Simple sign in integration test fails

7 views
Skip to first unread message

Yogi

unread,
Dec 5, 2010, 11:59:45 AM12/5/10
to Devise
I have before_filter on application_controller level to authenticate.
Now I'm writing simple integration test with cucumber/webrat and I
want to assert the redirect to login page unless the user is signed
in. The following test fails and it seems that cucumber/webrat isn't
redirected to sign_in page. Am I not grasping something?

Given /^the user has not logged in$/ do
visit destroy_user_session_path
end

When /^user visits item listing page$/ do
visit items_path
end

Then /^user should end up in page (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
current_path.should == path_to(page_name)
else
assert_equal path_to(page_name), current_path
end
end


(::) failed steps (::)

expected: "/users/sign_in",
got: "/items" (using ==)
(RSpec::Expectations::ExpectationNotMetError)
Reply all
Reply to author
Forward
0 new messages