Skip to content

Instantly share code, notes, and snippets.

@svenfuchs

svenfuchs/gist:53598

Created Jan 27, 2009
Embed
What would you like to do?
# 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