Module: Crabfarm::RSpec

Defined in:
lib/crabfarm/rspec.rb

Instance Method Summary collapse

Instance Method Details

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



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/crabfarm/rspec.rb', line 21

def crawl(_state=nil, _params={})
  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 = CF_TEST_CONTEXT.run_state(described_class, _params)
  else
    @last_state = CF_TEST_CONTEXT.run_state(_state, _params)
  end
end

#last_stateObject



39
40
41
# File 'lib/crabfarm/rspec.rb', line 39

def last_state
  @last_state
end

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



10
11
12
13
14
15
16
17
18
19
# File 'lib/crabfarm/rspec.rb', line 10

def parse(_snap_or_url, _options={})
  fixture = Pathname.new(File.join(ENV['SNAPSHOT_DIR'], _snap_or_url))
  if fixture.exist?
    CF_TEST_BUCKET.get("file://#{fixture.realpath}")
  else
    CF_TEST_BUCKET.get(_snap_or_url)
  end

  CF_TEST_BUCKET.parse(described_class, _options)
end

#parserObject



43
44
45
# File 'lib/crabfarm/rspec.rb', line 43

def parser
  @parser
end

#stateObject



35
36
37
# File 'lib/crabfarm/rspec.rb', line 35

def state
  @state ||= crawl
end