Guest User

Untitled

a guest
Dec 6th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # RSpec's subject method, both implicitly and explicitly set, is useful for
  2. # declaratively setting up the context of the object under test. If you provide a
  3. # class for your describe block, subject will implicitly be set to a new instance
  4. # of this class (with no arguments passed to the constructor). If you want
  5. # something more complex done, such as setting arguments, you can use the
  6. # explicit subject setter, which takes a block.
  7. describe Person do
  8. context "born 19 years ago" do
  9. subject { Person.new(:birthdate => 19.years.ago }
  10. it { should be_eligible_to_vote }
  11. its(:age) { should == 19 }
  12. it "should be younger than a 20 year old" do
  13. twenty_year_old = Person.new(:birthday => 20.years.ago)
  14. subject.should be_younger_than(twenty_year_old)
  15. end
  16. end
  17. end
Add Comment
Please, Sign In to add comment