Sha256: 083d75de49b29cbf3e8dabd4feaaa84179de3dcbb6f91243691dcba2419b2130

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

require 'cucumber/rspec/doubles'

RSPEC_EXPECTATION_NOT_MET_ERROR = RSpec::Expectations::ExpectationNotMetError

Then /^the following steps? should (fail|succeed):$/ do |expectation, steps_table|
  steps = steps_table.raw.flatten
  
  steps.each do |step|
    if expectation == 'fail'
      expect { step(step) }.to raise_error(RSPEC_EXPECTATION_NOT_MET_ERROR)
    
    else # succeed
      step(step)
    end

  end
end

When /^I run the following steps?:$/ do |steps_table|
  steps = steps_table.raw.flatten
  
  steps.each do |step|
    step(step)
  end
end

Then /^the following multiline step should (fail|succeed):$/ do |expectation, multiline_step|
  multiline_step = multiline_step.gsub(%{'''}, %{"""})
  if expectation == 'fail'
    expect { steps(multiline_step) }.to raise_error(RSPEC_EXPECTATION_NOT_MET_ERROR)
  else # succeed
    steps(multiline_step)
  end

end

Then(/^a hidden string with quotes should not be visible$/) do
  hidden_string = %Q{hidden '" quotes}
  assert_hidden(:text => hidden_string)
end

Then(/^a visible string with quotes should be visible$/) do
  visible_string = %Q{visible '" quotes}
  assert_visible(:text => visible_string)
end

Then(/^'show me the page' should open the page or take a screenshot$/) do
  # Projects with Capybara 1 & 2 use the launchy gem
  if Capybara::VERSION < "3.0"
    expect(Launchy).to receive(:open)
    step 'show me the page'
  else
    expect_any_instance_of(Capybara::Screenshot::Saver).to receive(:save)
    step 'show me the page'
  end
end

Version data entries

8 entries across 7 versions & 1 rubygems

Version Path
spreewald-2.2.2 tests/shared/features/shared/step_definitions/test_steps.rb
spreewald-2.2.2 tests/rails-4_capybara-3/features/step_definitions/test_steps.rb
spreewald-2.2.1 tests/shared/features/shared/step_definitions/test_steps.rb
spreewald-2.2.0 tests/shared/features/shared/step_definitions/test_steps.rb
spreewald-2.1.3 tests/shared/features/shared/step_definitions/test_steps.rb
spreewald-2.1.2 tests/shared/features/shared/step_definitions/test_steps.rb
spreewald-2.1.1 tests/shared/features/shared/step_definitions/test_steps.rb
spreewald-2.1.0 tests/shared/features/shared/step_definitions/test_steps.rb