-
-
Save lazyatom/163827 to your computer and use it in GitHub Desktop.
This file contains 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
context "A user posting to a blog" do | |
setup do | |
@user = Factory(:user) | |
@blog = Factory(:blog) | |
end | |
action do | |
post :create, :user_id => @user.id, :id => @blog.id, :post => {:body => "Blah"} | |
end | |
# the body of this block is actually executed after 'setup' but before 'action' | |
expect "send a notification to Technorati or whatever" do | |
TechnoratiApi.expects(:notify) | |
end | |
expect "kill a kitten" do | |
KittyKiller.expects(:murder_randomly) | |
end | |
should "put the post into the users's posts" do | |
assert @user.posts.include?("Blah") # or whatever | |
end | |
# etc | |
end |
This file contains 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
How it all runs | |
------------ | |
three 'tests' are generated: | |
test: A user posting to a blog should send a notification to Technorati or whatever | |
- setup runs | |
- Technorati expectation is setup | |
- action runs | |
- test body is empty | |
- expectations are then implicitly handled by mocha as normal | |
test: A user posting to a blog should kill a kitten | |
- setup runs | |
- KittyKiller expectation is setup | |
- action runs | |
- test body is empty | |
- expectations are then implicitly handled by mocha as normal | |
test: A user posting toa blog should put the post into the user's posts | |
- setup runs | |
- action runs | |
- test body runs and assertions are handled by test/unit as normal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment