Created
July 5, 2009 17:55
-
-
Save dreamcat4/141065 to your computer and use it in GitHub Desktop.
Shoulda macros
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
class Test::Unit::TestCase | |
# http://programblings.com/2008/10/31/two-shoulda-best-practices/ | |
# Sets the current person in the session from the person fixtures. | |
def self.logged_in_as(person, &block) | |
context "logged in as #{person}" do | |
setup do | |
@request.session[:person] = people(person).id | |
end | |
context '' do | |
yield | |
end | |
end | |
end | |
# Use this macro as a block | |
logged_in_as :mat do | |
# Contexts, setup | |
# Shoulda tests | |
end | |
# Declare a shoulda macro | |
def self.should_build_request_path(path) | |
should "build request path of #{path}" do | |
assert {path == @api_call.build_request_path} | |
end | |
end | |
should_raise(LoadError, :message => "such file to load") do | |
require "more vespene gas" | |
end | |
should_build_request_path '/v1/tags/get' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment