Module: Lopata

Defined in:
lib/lopata.rb,
lib/lopata/id.rb,
lib/lopata/role.rb,
lib/lopata/step.rb,
lib/lopata/runner.rb,
lib/lopata/version.rb,
lib/lopata/condition.rb,
lib/lopata/environment.rb,
lib/lopata/factory_bot.rb,
lib/lopata/shared_step.rb,
lib/lopata/active_record.rb,
lib/lopata/configuration.rb,
lib/lopata/generators/app.rb,
lib/lopata/observers/web_logger.rb,
lib/lopata/observers/base_observer.rb,
lib/lopata/observers/backtrace_formatter.rb,
lib/lopata/observers/console_output_observer.rb

Overview

Namespace for all Lopata code.

Defined Under Namespace

Modules: ActiveRecord, FactoryBot, Role Classes: Configuration, Environment, Scenario, ScenarioBuilder, World

Class Method Summary collapse

Class Method Details

.configurationLopata::Configuration

Returns global configuration object.

Returns:

See Also:



107
108
109
# File 'lib/lopata.rb', line 107

def self.configuration
  @configuration ||= Lopata::Configuration.new
end

.configure {|Lopata::Configuration| ... } ⇒ Object

Yields the global configuration to a block.

Examples:

Lopata.configure do |config|
  config.before_scenario 'setup test user'
end

Yields:

See Also:



100
101
102
# File 'lib/lopata.rb', line 100

def self.configure(&block)
  yield Lopata.configuration
end

.define(*args, &block) ⇒ Object

Define the scenario.



13
14
15
# File 'lib/lopata.rb', line 13

def self.define(*args, &block)
  Lopata::ScenarioBuilder.define(*args, &block)
end

.environmentLopata::Environment

Return global environment object

Returns:

See Also:



120
121
122
# File 'lib/lopata.rb', line 120

def self.environment
  Lopata.configuration.environment
end

.shared_context(name, &block) ⇒ Object

Register the shared step for context.

shared_context is a shortcat for shared_step(‘name’) { context(‘name’) { .. } }. The block will be arrounded into the context call.

Shared context may be used in scenarios by name:

Examples:

Lopata.shared_context 'calculation' do
  it('correct') { expect(1 + 1).to eq 2 }
  it('incorrect') { expect(1 + 2).to eq 4 }
end
Lopata.define 'verify calcuation in context' do
  verify 'calculation'
end

Parameters:

  • name (String)

    shared step unique name, will be used as a context’s name

  • block (Block)

    shared context definition



86
87
88
89
90
# File 'lib/lopata.rb', line 86

def self.shared_context(name, &block)
  Lopata::SharedStep.register(name) do
    context(name, &block)
  end
end

.shared_setup(name, &block) ⇒ Object

Register the shared step for setup.

shared_setup is a shortcat for shared_step ‘name’ { setup { .. } }. The block will be arrounded into the setup call.

Shared step may be used in scenarios by name:

Examples:

Lopata.shared_setup 'test user' do
  @user = create(:user)
end
Lopata.define 'user' do
  setup 'test user'

  it 'exists' do
    expect(@user).to_not be_nil
  end
end

Parameters:

  • name (String)

    shared step unique name

  • block (Block)

    shared setup definition



63
64
65
66
67
# File 'lib/lopata.rb', line 63

def self.shared_setup(name, &block)
  Lopata::SharedStep.register(name) do
    setup(&block)
  end
end

.shared_step(name, &block) ⇒ Object

Register the shared step

Shared step may be used in scenarios by name:

Examples:

Lopata.shared_step 'test user' do
  setup { @user = create(:user) }
end
Lopata.define 'user' do
  setup 'test user'

  it 'exists' do
    expect(@user).to_not be_nil
  end
end

Parameters:

  • name (String)

    shared step unique name

  • block (Block)

    shared step action sequence definition



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

def self.shared_step(name, &block)
  Lopata::SharedStep.register(name, &block)
end

.xdefine(*args, &block) ⇒ Object

Skip scenario definition. Option to temporary ignore scenario



18
19
# File 'lib/lopata.rb', line 18

def self.xdefine(*args, &block)
end