Skip to content

Instantly share code, notes, and snippets.

@Rafe
Created March 19, 2012 02:44
Show Gist options
  • Save Rafe/2091680 to your computer and use it in GitHub Desktop.
Save Rafe/2091680 to your computer and use it in GitHub Desktop.
RSpec Matcher helper:::
#true/false
target.should be
# can connect to every method that ends with ?
#ex :
target.should be_admin
# check target.admin?
target.should be_true
target.should be_false
target.should be_nil
target.should_not be_arbitary_predicate(*args)
#ex:
target.should be_a_kinds_of(Fixnum) # => target.kinds_of?
#equal
target.should equal(expect)
# ===
target.should == expect
#include
[1,2,3].should includes(1)
#change
should change(receiver, message, &block)
should change(receiver, message, &block).by(value)
should change(receiver, message, &block).from(old).to(new)
should_not change(receiver, message, &block)
#ex:
lambda {
User.create!(:name => "Tester")
}.should change(User,:count).by(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment