Module: Kernel

Defined in:
lib/gauge.rb

Instance Method Summary collapse

Instance Method Details

#after_scenario(options, &block) ⇒ Object

Invoked after execution of every scenario.

Examples:

after_scenario({tags: ['tag2', 'tag1'], operator: 'OR'}) do
   puts "I am the after_scenario hook"
end

Parameters:

  • block (block) —

    this block is called while executing the after_scenario hook

  • options ({tags: ['list', 'of', 'tags'], operator: 'OR' | 'AND'}) —

    specify tags and operator for which this after_scenario execution hook should run.



114
# File 'lib/gauge.rb', line 114

tagged_hook "after_scenario"

#after_spec(options, &block) ⇒ Object

Invoked after execution of every specification.

Examples:

after_spec({tags: ['tag2', 'tag1'], operator: 'OR'}) do
   puts "I am the after_spec hook"
end

Parameters:

  • block (block) —

    this block is called while executing the after_spec hook

  • options ({tags: ['list', 'of', 'tags'], operator: 'OR' | 'AND'}) —

    specify tags and operator for which this after_spec execution hook should run.



110
# File 'lib/gauge.rb', line 110

tagged_hook "after_spec"

#after_step(options, &block) ⇒ Object

Invoked after execution of every step.

Examples:

after_step({tags: ['tag2', 'tag1'], operator: 'OR'}) do
   puts "I am the after_step hook"
end

Parameters:

  • block (block) —

    this block is called while executing the after_step hook

  • options ({tags: ['list', 'of', 'tags'], operator: 'OR' | 'AND'}) —

    specify tags and operator for which this after_step execution hook should run.



106
# File 'lib/gauge.rb', line 106

tagged_hook "after_step"

#after_suite(&block) ⇒ Object

Invoked after execution of the entire suite.

Examples:

after_suite do
   puts "I am the after_suite hook"
end

Parameters:

  • block (block) —

    this block is called while executing the after_suite hook



118
# File 'lib/gauge.rb', line 118

hook "after_suite"

#before_scenario(options, &block) ⇒ Object

Invoked before execution of every scenario.

Examples:

before_scenario({tags: ['tag2', 'tag1'], operator: 'OR'}) do
   puts "I am the before_scenario hook"
end

Parameters:

  • block (block) —

    this block is called while executing the before_scenario hook

  • options ({tags: ['list', 'of', 'tags'], operator: 'OR' | 'AND'}) —

    specify tags and operator for which this before_scenario execution hook should run.



112
# File 'lib/gauge.rb', line 112

tagged_hook "before_scenario"

#before_spec(options, &block) ⇒ Object

Invoked before execution of every specification.

Examples:

before_spec({tags: ['tag2', 'tag1'], operator: 'OR'}) do
   puts "I am the before_spec hook"
end

Parameters:

  • block (block) —

    this block is called while executing the before_spec hook

  • options ({tags: ['list', 'of', 'tags'], operator: 'OR' | 'AND'}) —

    specify tags and operator for which this before_spec execution hook should run.



108
# File 'lib/gauge.rb', line 108

tagged_hook "before_spec"

#before_step(options, &block) ⇒ Object

Invoked before execution of every step.

Examples:

before_step({tags: ['tag2', 'tag1'], operator: 'OR'}) do
   puts "I am the before_step hook"
end

Parameters:

  • block (block) —

    this block is called while executing the before_step hook

  • options ({tags: ['list', 'of', 'tags'], operator: 'OR' | 'AND'}) —

    specify tags and operator for which this before_step execution hook should run.



104
# File 'lib/gauge.rb', line 104

tagged_hook "before_step"

#before_suite(&block) ⇒ Object

Invoked before execution of the entire suite.

Examples:

before_suite do
   puts "I am the before_suite hook"
end

Parameters:

  • block (block) —

    this block is called while executing the before_suite hook



116
# File 'lib/gauge.rb', line 116

hook "before_suite"

#step(*step_texts, &block) ⇒ Object

Specify implementation for a given step

Examples:

step 'this is a simple step' do
  puts 'hello there!'
end
# step with parameters
# * say "hello" to "gauge"
step 'say <what> to <who>' do |what, who|
  puts "say #{what} to #{who}"
end
# step with aliases, two step texts can map to the same definition
# provided they have the same parameter signature
# * say "hello" to "gauge"
# * When you meet "gauge", say "hello"

step 'say <what> to <who>', 'When you meet <who>, say <what>' do |what, who|
  puts "say #{what} to #{who}"
end
# step with table
# * Step that takes a table
#        |Product|       Description           |
#        |-------|-----------------------------|
#        |Gauge  |BDD style testing with ease  |
#        |Mingle |Agile project management     |
#        |Snap   |Hosted continuous integration|
#        |Gocd   |Continuous delivery platform |

step 'Step that takes a table <table>' do |table|
  # note the extra <table> that is added to the description
    puts x.columns.join("|")
    x.rows.each { |r| puts r.join("|") }
end

Parameters:

  • step_texts (string, ...) —

    the step text(s)

  • block (block) —

    the implementation block for given step.



94
95
96
97
98
99
100
101
# File 'lib/gauge.rb', line 94

def step(*step_texts, &block)
  step_texts.each do |text|
    parameterized_step_text = Gauge::Connector.step_value(text)
    Gauge::MethodCache.add_step(parameterized_step_text, &block)
    Gauge::MethodCache.add_step_text(parameterized_step_text, text)
  end
  Gauge::MethodCache.add_step_alias(*step_texts)
end