Module: Crabfarm::RSpec
- Defined in:
- lib/crabfarm/rspec.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #browser(_session_id = nil) ⇒ Object
- #last_state ⇒ Object
- #navigate(_name = nil, _params = {}) ⇒ Object
- #reduce(_snapshot = nil, _options = {}) ⇒ Object
- #reducer ⇒ Object
- #state ⇒ Object
Instance Method Details
#browser(_session_id = nil) ⇒ Object
54 55 56 |
# File 'lib/crabfarm/rspec.rb', line 54 def browser(_session_id=nil) @context.pool.driver(_session_id) end |
#last_state ⇒ Object
46 47 48 |
# File 'lib/crabfarm/rspec.rb', line 46 def last_state @last_state end |
#navigate(_name = nil, _params = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/crabfarm/rspec.rb', line 25 def navigate(_name=nil, _params={}) raise Error.new "'navigate' is only available in navigator specs" if @context.nil? if _name.is_a? Hash _params = _name _name = nil end if _name.nil? return nil unless described_class < BaseNavigator # TODO: maybe raise an error here. @state = @last_state = TransitionService.transition @context, described_class, _params else @last_state = TransitionService.transition @context, _name, _params end end |
#reduce(_snapshot = nil, _options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/crabfarm/rspec.rb', line 6 def reduce(_snapshot=nil, ={}) raise Error.new "'reduce' is only available in reducer specs" unless described_class < Crabfarm::BaseReducer if _snapshot.is_a? Hash raise ArgumentException.new 'Invalid arguments' unless .nil? = _snapshot _snapshot = nil end snapshot_path = described_class.snapshot_path _snapshot raise Error.new "Snapshot does not exist #{snapshot_path}" unless File.exist? snapshot_path data = File.read snapshot_path reducer = described_class.new data, reducer.run reducer end |
#reducer ⇒ Object
50 51 52 |
# File 'lib/crabfarm/rspec.rb', line 50 def reducer @reducer ||= reduce end |
#state ⇒ Object
42 43 44 |
# File 'lib/crabfarm/rspec.rb', line 42 def state @state ||= navigate end |