Skip to content

Instantly share code, notes, and snippets.

@svenfuchs
Created January 27, 2009 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svenfuchs/53598 to your computer and use it in GitHub Desktop.
Save svenfuchs/53598 to your computer and use it in GitHub Desktop.
# 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