Skip to content

Tests for current behavior, related to #84. #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2015-08-15 16:01:39 -0400 using RuboCop version 0.33.0.
# on 2015-08-15 17:01:12 -0400 using RuboCop version 0.33.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -11,7 +11,7 @@
Metrics/ClassLength:
Max: 103

# Offense count: 80
# Offense count: 85
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 142
Expand All @@ -24,7 +24,7 @@ Metrics/MethodLength:
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 238
Max: 258

# Offense count: 1
Style/AsciiComments:
Expand Down
27 changes: 27 additions & 0 deletions test/hyperclient/link_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ module Hyperclient
link._expand._url.must_equal '/orders'
link._url.must_equal '/orders'
end

it 'does not expand unknown variables' do
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
link._expand(unknown: '1')._url.must_equal '/orders'
end

it 'only expands known variables' do
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
link._expand(unknown: '1', id: '2')._url.must_equal '/orders?id=2'
end

it 'only expands templated links' do
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => false }, entry_point)
link._expand(id: '1')._url.must_equal '/orders{?id}'
end
end
end

Expand All @@ -91,6 +106,18 @@ module Hyperclient
link._url.must_equal '/orders?id=1'
end

it 'does not expand an uri template with unknown variables' do
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1)

link._url.must_equal '/orders'
end

it 'only expands known variables in a uri template' do
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1, id: 2)

link._url.must_equal '/orders?id=2'
end

it 'returns the link when no uri template' do
link = Link.new('key', { 'href' => '/orders' }, entry_point)
link._url.must_equal '/orders'
Expand Down