class ActionDispatch::IntegrationTest

end
end
end
assert(…)
:password => who.password
sess.post “/login”, :username => who.username,
who = people(who)
sess.extend(CustomAssertions)
open_session do |sess|
def login(who)
end
end

assert(…)
xml_http_request “/say/#{room.id}”, :message => message
def speak(room, message)
end

assert(…)
get(room_url(:id => room.id))
# reference a named route, for maximum internal consistency!
def enter(room)
module CustomAssertions
private
end
david.speak(room, “hello!”)
david.enter(room)
jamis.speak(room, “anybody home?”)
jamis.enter(room)
room = rooms(:office)
jamis, david = login(:jamis), login(:david)
def test_login_and_speak
fixtures :people, :rooms
class AdvancedTest < ActionDispatch::IntegrationTest
require “test_helper”
reference any named routes you happen to have defined.
powerful testing DSL that is specific for your application. You can even
even extend those instances with assertions and methods to create a very
However, you can also have multiple session instances open per test, and
end
end
assert_equal “/home”, path
assert_equal 200, status
follow_redirect!
:password => people(:jamis).password
post “/login”, :username => people(:jamis).username,
# post the login and follow through to the home page
assert_equal 200, status
get “/login”
# get the login page
def test_login
fixtures :people
class ExampleTest < ActionDispatch::IntegrationTest
require “test_helper”
using the get/post methods:
At its simplest, you simply extend IntegrationTest and write your tests
entire stack, from the dispatcher to the database.
more completely than either unit or functional tests do, exercising the
tying them all together to ensure they work together as expected. It tests
An integration test spans multiple controllers and actions,

def self.app

def self.app
  # DEPRECATE Rails application fallback
  # This should be set by the initializer
  @@app || (defined?(Rails.application) && Rails.application) || nil
end

def self.app=(app)

def self.app=(app)
  @@app = app
end

def app

def app
  super || self.class.app
end

def url_options

def url_options
  reset! unless integration_session
  integration_session.url_options
end