Skip to content

Commit fbe7ba7

Browse files
committed
Tests for current behavior, related to #84.
1 parent 18a6b6f commit fbe7ba7

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

.rubocop_todo.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2015-08-15 16:01:39 -0400 using RuboCop version 0.33.0.
3+
# on 2015-08-15 16:22:00 -0400 using RuboCop version 0.33.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -11,7 +11,7 @@
1111
Metrics/ClassLength:
1212
Max: 103
1313

14-
# Offense count: 80
14+
# Offense count: 82
1515
# Configuration parameters: AllowURI, URISchemes.
1616
Metrics/LineLength:
1717
Max: 142
@@ -24,7 +24,7 @@ Metrics/MethodLength:
2424
# Offense count: 3
2525
# Configuration parameters: CountComments.
2626
Metrics/ModuleLength:
27-
Max: 238
27+
Max: 246
2828

2929
# Offense count: 1
3030
Style/AsciiComments:

test/hyperclient/link_test.rb

+22
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ module Hyperclient
7575
link._expand._url.must_equal '/orders'
7676
link._url.must_equal '/orders'
7777
end
78+
79+
it 'does not expand unknown variables' do
80+
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
81+
link._expand(unknown: '1')._url.must_equal '/orders'
82+
end
83+
84+
it 'only expands known variables' do
85+
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point)
86+
link._expand(unknown: '1', id: '2')._url.must_equal '/orders?id=2'
87+
end
7888
end
7989
end
8090

@@ -91,6 +101,18 @@ module Hyperclient
91101
link._url.must_equal '/orders?id=1'
92102
end
93103

104+
it 'does not expand an uri template with unknown variables' do
105+
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1)
106+
107+
link._url.must_equal '/orders'
108+
end
109+
110+
it 'only expands known variables in a uri template' do
111+
link = Link.new('key', { 'href' => '/orders{?id}', 'templated' => true }, entry_point, unknown: 1, id: 2)
112+
113+
link._url.must_equal '/orders?id=2'
114+
end
115+
94116
it 'returns the link when no uri template' do
95117
link = Link.new('key', { 'href' => '/orders' }, entry_point)
96118
link._url.must_equal '/orders'

0 commit comments

Comments
 (0)