Cucumber & Capybara
Given(/^I have signed in$/) do
user = User.create(email: "
[email protected]", password: "password")
visit(new_user_session_path)
fill_in("Email", :with => @user.email)
fill_in("Password", :with => @user.password)
click_button("Sign in")
end
When(/^I go to the task form$/) do
visit(tasks_path)
end
When(/^create a new task$/) do
fill_in('Description', :with => 'Find the meaning of life')
click_button('Create Task')
end
Then(/^the above (.*) should be created$/) do |model|
model.humanize.constantize.count().should == 1 // Task.count().should == 1
end
Then(/^I should see the text "(.*)"$/) do |text|
page.should have_content(text)
end
Monday, May 27, 13