Created
January 27, 2009 22:10
-
-
Save svenfuchs/53598 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
# from http://weblog.jamisbuck.org/2006/3/9/integration-testing-in-rails-1-1 | |
require "#{File.dirname(__FILE__)}/../test_helper" | |
class StoriesTest < ActionController::IntegrationTest | |
fixtures :accounts, :ledgers, :registers, :people | |
def test_signup_new_person | |
new_session do |bob| | |
bob.goes_to_login | |
bob.goes_to_signup | |
bob.signs_up_with :name => "Bob", :user_name => "bob", | |
:password => "secret" | |
end | |
end | |
private | |
module MyTestingDSL | |
def goes_to_login | |
get "/login" | |
assert_response :success | |
assert_template "login/index" | |
end | |
def goes_to_signup | |
get "/signup" | |
assert_response :success | |
assert_template "signup/index" | |
end | |
def signs_up_with(options) | |
post "/signup", options | |
assert_response :redirect | |
follow_redirect! | |
assert_response :success | |
assert_template "ledger/index" | |
end | |
end | |
def new_session | |
open_session do |sess| | |
sess.extend(MyTestingDSL) | |
yield sess if block_given? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment