Skip to content

Commit 6febe87

Browse files
author
Ivo Anjo
committed
Add test scenario for dropped values for same parameter
1 parent 557585a commit 6febe87

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

features/api_navigation.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Feature: API navigation
1212
When I search for a post with a templated link
1313
Then the API should receive the request with all the params
1414

15+
Scenario: Templated links with multiple values
16+
Given I connect to the API
17+
When I search for posts by tag with a templated link
18+
Then the API should receive the request for posts by tag with all the params
19+
1520
Scenario: Attributes
1621
Given I connect to the API
1722
When I load a single post

features/steps/api_navigation.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class Spinach::Features::ApiNavigation < Spinach::FeatureSteps
1717
assert_requested :get, 'http://api.example.org/search?q=something'
1818
end
1919

20+
step 'I search for posts by tag with a templated link' do
21+
api._links.tagged._expand(tags: %w(foo bar))._resource
22+
end
23+
24+
step 'the API should receive the request for posts by tag with all the params' do
25+
assert_requested :get, 'http://api.example.org/search?tags=foo&tags=bar'
26+
end
27+
2028
step 'I load a single post' do
2129
@post = api._links.posts._links.last_post
2230
end

features/support/api.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module API
55
include Spinach::Fixtures
66

77
before do
8+
WebMock::Config.instance.query_values_notation = :flat_array
9+
810
stub_request(:any, %r{api.example.org*}).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
911
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: { 'Content-Type' => 'application/hal+json' })
1012
stub_request(:get, 'api.example.org/posts/1').to_return(body: post_response, headers: { 'Content-Type' => 'application/hal+json' })

features/support/fixtures.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def root_response
88
"self": { "href": "/" },
99
"posts": { "href": "/posts" },
1010
"search": { "href": "/search{?q}", "templated": true },
11+
"tagged": { "href": "/search{?tags*}", "templated": true },
1112
"api:authors": { "href": "/authors" },
1213
"next": { "href": "/page2" }
1314
}

0 commit comments

Comments
 (0)