fix a cucumber web_step

pull/59/head
Philipp Tessenow 12 years ago
parent bae697185d
commit 6e0d0cdc99
  1. 23
      features/step_definitions/web_steps.rb

@ -18,7 +18,7 @@
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
#
require 'spec_helper' # for RSpec::Rails::Matchers
require 'uri'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
@ -289,21 +289,22 @@ end
Then /^there should be a( disabled)? "(.+)" field( visible| invisible)?(?: within "([^\"]*)")?(?: if plugin "(.+)" is loaded)?$/ do |disabled, fieldname, visible, selector, plugin_name|
if plugin_name.nil? || Redmine::Plugin.installed?(plugin_name)
with_scope(selector) do
if defined?(Spec::Rails::Matchers)
find_field(fieldname).should_not be_nil
field = find :field, fieldname, :visible => !(visible && visible == " invisible")
if defined?(RSpec::Rails::Matchers)
field.should_not be_nil
if visible && visible == " visible"
find_field(fieldname).should be_visible
field.should be_visible
elsif visible && visible == " invisible"
find_field(fieldname).should_not be_visible
field.should_not be_visible
end
if disabled
find_field(fieldname)[:disabled].should == "disabled"
field[:disabled].should == "disabled"
else
find_field(fieldname)[:disabled].should == nil
field[:disabled].should == nil
end
else
assert_not_nil find_field(fieldname)
assert_not_nil field
end
end
end
@ -311,7 +312,7 @@ end
Then /^there should not be a "(.+)" field(?: within "([^\"]*)")?$/ do |fieldname, selector|
with_scope(selector) do
if defined?(Spec::Rails::Matchers)
if defined?(RSpec::Rails::Matchers)
lambda {find_field(fieldname)}.should raise_error(Capybara::ElementNotFound)
else
assert_nil find_field(fieldname)
@ -320,7 +321,7 @@ Then /^there should not be a "(.+)" field(?: within "([^\"]*)")?$/ do |fieldname
end
Then /^there should be a "(.+)" button$/ do |button_label|
if defined?(Spec::Rails::Matchers)
if defined?(RSpec::Rails::Matchers)
page.should have_xpath("//input[@value='#{button_label}']")
else
raise NotImplementedError, "Only Matcher implemented"
@ -335,7 +336,7 @@ Then /^the "([^\"]*)" select(?: within "([^\"]*)")? should have the following op
field = find_field(field)
options_actual = field.all('option').collect(&:text)
if defined?(Spec::Rails::Matchers)
if defined?(RSpec::Rails::Matchers)
options_actual.should =~ options_expected
else
raise NotImplementedError, "Only Matcher implemented"

Loading…
Cancel
Save