Skip to content

Commit

Permalink
Tests for current behavior, related to codegram#84.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Aug 15, 2015
1 parent 18a6b6f commit dc8d988
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
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 16:59:19 -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: 84
# 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: 254

# Offense count: 1
Style/AsciiComments:
Expand Down
22 changes: 22 additions & 0 deletions test/hyperclient/link_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ 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
end
end

Expand All @@ -91,6 +101,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

0 comments on commit dc8d988

Please sign in to comment.