Browse files

Rspec.

  • Loading branch information...
1 parent 6295e7e commit cad0ca2bffb4305760dbc6702386957f6d85cafd @rstacruz committed Mar 21, 2012
Showing with 15 additions and 29 deletions.
  1. +15 −29 rspec.md
View
44 rspec.md
@@ -57,58 +57,44 @@ title: RSpec
### Expectations
+ # Can be .should or .should_not
+
+ # Numeric
target.should be < 6
target.should == 5
+ target.should equal value
target.should be_between(1, 10)
- target.should_not == 'Samantha'
-
- target.should be <value>
- target.should_not be <value>
+ target.should be_close value, tolerance
+ target.should be value
target.should satisfy {|arg| ...}
- target.should_not satisfy {|arg| ...}
-
- target.should equal <value>
- target.should not_equal <value>
-
- target.should be_close <value>, <tolerance>
- target.should_not be_close <value>, <tolerance>
-
target.should predicate [optional args]
- target.should be_predicate [optional args]
- target.should_not predicate [optional args]
- target.should_not be_predicate [optional args]
-
- target.should match <regex>
- target.should_not match <regex>
+ target.should match regexp
target.should be_an_instance_of <class>
- target.should_not be_an_instance_of <class>
-
target.should be_a_kind_of <class>
- target.should_not be_a_kind_of <class>
target.should respond_to <symbol>
- target.should_not respond_to <symbol>
- lambda {a_call}.should raise_error
- lambda {a_call}.should raise_error(<exception> [, message])
- lambda {a_call}.should_not raise_error
- lambda {a_call}.should_not raise_error(<exception> [, message])
- lambda {a_call}.should change(instance, method).from(number).to(number)
+ # Control flow
+ proc.should raise_error
+ proc.should raise_error(<exception> [, message])
proc.should throw <symbol>
- proc.should_not throw <symbol>
+ # Enumerables/arrays
target.should include <object>
- target.should_not include <object>
target.should have(<number>).things
target.should have_at_least(<number>).things
target.should have_at_most(<number>).things
target.should have(<number>).errors_on(:field)
+ # Change
+ proc.should change(instance, method).from(number).to(number)
+
+ # proc.should <=> expect(&proc).to
expect { thing.approve! }.to change(thing, :status).
from(Status::AWAITING_APPROVAL).
to(Status::APPROVED)

0 comments on commit cad0ca2

Please sign in to comment.