Module: Crabfarm::RSpec::NavigatorSpecHelpers
- Defined in:
- lib/crabfarm/rspec/navigator_spec_helpers.rb
Instance Method Summary collapse
- #browser(_session_id = nil) ⇒ Object
- #last_state ⇒ Object
- #navigate(_name = nil, _params = {}) ⇒ Object
- #spy_reducer(_name_or_class) ⇒ Object
- #state ⇒ Object
Instance Method Details
#browser(_session_id = nil) ⇒ Object
39 40 41 42 |
# File 'lib/crabfarm/rspec/navigator_spec_helpers.rb', line 39 def browser(_session_id=nil) ensure_context_for :browser @navigator_context.pool.driver _session_id end |
#last_state ⇒ Object
29 30 31 |
# File 'lib/crabfarm/rspec/navigator_spec_helpers.rb', line 29 def last_state @last_state end |
#navigate(_name = nil, _params = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/crabfarm/rspec/navigator_spec_helpers.rb', line 7 def navigate(_name=nil, _params={}) ensure_context_for :navigate if _name.is_a? Hash _params = _name _name = nil end Factories::Reducer.with_decorator spy_manager do if _name.nil? return nil unless described_class < BaseNavigator # TODO: maybe raise an error here. @navigator_state = @last_state = TransitionService.transition @navigator_context, described_class, _params else @last_state = TransitionService.transition @navigator_context, _name, (_params || {}) end end end |
#spy_reducer(_name_or_class) ⇒ Object
33 34 35 36 37 |
# File 'lib/crabfarm/rspec/navigator_spec_helpers.rb', line 33 def spy_reducer(_name_or_class) ensure_context_for :spy_reducer reducer_class = Utils::Resolve.reducer_class _name_or_class spy_manager.new_spy_for reducer_class end |
#state ⇒ Object
25 26 27 |
# File 'lib/crabfarm/rspec/navigator_spec_helpers.rb', line 25 def state @navigator_state || navigate(@navigator_params) end |