2016-03-07 16:52:19 -08:00
|
|
|
# frozen_string_literal: true
|
2018-01-08 12:23:54 -08:00
|
|
|
|
2017-01-26 16:10:51 -08:00
|
|
|
When(/^I visit the (?:root|home) page$/) do
|
2011-02-06 14:34:32 +01:00
|
|
|
visit('/')
|
|
|
|
end
|
|
|
|
|
2017-01-26 16:10:51 -08:00
|
|
|
Then(/^I should see "([^"]*)"$/) do |text|
|
2013-11-14 09:43:36 -08:00
|
|
|
expect(page).to have_content(text)
|
2011-02-06 14:34:32 +01:00
|
|
|
end
|
|
|
|
|
2017-01-26 16:10:51 -08:00
|
|
|
Then(/^Capybara should use the "([^"]*)" driver$/) do |driver|
|
2013-11-14 09:43:36 -08:00
|
|
|
expect(Capybara.current_driver).to eq(driver.to_sym)
|
2011-02-06 14:34:32 +01:00
|
|
|
end
|
2011-02-06 14:44:43 +01:00
|
|
|
|
2017-01-26 16:10:51 -08:00
|
|
|
When(/^I use a matcher that fails$/) do
|
2011-02-06 14:44:43 +01:00
|
|
|
begin
|
2013-11-14 09:43:36 -08:00
|
|
|
expect(page).to have_css('h1#doesnotexist')
|
2014-06-11 11:52:29 -07:00
|
|
|
rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e
|
2011-02-06 14:44:43 +01:00
|
|
|
@error_message = e.message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-26 16:10:51 -08:00
|
|
|
Then(/^the failing exception should be nice$/) do
|
2018-05-14 14:30:34 -07:00
|
|
|
expect(@error_message).to match(/expected to find visible css \"h1#doesnotexist\"/)
|
2011-02-06 14:44:43 +01:00
|
|
|
end
|