Rodrigo Rosenfeld Rosas
2009-Oct-30 09:30 UTC
[rspec-users] webrat, Rails and controller sessions
When I ran ''rake spec'', it generated a spec_helper.rb with the
following
line:
require ''webrat/integrations/rspec-rails''
It seems that this file changed to webrat/rspec-rails on last webrat gem.
But changing to "require ''webrat/rspec-rails''"
doesn''t seem to work.
What solved for me was following webrat documentation:
Webrat.configure do |config|
config.mode = :rails
end
And including "config.gem ''webrat''" in
environments/test.rb.
''spec'' rake task should probably be updated to reflect current
webrat...
Anyway, I was wondering if it is possible to get the Rails session from
the specs and resetting it, for instance.
I''ve used another approach in my tests, but I think it would be
interesting to evaluate the session state in some tests... Is it possible?
Here is what I''m doing currently:
describe UsersController do
context ''when accessing protected area'' do
before(:each) do
@user = User.make :password => ''secret''
end
it ''should authenticate with login or e-mail'' do
[@user.login, @user.email].each do |login_or_email|
# session[''user''] = nil
visit ''/''
click_link I18n.t(:''user.login'')
fill_in ''login'', :with => login_or_email
fill_in ''password'', :with =>
''secret''
click_button I18n.t(:''user.login'')
contain @user.name
click_link I18n.t :''user.logout''
# session[''user''].should == @user.id
end
visit ''/''
click_link I18n.t(:''user.login'')
fill_in ''login'', :with => @user.login
fill_in ''password'', :with =>
''wrong''
click_button I18n.t(:''user.login'')
assert_not_contain @user.name
# session[''user''].should be_nil
end
end
end
Thanks,
Rodrigo.
__________________________________________________
Fa?a liga??es para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/