@@ -75,6 +75,16 @@ 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
78
88
end
79
89
end
80
90
@@ -91,6 +101,18 @@ module Hyperclient
91
101
link . _url . must_equal '/orders?id=1'
92
102
end
93
103
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
+
94
116
it 'returns the link when no uri template' do
95
117
link = Link . new ( 'key' , { 'href' => '/orders' } , entry_point )
96
118
link . _url . must_equal '/orders'
0 commit comments