Created
March 19, 2012 02:44
-
-
Save Rafe/2091680 to your computer and use it in GitHub Desktop.
RSpec Matcher helper:::
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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