diff options
| author | luu <luuduong@gmail.com> | 2014-12-06 15:21:37 +0000 |
|---|---|---|
| committer | luu <luuduong@gmail.com> | 2014-12-06 15:21:37 +0000 |
| commit | f60ca93a327d773723f2ac7235331702256da656 (patch) | |
| tree | acff2a43acf7cc33baaaa5d2681ed3f7ca921eaf /spec/models | |
| parent | ad658c4c7ba39191ed379ed73aa4a1b5a463be45 (diff) | |
add validation for asin and valid tool.
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/tool_spec.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/spec/models/tool_spec.rb b/spec/models/tool_spec.rb index caf6ba94..db08b512 100644 --- a/spec/models/tool_spec.rb +++ b/spec/models/tool_spec.rb @@ -34,18 +34,30 @@ describe Tool do end context "#validation" do + let(:tool) { build(:tool) } + it "has to have a name" do - tool = Tool.new + tool.name = nil expect(tool).to_not be_valid expect(tool.errors[:name]).to_not be_empty end it "name has to be unique" do - Tool.create(name: 'blah') - - tool = Tool.new(name: 'blah') - tool.valid? + create(:tool, name: 'blah') + tool.name = 'blah' + + expect(tool).to_not be_valid expect(tool.errors[:name]).to_not be_empty end + + it "has a ASIN number" do + tool.asin = nil + expect(tool).to_not be_valid + expect(tool.errors[:asin]).to_not be_empty + end + + it "validates" do + expect(tool).to be_valid + end end end |
