I'm new to Ruby and Cucumber, but I'm using it to test high level functionality in my web app. I've mostly got the idea of how it works, but I'm struggling with one bit. I'm using a background in the scenario file to say: Given a user is logged in and this are the steps:
Given /^I am logged in as "([^"]*)" with password "([^"]*)"$/ do |user, password|
visit "http://www.website.com:82/login"
#Is there a 'logout'?
if (response_body contain('Login')) then
fill_in "email", :with => user
fill_in "password", :with => password
click_button "Login"
end
response_body.should contain("Your Accounts")
end
I'm having trouble with the if. I want to say 'If not logged in, log in' but not sure whether to use the webrat object (if that's what response_body is) or something else!
Thanks
Mike
I probably would have went with something like (seems a bit cleared to me than throwing conditionals into Cucumber):