Hi,
I am using cucumber with webrat for testing my application.
I have admin role in my application.
When admin logs into the system he able to see the “Users” link which
gives an interface to manage users for admin. I have written the feature
like as follows:-
Feature: List All Users
So that Admin can manage users
Scenario: Login as Admin
When I login with user “username” with password “123456”
Then “Users” link should be shown
My Step definition code is like as follows:-
When /^I login with user “([^”])" with password “([^”])"$/ do |login,
password|
visit “/”
fill_in “login”, :with=>login
fill_in “password”, :with=>password
click_button “Log in”
File.open(“response.html”, ‘w’) {|f| f.write( response.body) }
response.should contain(“Logged in successfully”)
end
Then /^"([^"]*)" link should be shown$/ do |arg1|
clicks_link user_list_path
#pending # express the regexp above with the code you wish you had
end
My problem is 2nd step:-
Could not find link with text or title or id “/user-list”
(Webrat::NotFoundError)
features/admin.feature:5:in `Then “Users” link should be shown’
Failing Scenarios:
cucumber features/admin.feature:3 # Scenario: Login as Admin
Is there anything wrong with my code?
How can I check whether the link is present or not?
Also, My login is successful as admin but when I print response I get
the home page structure and not the app home page.
Can anyone help me out?
Thanks,
Mike