teamcapybara--capybara/features/step_definitions/capybara_steps.rb

26 lines
653 B
Ruby
Raw Normal View History

2016-03-08 00:52:19 +00:00
# frozen_string_literal: true
2018-01-08 20:23:54 +00:00
2017-01-27 00:10:51 +00:00
When(/^I visit the (?:root|home) page$/) do
visit('/')
end
2017-01-27 00:10:51 +00:00
Then(/^I should see "([^"]*)"$/) do |text|
expect(page).to have_content(text)
end
2017-01-27 00:10:51 +00:00
Then(/^Capybara should use the "([^"]*)" driver$/) do |driver|
expect(Capybara.current_driver).to eq(driver.to_sym)
end
2017-01-27 00:10:51 +00:00
When(/^I use a matcher that fails$/) do
begin
expect(page).to have_css('h1#doesnotexist')
rescue StandardError, RSpec::Expectations::ExpectationNotMetError => e
@error_message = e.message
end
end
2017-01-27 00:10:51 +00:00
Then(/^the failing exception should be nice$/) do
2018-01-09 22:05:50 +00:00
expect(@error_message).to match %r{expected to find visible css \"h1#doesnotexist\"}
end