lib/spreewald/web_steps.rb in spreewald-1.0.0 vs lib/spreewald/web_steps.rb in spreewald-1.1.0
- old
+ new
@@ -266,21 +266,21 @@
# nodoc
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
patiently do
with_scope(parent) do
field_checked = find_field(label)['checked']
- field_checked.should be_true
+ field_checked.should == true
end
end
end
# nodoc
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
patiently do
with_scope(parent) do
field_checked = find_field(label)['checked']
- field_checked.should be_false
+ field_checked.should == false
end
end
end
Then /^the radio button "([^"]*)" should( not)? be (?:checked|selected)$/ do |field, negate|
@@ -430,11 +430,11 @@
# Checks that an element is actually visible, also considering styles
# Within a selenium test, the browser is asked whether the element is really visible
# In a non-selenium test, we only check for `.hidden`, `.invisible` or `style: display:none`
#
# More details [here](https://makandracards.com/makandra/1049-capybara-check-that-a-page-element-is-hidden-via-css)
-Then /^(the tag )?"([^\"]+)" should( not)? be visible$/ do |tag, selector_or_text, negate|
+Then /^(the tag )?"([^\"]+)" should( not)? be visible$/ do |tag, selector_or_text, hidden|
case Capybara::current_driver
when :selenium, :webkit, :poltergeist
patiently do
visibility_detecting_javascript = %[
(function() {
@@ -476,20 +476,19 @@
}
return false;
})();
].gsub(/\n/, ' ')
- matcher = negate ? be_false : be_true
- page.evaluate_script(visibility_detecting_javascript).should matcher
+ page.evaluate_script(visibility_detecting_javascript).should == !hidden
end
else
invisibility_detecting_matcher = if tag
have_css(".hidden, .invisible, [style~=\"display: none\"] #{selector_or_text}")
else
have_css('.hidden, .invisible, [style~="display: none"]', :text => selector_or_text)
end
- expectation = negate ? :should : :should_not # sic
+ expectation = hidden ? :should : :should_not # sic
page.send(expectation, invisibility_detecting_matcher)
end
end
# Click on some text that might not be a link
@@ -611,25 +610,26 @@
end
["false", "", nil].send(negate ? :should : :should_not, include(element[:disabled]))
end
# Tests that a field with the given label is visible.
-Then /^the "([^\"]*)" field should( not)? be visible$/ do |label, negate|
+Then /^the "([^\"]*)" field should( not)? be visible$/ do |label, hidden|
field = find_field(label)
- expectation = negate ? :should_not : :should
+
case Capybara::current_driver
when :selenium, :webkit
patiently do
visibility_detecting_javascript = %[
(function(){
var field = $('##{field['id']}');
return(field.is(':visible'));
})();
].gsub(/\n/, ' ')
- page.evaluate_script(visibility_detecting_javascript).send(expectation, be_true)
+ page.evaluate_script(visibility_detecting_javascript).should == !hidden
end
else
+ expectation = hidden ? :should_not : :should
field.send(expectation, be_visible)
end
end
# Waits for the page to finish loading and AJAX requests to finish.
@@ -637,10 +637,10 @@
# More details [here](https://makandracards.com/makandra/12139-waiting-for-page-loads-and-ajax-requests-to-finish-with-capybara).
When /^I wait for the page to load$/ do
if [:selenium, :webkit, :poltergeist].include?(Capybara.current_driver)
patiently do
# when no jQuery is loaded, we assume there are no pending AJAX requests
- page.evaluate_script("typeof jQuery === 'undefined' || $.active == 0").should be_true
+ page.evaluate_script("typeof jQuery === 'undefined' || $.active == 0").should == true
end
end
page.has_content? ''
end