lib/quke/configuration.rb in quke-0.3.1 vs lib/quke/configuration.rb in quke-0.3.2
- old
+ new
@@ -114,10 +114,23 @@
# have is not supported by the site.
def user_agent
@data['user_agent']
end
+ # Return the value set for +javascript_errors+.
+ #
+ # Currently only supported when using the phantomjs driver (ignored by the
+ # others). In phantomjs if a site has a javascript error we can configure it
+ # to throw an error which will cause the test to fail. Quke by default sets
+ # this to true, however you can override it by setting this flag to false.
+ # For example you may be dealing with a legacy site and JavaScript errors
+ # are out of your scope. You still want to test other aspects of the site
+ # but not let these errors prevent you from using phantomjs.
+ def javascript_errors
+ @data['javascript_errors']
+ end
+
# Return the hash of +browserstack+ options.
#
# If you select the browserstack driver, there are a number of options you
# can pass through to setup your browserstack tests, username and auth_key
# being the critical ones.
@@ -168,17 +181,24 @@
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
def default_data!(data)
data.merge(
- 'features_folder' => (data['features'] || 'features').downcase.strip,
- 'app_host' => (data['app_host'] || '').downcase.strip,
- 'driver' => (data['driver'] || 'phantomjs').downcase.strip,
- 'pause' => (data['pause'] || '0').to_s.downcase.strip.to_i,
- 'stop_on_error' => (data['stop_on_error'] || 'false').to_s.downcase.strip,
- 'max_wait_time' => (data['max_wait_time'] || Capybara.default_max_wait_time).to_s.downcase.strip.to_i,
- 'user_agent' => (data['user_agent'] || '').strip,
- 'custom' => (data['custom'] || nil)
+ 'features_folder' => (data['features'] || 'features').downcase.strip,
+ 'app_host' => (data['app_host'] || '').downcase.strip,
+ 'driver' => (data['driver'] || 'phantomjs').downcase.strip,
+ 'pause' => (data['pause'] || '0').to_s.downcase.strip.to_i,
+ 'stop_on_error' => (data['stop_on_error'] || 'false').to_s.downcase.strip,
+ 'max_wait_time' => (data['max_wait_time'] || Capybara.default_max_wait_time).to_s.downcase.strip.to_i,
+ 'user_agent' => (data['user_agent'] || '').strip,
+ # Because we want to default to 'true', but allow users to override it
+ # with 'false' it causes us to mess with the logic. Essentially if the
+ # user does enter false (either as a string or as a boolean) the result
+ # will be 'true', so we flip it back to 'false' with !.
+ # Else the condition fails and we get 'false', which when flipped gives
+ # us 'true', which is what we want the default value to be
+ 'javascript_errors' => !(data['javascript_errors'].to_s.downcase.strip == 'false'),
+ 'custom' => (data['custom'] || nil)
)
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/PerceivedComplexity