Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. RSpec::Matchers.define :act_like_a_good_foo do
  2. match do
  3. # subject is implicit in example
  4. subject.has_bar?.should == true
  5. subject.should be_true # predicate matchers defined within RSpec::Matchers
  6. subject.should have_bar
  7. end
  8. end
  9.  
  10. describe Foo do
  11. it { should act_like_a_good_foo }
  12. end
  13.  
  14. class MyAssertions
  15. include RSpec::Matchers
  16.  
  17. def assert_everything_is_ok
  18. @foo = Foo.new
  19. @foo.has_bar?.should == true # works!
  20. @foo.has_bar?.should be_true # works now :)
  21. @foo.should have_bar # works now :)
  22. end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement