Hello list,
I’m having problems with the following integration test (tests for the
authentication aspects of the application):
require “#{File.dirname(FILE)}/…/test_helper”
class AuthenticationTest < ActionController::IntegrationTest
fixtures :your, :models
def test_successful_login
george = enter_site(:george)
end
module BrowsingTestDSL
include ERB::Util
attr_writer :name
def tries_to_go_to_admin
get "/admin/book/new"
assert_response :redirect
assert_redirected_to "/account/login"
end
def enter_site(name)
open_session do |session|
session.extend(BrowsingTestDSL)
session.name = name
yield session if block_given?
end
end
end
end
When I run this test, rails tell me test_site() is undefined, however,
I’ve
declared it inside the private module (I’m using the module to implement
this test’s DSL, as seen in the book Beginning Ruby on Rails E-Commerce
from
Apress).
Here’s the output:
"Loaded suite test/integration/authentication_test
Started
E
Finished in 0.312 seconds.
- Error:
test_successful_login(AuthenticationTest):
NoMethodError: undefined methodenter_site' for #<ActionController::Integration::Session:0x4751620> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/test_process.rb:452:in
meod_missing’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:547:in
sen c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:547:in
metd_missing’
test/integration/authentication_test.rb:7:intest_successful_login' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/integration.rb:453:in
run
1 tests, 0 assertions, 0 failures, 1 errors"
What am I doing wrong ?
Thanks in advance,
Marcelo.