Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test scenario for dropped values for same parameter
  • Loading branch information
Ivo Anjo committed Feb 17, 2017
commit 6febe87589836909ff6a5de2423d00f11f049d57
5 changes: 5 additions & 0 deletions features/api_navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Feature: API navigation
When I search for a post with a templated link
Then the API should receive the request with all the params

Scenario: Templated links with multiple values
Given I connect to the API
When I search for posts by tag with a templated link
Then the API should receive the request for posts by tag with all the params

Scenario: Attributes
Given I connect to the API
When I load a single post
Expand Down
8 changes: 8 additions & 0 deletions features/steps/api_navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class Spinach::Features::ApiNavigation < Spinach::FeatureSteps
assert_requested :get, 'http://api.example.org/search?q=something'
end

step 'I search for posts by tag with a templated link' do
api._links.tagged._expand(tags: %w(foo bar))._resource
end

step 'the API should receive the request for posts by tag with all the params' do
assert_requested :get, 'http://api.example.org/search?tags=foo&tags=bar'
end

step 'I load a single post' do
@post = api._links.posts._links.last_post
end
Expand Down
2 changes: 2 additions & 0 deletions features/support/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module API
include Spinach::Fixtures

before do
WebMock::Config.instance.query_values_notation = :flat_array

stub_request(:any, %r{api.example.org*}).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/1').to_return(body: post_response, headers: { 'Content-Type' => 'application/hal+json' })
Expand Down
1 change: 1 addition & 0 deletions features/support/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def root_response
"self": { "href": "/" },
"posts": { "href": "/posts" },
"search": { "href": "/search{?q}", "templated": true },
"tagged": { "href": "/search{?tags*}", "templated": true },
"api:authors": { "href": "/authors" },
"next": { "href": "/page2" }
}
Expand Down