Ahmy Yulrizka
On Mon, Dec 20, 2010 at 1:20 PM, Mike Disuza
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> 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''
>
> If im not mistaken, the clicks_link accept the "link text" rather
then the
url
http://webrat.rubyforge.org/classes/ActionController/Integration/Session.html#M000004
if you have <a href="/users">User List"</a>
the step should be clicks_link "User List"
also you might want to see the features/step_definition/web_step.rb
you could use the predefined helper "follow"
so in the description you could use
...
And I follow "User List"
...
> Failing Scenarios:
> cucumber features/admin.feature:3 # Scenario: Login as Admin
>
>
>
I don''t really know about this, but there is also predefined step that
will
help you look at what webrat "see" the step is
show_me_the_page
when it''s called, it save current response html to /tmp
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
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.