Module: Crabfarm::RSpec

Defined in:
lib/crabfarm/rspec.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#crawl(_state = nil, _params = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/crabfarm/rspec.rb', line 16

def crawl(_state=nil, _params={})

  raise Error.new "Crawl is only available in state specs" if @context.nil?

  if _state.is_a? Hash
    _params = _state
    _state = nil
  end

  if _state.nil?
    return nil unless described_class < BaseState # TODO: maybe raise an error here.
    @state = @last_state = TransitionService.apply_state @context, described_class, _params
  else
    @last_state = TransitionService.apply_state @context, _state, _params
  end
end

#driver(_session_id = nil) ⇒ Object



45
46
47
# File 'lib/crabfarm/rspec.rb', line 45

def driver(_session_id=nil)
  @context.pool.driver(_session_id)
end

#last_stateObject



37
38
39
# File 'lib/crabfarm/rspec.rb', line 37

def last_state
  @last_state
end

#parse(_snapshot, _options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/crabfarm/rspec.rb', line 6

def parse(_snapshot, _options={})
  snapshot_path = GlobalState.snapshot_path _snapshot
  raise Error.new "Snapshot does not exist #{_snapshot}" unless File.exist? snapshot_path

  html = File.read snapshot_path
  parser = described_class.new html, _options
  parser.parse
  parser
end

#parserObject



41
42
43
# File 'lib/crabfarm/rspec.rb', line 41

def parser
  @parser
end

#stateObject



33
34
35
# File 'lib/crabfarm/rspec.rb', line 33

def state
  @state ||= crawl
end