@@ -75,6 +75,21 @@ module Hyperclient
75
75
link . _expand . _url . must_equal '/orders'
76
76
link . _url . must_equal '/orders'
77
77
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
88
+
89
+ it 'only expands templated links' do
90
+ link = Link . new ( 'key' , { 'href' => '/orders{?id}' , 'templated' => false } , entry_point )
91
+ link . _expand ( id : '1' ) . _url . must_equal '/orders{?id}'
92
+ end
78
93
end
79
94
end
80
95
@@ -91,6 +106,18 @@ module Hyperclient
91
106
link . _url . must_equal '/orders?id=1'
92
107
end
93
108
109
+ it 'does not expand an uri template with unknown variables' do
110
+ link = Link . new ( 'key' , { 'href' => '/orders{?id}' , 'templated' => true } , entry_point , unknown : 1 )
111
+
112
+ link . _url . must_equal '/orders'
113
+ end
114
+
115
+ it 'only expands known variables in a uri template' do
116
+ link = Link . new ( 'key' , { 'href' => '/orders{?id}' , 'templated' => true } , entry_point , unknown : 1 , id : 2 )
117
+
118
+ link . _url . must_equal '/orders?id=2'
119
+ end
120
+
94
121
it 'returns the link when no uri template' do
95
122
link = Link . new ( 'key' , { 'href' => '/orders' } , entry_point )
96
123
link . _url . must_equal '/orders'
0 commit comments