Advertisement
mud_dauber

Rspec example

Apr 26th, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. require "spec_helper"
  2.  
  3. describe Contact do |v|
  4. it "is valid with a firstname, lastname and email" do
  5. c = Contact.new(
  6. firstname: "joe",
  7. lastname: "smith",
  8. email: "[email protected]")
  9. expect(c).to be_valid
  10. end
  11.  
  12. it "is invalid without a firstname" do
  13.  
  14. expect(Contact.new(firstname: nil)).to_have(1).errors_on(:firstname)
  15. end
  16.  
  17. it "is invalid without a lastname"
  18. it "is invalid without an email address"
  19. it "is invalid without a duplicate email address"
  20. it "returns a contact's full name as a string"
  21. end
  22.  
  23. /*** BUNDLE EXEC RSPEC ***/
  24.  
  25. Failures:
  26.  
  27. 1) Contact is invalid without a firstname
  28. Failure/Error: expect(Contact.new(firstname: nil)).to_have(1).errors_on(:firstname)
  29. NoMethodError:
  30. undefined method `to_have' for #<RSpec::Expectations::ExpectationTarget:0xb3068ac>
  31. # ./spec/models/contact_spec.rb:14:in `block (2 levels) in <top (required)>'
  32.  
  33. Finished in 0.03346 seconds
  34. 6 examples, 1 failure, 4 pending
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement