Class: Lopata::Scenario

Inherits:
Object
  • Object
show all
Includes:
ActiveRecord::Methods, FactoryBot::Methods, Role::Methods, RSpec::Matchers
Defined in:
lib/lopata/scenario.rb

Overview

Scenario runtime class.

All the scenarios are running in context of separate Lopata::Scenario object.

Instance Method Summary collapse

Methods included from Role::Methods

#current_role

Methods included from ActiveRecord::Methods

#cleanup, #cleanup_later, #find_created, #reload

Methods included from FactoryBot::Methods

#create

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



47
48
49
50
51
52
53
54
55
56
# File 'lib/lopata/scenario.rb', line 47

def method_missing(method, *args, &block)

  if (let_method = execution.find_let_method(method))
    let_method.call_in_scenario(self, *args)
  elsif .keys.include?(method)
    [method]
  else
    super
  end
end

Instance Method Details

#inspectObject Also known as: to_s

Provide a human-readable representation of this class



19
20
21
# File 'lib/lopata/scenario.rb', line 19

def inspect
  "#<#{self.class.name} #{execution.title.inspect}>"
end

#metadataHash

Note:

The metadata keys also availalbe as methods (via method_missing)

Returns metadata available for current step.

Returns:

  • (Hash)

    metadata available for current step



40
41
42
# File 'lib/lopata/scenario.rb', line 40

def 
  execution.
end

#pending(message = nil) ⇒ Object

Marks current step as pending Pending steps wont be failed

Examples:

it 'pending step' do
  pending
  expect(1).to eq 2
end


34
35
36
# File 'lib/lopata/scenario.rb', line 34

def pending(message = nil)
  execution.current_step.pending!(message)
end