= FactoryGirl.create :user, username: 'demo', password: 'demo1234' End Then(/^I will be shown a message error$/) do expect(page).to have_content 'Invalid login or password.' end When(/^I press Sign in$/) do click_button 'Sign in' end Then(/^I will be redirected to home page$/) do expect(page).to have_content 'Login successful' end Then(/^I will be redirected to (.*) page$/) do |url| path = URI.parse(current_url).path expect(path).to match "/#{url}" end