Sha256: 91e3c7f6df8c7d7eea52a79286773185a72653956f8b02f1553bdd29f9b13a9e

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'capybara'

When /^I (?:fill in|select|choose|check|press) a nonexistent (.+) an error should be raised$/ do |type|

  case type
  when "text field" then
    assert_raise(RuntimeError,Capybara::ElementNotFound) do
      When %{I fill in "nonexistent" with "anything"}
    end
  when "select field" then
    assert_raise(RuntimeError,Capybara::ElementNotFound) do
      When %{I select "anything" from "nonexistent"}
    end
  when "radio button" then
    assert_raise(RuntimeError,Capybara::ElementNotFound) do
      When %{I choose "nonexistent"}
    end
  when "checkbox" then
    assert_raise(RuntimeError,Capybara::ElementNotFound) do
      When %{I check "nonexistent"}
    end
  when "button" then
    assert_raise(RuntimeError,Capybara::ElementNotFound) do
      When %{I press "nonexistent"}
    end
  else assert false
  end
end

When /^I follow a nonexistent link an error should be raised$/ do 
  assert_raise(RuntimeError,Capybara::ElementNotFound) do
    When %{I follow "nonexistent"}
  end
end

When /^I select a missing option from an existing select an error should be raised$/ do
  assert_raise(RuntimeError,Capybara::OptionNotFound) do
    When %{I select "nonexistent" from "Exists"}
  end
end

When /^I test the value of a nonexistent field contains an error should be raised$/ do
  assert_raise(RuntimeError,NoMethodError) do
    When %{the "nonexistent" field should contain "Anything"}
  end

  assert_raise(RuntimeError,NoMethodError) do
    When %{the "nonexistent" field should not contain "Anything"}
  end
end

When /^I test state of a nonexistent checkbox contains an error should be raised$/ do
  assert_raise(RuntimeError,NoMethodError) do
    When %{the "nonexistent" checkbox should be checked}
  end

  assert_raise(RuntimeError,NoMethodError) do
    When %{the "nonexistent" checkbox should not be checked}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mechanical-cuke-0.5.0 features/step_definitions/missing_field_steps.rb