replace asserts with rspec equivalents

This commit is contained in:
Fabian Rodriguez 2013-08-12 19:20:15 -03:00
parent 625159c8ad
commit c69853e0cf
2 changed files with 9 additions and 46 deletions

View file

@ -216,11 +216,7 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should be filled with "([^"]*)"
field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
field_value = field_value.first if field_value.is_a? Array
if field_value.respond_to? :should
field_value.should == value
else
assert_equal(value, field_value)
end
field_value.should == value
end
end

View file

@ -119,22 +119,14 @@ end
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
regexp = Regexp.new(regexp)
with_scope(selector) do
if page.respond_to? :should
page.should have_xpath('//*', :text => regexp)
else
assert page.has_xpath?('//*', :text => regexp)
end
page.should have_xpath('//*', :text => regexp)
end
end
Then /^(?:|I )should not see (\".+?\"[\s]*)(?:[\s]+within[\s]* "([^"]*)")?$/ do |vars,selector|
vars.scan(/"([^"]+?)"/).flatten.each do |text|
with_scope(selector) do
if page.respond_to? :should
page.should have_no_content(text)
else
assert page.has_no_content?(text)
end
page.should have_no_content(text)
end
end
end
@ -142,11 +134,7 @@ end
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
regexp = Regexp.new(regexp)
with_scope(selector) do
if page.respond_to? :should
page.should have_no_xpath('//*', :text => regexp)
else
assert page.has_no_xpath?('//*', :text => regexp)
end
page.should have_no_xpath('//*', :text => regexp)
end
end
@ -154,11 +142,7 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |
with_scope(selector) do
field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should
field_value.should =~ /#{value}/
else
assert_match(/#{value}/, field_value)
end
field_value.should =~ /#{value}/
end
end
@ -166,33 +150,21 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/
with_scope(selector) do
field = find_field(field)
field_value = (field.tag_name == 'textarea') ? field.text : field.value
if field_value.respond_to? :should_not
field_value.should_not =~ /#{value}/
else
assert_no_match(/#{value}/, field_value)
end
field_value.should_not =~ /#{value}/
end
end
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
with_scope(selector) do
field_checked = find_field(label)['checked']
if field_checked.respond_to? :should
field_checked.should be_true
else
assert field_checked
end
field_checked.should be_true
end
end
Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
with_scope(selector) do
field_checked = find_field(label)['checked']
if field_checked.respond_to? :should
field_checked.should be_false
else
assert !field_checked
end
field_checked.should be_false
end
end
@ -206,12 +178,7 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
actual_params = query ? CGI.parse(query) : {}
expected_params = {}
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
if actual_params.respond_to? :should
actual_params.should == expected_params
else
assert_equal expected_params, actual_params
end
actual_params.should == expected_params
end
Then /^show me the page$/ do