Module: Kernel

Defined in:
lib/gauge.rb

Instance Method Summary collapse

Instance Method Details

#after_scenario(&block) ⇒ Object

Invoked after execution of every scenario.

Examples:

after_scenario do
   puts "I am the after_scenario hook"
end

Parameters:

  • block (block)

    , this block is called while executing the after_scenario hook



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

hook "after_scenario"

#after_spec(&block) ⇒ Object

Invoked after execution of every specification.

Examples:

after_spec do
   puts "I am the after_spec hook"
end

Parameters:

  • block (block)

    , this block is called while executing the after_spec hook



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

hook "after_spec"

#after_step(&block) ⇒ Object

Invoked after execution of every step.

Examples:

after_step do
   puts "I am the after_step hook"
end

Parameters:

  • block (block)

    , this block is called while executing the after_step hook



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

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



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

hook "after_suite"

#before_scenario(&block) ⇒ Object

Invoked before execution of every scenario.

Examples:

before_scenario do
   puts "I am the before_scenario hook"
end

Parameters:

  • block (block)

    , this block is called while executing the before_scenario hook



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

hook "before_scenario"

#before_spec(&block) ⇒ Object

Invoked before execution of every specification.

Examples:

before_spec do
   puts "I am the before_spec hook"
end

Parameters:

  • block (block)

    , this block is called while executing the before_spec hook



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

hook "before_spec"

#before_step(&block) ⇒ Object

Invoked before execution of every step.

Examples:

before_step do
   puts "I am the before_step hook"
end

Parameters:

  • block (block)

    , this block is called while executing the before_step hook



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

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



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

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.



80
81
82
83
84
85
86
87
# File 'lib/gauge.rb', line 80

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