Sha256: 048f0759bf828fb48a1b054da3ac87d2ddc1a626713e7806f2499c430a60a20a

Contents?: true

Size: 1.79 KB

Versions: 25

Compression:

Stored size: 1.79 KB

Contents

  @spawn
  Feature: Hooks execute in defined order

  Background:
    Given a file named "features/step_definitions/steps.rb" with:
      """
      Given /^background step$/ do; $EventOrder.push(:background_step) end
      Given /^scenario step$/ do; $EventOrder.push(:scenario_step) end
      """
    And a file named "features/support/hooks.rb" with:
      """
      $EventOrder = []
      Around('@around') do |scenario,block|
        $EventOrder.push :around_begin
        block.call
        $EventOrder.push :around_end
      end
      Before('@before') do
        $EventOrder.push :before
      end
      After('@after') do |scenario|
        $EventOrder.push :after
      end
      at_exit {
        puts "Event order: #{$EventOrder.join(' ')}"
      }
      """
    And a file named "features/around_hook_covers_background.feature" with:
      """
      @around
      Feature: Around hooks cover background steps
        Background:
          Given background step
        Scenario:
          Given scenario step
      """
    And a file named "features/all_hook_order.feature" with:
      """
      @around
      @before
      @after
      Feature: All hooks execute in expected order
        Background:
          Given background step
        Scenario:
          Given scenario step
      """

  Scenario: Around hooks cover background steps
    When I run `cucumber -o /dev/null features/around_hook_covers_background.feature`
    Then the output should contain:
      """
      Event order: around_begin background_step scenario_step around_end
      """

  Scenario: All hooks execute in expected order
    When I run `cucumber -o /dev/null features/all_hook_order.feature`
    Then the output should contain:
      """
      Event order: around_begin before background_step scenario_step after around_end
      """

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
cucumber-2.99.0 features/docs/writing_support_code/hook_order.feature
mobiusloop-0.1.5 features/docs/writing_support_code/hook_order.feature
cucumber-3.0.0.pre.1 features/docs/writing_support_code/hook_order.feature
cucumber-2.4.0 features/docs/writing_support_code/hook_order.feature
mobiusloop-0.1.3 features/docs/writing_support_code/hook_order.feature
mobiusloop-0.1.2 features/docs/writing_support_code/hook_order.feature
cucumber-2.3.3 features/docs/writing_support_code/hook_order.feature
cucumber-2.3.2 features/docs/writing_support_code/hook_order.feature
cucumber-2.3.1 features/docs/writing_support_code/hook_order.feature
cucumber-2.3.0 features/docs/writing_support_code/hook_order.feature
cucumber-2.2.0 features/docs/writing_support_code/hook_order.feature
cucumber-2.1.0 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.2 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.1 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.0 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.0.rc.5 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.0.rc.4 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.0.rc.3 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.0.rc.2 features/docs/writing_support_code/hook_order.feature
cucumber-2.0.0.rc.1 features/docs/writing_support_code/hook_order.feature