Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # RSpec's subject method, both implicitly and explicitly set, is useful for
- # declaratively setting up the context of the object under test. If you provide a
- # class for your describe block, subject will implicitly be set to a new instance
- # of this class (with no arguments passed to the constructor). If you want
- # something more complex done, such as setting arguments, you can use the
- # explicit subject setter, which takes a block.
- describe Person do
- context "born 19 years ago" do
- subject { Person.new(:birthdate => 19.years.ago }
- it { should be_eligible_to_vote }
- its(:age) { should == 19 }
- it "should be younger than a 20 year old" do
- twenty_year_old = Person.new(:birthday => 20.years.ago)
- subject.should be_younger_than(twenty_year_old)
- end
- end
- end
Add Comment
Please, Sign In to add comment