hidroh / cucumber-api

API validator in BBD style with Cucumber
https://rubygems.org/gems/cucumber-api
Apache License 2.0
52 stars 56 forks source link

Grabbed values do not work with headers #23

Closed biggianteye closed 6 years ago

biggianteye commented 6 years ago

I am trying to grab a token returned from an authentication endpoint and use it as a header in subsequent requests but the grabbed field is showing as the field name in the header rather than the field value.

Here is a simplified example:

Scenario:
    # Log in and get an access token
    Given I send and accept JSON
    And I set JSON request body to:
        """
        { "email": "me@example.com", "password": "x" }
        """
    And I send a POST request to "http://api/auth/login"
    And I grab "$..access_token" as "token"

    # Try to do another request using the above token in the Authorization header
    Given I send and accept JSON
    And I add Headers:
        | Authorization | Foo {token} |
    And I send a GET request to "http://api/customer/addresses"
    ...

I would expect the Authorization header in the second request to contain the token value but it actually just contains Foo {token}.

How can I add a grabbed value as a header?