Sha256: a74e5a0cbdc9b5c0e9d4ae9a24883b56ea67f0a735fcaf43bb6a3bcb8d01195e

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

# Passing data values to a macro-step #

Macro-steps as defined in the _Basics_ section are pretty limited. 

Remember Joe and his calculator?...  
Suppose that Joe created a macro-step as follows:
```cucumber
    ...
    Given I define the step "When I [enter the number 8]" to mean:  
    """  
    When I type 8  
    And I click Enter 
    """
    ...
```

While being a perfectly valid macro, it is almost useless since it will always enter the same digit 8.

What Joe really needs is a macro-step that allows him to enter any number.  
His wish, in turn, implies that the previous macro-step should accept one parameter value: the number to enter.

Here is how Joe might proceed:
```cucumber
    ...
    Given I define the step "When I [enter the number <some_number>]" to mean:  
    """
    When I type <some_number>  
    And I click Enter 
    """
    ...
```

And here is how he can use the last macro to enter the value 2:

```cucumber
    ...
    When I [enter the number "2"] 
    ...
```

## Rules of the game ##
When a macro-step is required to take one or more values, then:

1. Place in the step being defined the name of an argument between chevrons < ... >.
2. When the macro is used in a scenario, place the value of the corresponding argument between double quotes "...".


Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
macros4cuke-0.5.18 features/2_macros_with_arguments/README.md
macros4cuke-0.5.17 features/2_macros_with_arguments/README.md
macros4cuke-0.5.16 features/2_macros_with_arguments/README.md
macros4cuke-0.5.15 features/2_macros_with_arguments/README.md
macros4cuke-0.5.14 features/2_macros_with_arguments/README.md
macros4cuke-0.5.13 features/2_macros_with_arguments/README.md
macros4cuke-0.5.12 features/2_macros_with_arguments/README.md
macros4cuke-0.5.11 features/2_macros_with_arguments/README.md
macros4cuke-0.5.10 features/2_macros_with_arguments/README.md
macros4cuke-0.5.09 features/2_macros_with_arguments/README.md
macros4cuke-0.5.08 features/2_macros_with_arguments/README.md
macros4cuke-0.5.07 features/2_macros_with_arguments/README.md
macros4cuke-0.5.06 features/2_macros_with_arguments/README.md
macros4cuke-0.5.03 features/2_macros_with_arguments/README.md
macros4cuke-0.4.09 features/2_macros_with_arguments/README.md
macros4cuke-0.4.08 features/2_Macros_with_arguments/README.md