Sha256: 034365f92570400696e9d51818461e37df6216152181aae0e3a5f24620974c3a

Contents?: true

Size: 1.55 KB

Versions: 24

Compression:

Stored size: 1.55 KB

Contents

Feature: Step Definitions

  Everybody knows you can do step definitions in Cucumber
  but did you know you can do this?

  Scenario: Call a method in World directly from a step def
    Given a file named "features/step_definitions/steps.rb" with:
      """
      module Driver
        def do_action
          @done = true
        end

        def assert_done
          @done.should be_true
        end
      end
      World(Driver)

      When /I do the action/, :do_action
      Then /The action should be done/, :assert_done
      """
    And a file named "features/action.feature" with:
      """
      Feature:
        Scenario:
          When I do the action
          Then the action should be done
      """
    When I run `cucumber`
    Then it should pass

  Scenario: Call a method on an actor in the World directly from a step def
    Given a file named "features/step_definitions/steps.rb" with:
      """
      class Thing
        def do_action
          @done = true
        end

        def assert_done
          @done.should be_true
        end
      end

      module Driver
        def thing
          @thing ||= Thing.new
        end
      end
      World(Driver)

      When /I do the action to the thing/, :do_action, :on => lambda { thing }
      Then /The thing should be done/, :assert_done, :on => lambda { thing }
      """
    And a file named "features/action.feature" with:
      """
      Feature:
        Scenario:
          When I do the action to the thing
          Then the thing should be done
      """
    When I run `cucumber`
    Then it should pass

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
cucumber-1.3.20 features/step_definitions.feature
cucumber-1.3.19 features/step_definitions.feature
cucumber-1.3.18 features/step_definitions.feature
cucumber-1.3.17 features/step_definitions.feature
cucumber-1.3.16 features/step_definitions.feature
cucumber-1.3.15 features/step_definitions.feature
cucumber-1.3.14 features/step_definitions.feature
cucumber-1.3.13 features/step_definitions.feature
cucumber-1.3.12 features/step_definitions.feature
cucumber-1.3.11 features/step_definitions.feature
cucumber-1.3.10 features/step_definitions.feature
cucumber-1.3.9 features/step_definitions.feature
cucumber-1.3.8 features/step_definitions.feature
cucumber-1.3.7 features/step_definitions.feature
cucumber-1.3.6 features/step_definitions.feature
cucumber-1.3.5 features/step_definitions.feature
cucumber-1.3.4 features/step_definitions.feature
cucumber-1.3.3 features/step_definitions.feature
cucumber-1.3.2 features/step_definitions.feature
cucumber-1.3.1 features/step_definitions.feature