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 (also: #navigator)
Instance Method Details
#browser(_session_id = nil) ⇒ Object
56 57 58 |
# File 'lib/crabfarm/rspec.rb', line 56 def browser(_session_id=nil) @context.pool.browser(_session_id) end |
#last_state ⇒ Object
48 49 50 |
# File 'lib/crabfarm/rspec.rb', line 48 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}" unless File.exist? snapshot_path data = File.read snapshot_path reducer = described_class.new data, reducer.run reducer end |
#reducer ⇒ Object
52 53 54 |
# File 'lib/crabfarm/rspec.rb', line 52 def reducer @reducer ||= reduce end |
#state ⇒ Object Also known as:
42 43 44 |
# File 'lib/crabfarm/rspec.rb', line 42 def state @state ||= navigate end |