Class: Browsery::Settings
- Inherits:
-
Object
- Object
- Browsery::Settings
- Defined in:
- lib/browsery/settings.rb
Overview
An object that holds runtime settings.
Furthermore, Minitest doesn’t provide any good way of passing a hash of options to each test.
TODO: We’re importing ActiveSupport’s extensions to Hash, which means that we’ll be amending the way Hash objects work; once AS updates themselves to ruby 2.0 refinements, let’s move towards that.
Instance Method Summary collapse
- #auto_finalize? ⇒ Boolean
- #connector ⇒ Object
- #env ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #inspect ⇒ Object
- #io ⇒ Object
- #merge!(other) ⇒ Object
-
#parallel ⇒ Object
can be used as a flag no matter parallel option is used in command line or not can also be used to fetch the value if a valid value is specified.
- #raw_arguments ⇒ Object
- #rerun_failure ⇒ Object
- #reuse_driver? ⇒ Boolean
- #sauce_access_key ⇒ Object
- #sauce_session_http_auth(driver) ⇒ Object
- #sauce_username ⇒ Object
- #seed ⇒ Object
- #tags ⇒ Object
- #verbose? ⇒ Boolean
- #verbosity_level ⇒ Object
- #visual_regression ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
13 14 15 |
# File 'lib/browsery/settings.rb', line 13 def initialize @hsh = {} end |
Instance Method Details
#auto_finalize? ⇒ Boolean
22 23 24 |
# File 'lib/browsery/settings.rb', line 22 def auto_finalize? hsh.fetch(:auto_finalize, true) end |
#connector ⇒ Object
26 27 28 |
# File 'lib/browsery/settings.rb', line 26 def connector hsh.fetch(:connector, :firefox).to_s end |
#env ⇒ Object
30 31 32 33 34 |
# File 'lib/browsery/settings.rb', line 30 def env # add a gitignored env file which stores a default env # pass the default env in as default hsh.fetch(:env, :rent_qa).to_s end |
#inspect ⇒ Object
17 18 19 20 |
# File 'lib/browsery/settings.rb', line 17 def inspect settings = self.class.public_instance_methods(false).sort.map(&:inspect).join(', ') "#<Browsery::Settings #{settings}>" end |
#io ⇒ Object
49 50 51 |
# File 'lib/browsery/settings.rb', line 49 def io hsh[:io] end |
#merge!(other) ⇒ Object
53 54 55 56 |
# File 'lib/browsery/settings.rb', line 53 def merge!(other) hsh.merge!(other.symbolize_keys) self end |
#parallel ⇒ Object
can be used as a flag no matter parallel option is used in command line or not can also be used to fetch the value if a valid value is specified
60 61 62 63 64 65 66 |
# File 'lib/browsery/settings.rb', line 60 def parallel if hsh[:parallel] == 0 return nil else hsh.fetch(:parallel).to_i end end |
#raw_arguments ⇒ Object
68 69 70 |
# File 'lib/browsery/settings.rb', line 68 def raw_arguments hsh.fetch(:args, nil).to_s end |
#rerun_failure ⇒ Object
76 77 78 |
# File 'lib/browsery/settings.rb', line 76 def rerun_failure hsh.fetch(:rerun_failure) end |
#reuse_driver? ⇒ Boolean
72 73 74 |
# File 'lib/browsery/settings.rb', line 72 def reuse_driver? hsh.fetch(:reuse_driver, false) end |
#sauce_access_key ⇒ Object
45 46 47 |
# File 'lib/browsery/settings.rb', line 45 def sauce_access_key sauce_user["pass"] end |
#sauce_session_http_auth(driver) ⇒ Object
36 37 38 39 |
# File 'lib/browsery/settings.rb', line 36 def sauce_session_http_auth(driver) session_id = driver.session_id "https://#{sauce_username}:#{sauce_access_key}@saucelabs.com/rest/v1/#{sauce_username}/jobs/#{session_id}" end |
#sauce_username ⇒ Object
41 42 43 |
# File 'lib/browsery/settings.rb', line 41 def sauce_username sauce_user["user"] end |
#seed ⇒ Object
84 85 86 |
# File 'lib/browsery/settings.rb', line 84 def seed hsh.fetch(:seed, nil).to_i end |
#tags ⇒ Object
88 89 90 |
# File 'lib/browsery/settings.rb', line 88 def hsh[:tags] ||= [] end |
#verbose? ⇒ Boolean
92 93 94 |
# File 'lib/browsery/settings.rb', line 92 def verbose? verbosity_level > 0 end |
#verbosity_level ⇒ Object
96 97 98 |
# File 'lib/browsery/settings.rb', line 96 def verbosity_level hsh.fetch(:verbosity_level, 0).to_i end |
#visual_regression ⇒ Object
80 81 82 |
# File 'lib/browsery/settings.rb', line 80 def visual_regression hsh.fetch(:visual_regression) end |