htty 1.5.4 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +12 -9
- data/.rspec +2 -1
- data/.travis.yml +11 -8
- data/.yardopts +1 -1
- data/Gemfile +22 -10
- data/Guardfile +31 -13
- data/History.markdown +6 -0
- data/README.markdown +29 -13
- data/Rakefile +2 -64
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/exe/htty +5 -0
- data/htty.gemspec +27 -29
- data/lib/htty.rb +29 -4
- data/lib/htty/cli.rb +9 -16
- data/lib/htty/cli/body_open_command.rb +2 -7
- data/lib/htty/cli/command.rb +10 -18
- data/lib/htty/cli/commands.rb +76 -11
- data/lib/htty/cli/commands/address.rb +1 -14
- data/lib/htty/cli/commands/body_clear.rb +1 -8
- data/lib/htty/cli/commands/body_edit.rb +1 -11
- data/lib/htty/cli/commands/body_request.rb +1 -12
- data/lib/htty/cli/commands/body_request_open.rb +1 -10
- data/lib/htty/cli/commands/body_response.rb +1 -12
- data/lib/htty/cli/commands/body_response_open.rb +1 -11
- data/lib/htty/cli/commands/body_set.rb +1 -10
- data/lib/htty/cli/commands/body_unset.rb +1 -9
- data/lib/htty/cli/commands/cd.rb +1 -8
- data/lib/htty/cli/commands/cookie_add.rb +1 -8
- data/lib/htty/cli/commands/cookie_remove.rb +1 -8
- data/lib/htty/cli/commands/cookies.rb +1 -15
- data/lib/htty/cli/commands/cookies_add.rb +1 -11
- data/lib/htty/cli/commands/cookies_clear.rb +1 -8
- data/lib/htty/cli/commands/cookies_remove.rb +1 -11
- data/lib/htty/cli/commands/cookies_remove_all.rb +1 -11
- data/lib/htty/cli/commands/cookies_use.rb +1 -14
- data/lib/htty/cli/commands/delete.rb +1 -8
- data/lib/htty/cli/commands/exit.rb +1 -8
- data/lib/htty/cli/commands/follow.rb +1 -10
- data/lib/htty/cli/commands/form.rb +1 -7
- data/lib/htty/cli/commands/form_add.rb +1 -7
- data/lib/htty/cli/commands/form_clear.rb +1 -8
- data/lib/htty/cli/commands/form_remove.rb +1 -7
- data/lib/htty/cli/commands/form_remove_all.rb +1 -7
- data/lib/htty/cli/commands/fragment_clear.rb +1 -8
- data/lib/htty/cli/commands/fragment_set.rb +1 -10
- data/lib/htty/cli/commands/fragment_unset.rb +1 -9
- data/lib/htty/cli/commands/get.rb +1 -8
- data/lib/htty/cli/commands/header_set.rb +1 -8
- data/lib/htty/cli/commands/header_unset.rb +1 -8
- data/lib/htty/cli/commands/headers_clear.rb +1 -8
- data/lib/htty/cli/commands/headers_request.rb +1 -15
- data/lib/htty/cli/commands/headers_response.rb +1 -15
- data/lib/htty/cli/commands/headers_set.rb +1 -10
- data/lib/htty/cli/commands/headers_unset.rb +1 -10
- data/lib/htty/cli/commands/headers_unset_all.rb +1 -10
- data/lib/htty/cli/commands/help.rb +4 -12
- data/lib/htty/cli/commands/history.rb +1 -10
- data/lib/htty/cli/commands/history_verbose.rb +1 -12
- data/lib/htty/cli/commands/host_set.rb +1 -8
- data/lib/htty/cli/commands/http_delete.rb +1 -12
- data/lib/htty/cli/commands/http_get.rb +1 -13
- data/lib/htty/cli/commands/http_head.rb +1 -9
- data/lib/htty/cli/commands/http_options.rb +1 -9
- data/lib/htty/cli/commands/http_patch.rb +1 -13
- data/lib/htty/cli/commands/http_post.rb +1 -13
- data/lib/htty/cli/commands/http_put.rb +1 -12
- data/lib/htty/cli/commands/http_trace.rb +1 -9
- data/lib/htty/cli/commands/patch.rb +1 -8
- data/lib/htty/cli/commands/path_set.rb +11 -11
- data/lib/htty/cli/commands/port_set.rb +1 -9
- data/lib/htty/cli/commands/post.rb +1 -8
- data/lib/htty/cli/commands/put.rb +1 -8
- data/lib/htty/cli/commands/query_add.rb +1 -13
- data/lib/htty/cli/commands/query_clear.rb +1 -8
- data/lib/htty/cli/commands/query_remove.rb +1 -13
- data/lib/htty/cli/commands/query_set.rb +1 -13
- data/lib/htty/cli/commands/query_unset.rb +1 -13
- data/lib/htty/cli/commands/query_unset_all.rb +1 -10
- data/lib/htty/cli/commands/quit.rb +1 -7
- data/lib/htty/cli/commands/reuse.rb +5 -12
- data/lib/htty/cli/commands/scheme_set.rb +1 -9
- data/lib/htty/cli/commands/ssl_verification.rb +1 -11
- data/lib/htty/cli/commands/ssl_verification_off.rb +1 -10
- data/lib/htty/cli/commands/ssl_verification_on.rb +1 -10
- data/lib/htty/cli/commands/status.rb +1 -11
- data/lib/htty/cli/commands/undo.rb +1 -7
- data/lib/htty/cli/commands/userinfo_clear.rb +1 -8
- data/lib/htty/cli/commands/userinfo_set.rb +1 -11
- data/lib/htty/cli/commands/userinfo_unset.rb +1 -9
- data/lib/htty/cli/display.rb +4 -6
- data/lib/htty/cli/http_method_command.rb +1 -10
- data/lib/htty/cli/input_device.rb +1 -0
- data/lib/htty/cli/url_escaping.rb +1 -6
- data/lib/htty/cookies_util.rb +3 -3
- data/lib/htty/headers.rb +3 -4
- data/lib/htty/http_patch.rb +20 -23
- data/lib/htty/no_header_error.rb +1 -1
- data/lib/htty/no_location_header_error.rb +1 -3
- data/lib/htty/no_response_error.rb +1 -1
- data/lib/htty/no_set_cookie_header_error.rb +1 -3
- data/lib/htty/payload.rb +1 -5
- data/lib/htty/platform.rb +1 -1
- data/lib/htty/preferences.rb +1 -1
- data/lib/htty/request.rb +3 -13
- data/lib/htty/requests_util.rb +1 -5
- data/lib/htty/response.rb +1 -4
- data/lib/htty/session.rb +1 -3
- data/lib/htty/tempfile_preserving_extname.rb +1 -2
- data/lib/htty/uri.rb +1 -2
- data/lib/htty/version.rb +1 -1
- data/lib/tasks.rb +3 -0
- data/lib/tasks/build_doc.rake +8 -0
- data/lib/tasks/lib_each.rake +25 -0
- data/lib/tasks/spec.rake +68 -0
- data/lib/tasks/spec_each.rake +19 -0
- metadata +48 -209
- data/bin/htty +0 -5
- data/spec/integration/htty/cli/commands/query_add_spec.rb +0 -57
- data/spec/integration/htty/cli/commands/query_remove_spec.rb +0 -55
- data/spec/integration/htty/cli/commands/query_set_spec.rb +0 -78
- data/spec/integration/htty/cli/commands/query_unset_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -76
- data/spec/unit/htty/cli/commands/address_spec.rb +0 -103
- data/spec/unit/htty/cli/commands/body_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/body_edit_spec.rb +0 -18
- data/spec/unit/htty/cli/commands/body_request_spec.rb +0 -67
- data/spec/unit/htty/cli/commands/body_response_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/body_set_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/body_unset_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/cd_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/cookie_add_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/cookies_add_spec.rb +0 -78
- data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/cookies_spec.rb +0 -76
- data/spec/unit/htty/cli/commands/cookies_use_spec.rb +0 -75
- data/spec/unit/htty/cli/commands/delete_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/exit_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/follow_spec.rb +0 -70
- data/spec/unit/htty/cli/commands/form_add_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/form_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +0 -66
- data/spec/unit/htty/cli/commands/form_remove_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/form_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/fragment_set_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/get_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/header_set_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/header_unset_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/headers_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/headers_request_spec.rb +0 -81
- data/spec/unit/htty/cli/commands/headers_response_spec.rb +0 -77
- data/spec/unit/htty/cli/commands/headers_set_spec.rb +0 -74
- data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/headers_unset_spec.rb +0 -63
- data/spec/unit/htty/cli/commands/help_spec.rb +0 -67
- data/spec/unit/htty/cli/commands/history_spec.rb +0 -65
- data/spec/unit/htty/cli/commands/history_verbose_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/host_set_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/http_delete_spec.rb +0 -75
- data/spec/unit/htty/cli/commands/http_get_spec.rb +0 -77
- data/spec/unit/htty/cli/commands/http_head_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/http_options_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/http_patch_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/http_post_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/http_put_spec.rb +0 -71
- data/spec/unit/htty/cli/commands/http_trace_spec.rb +0 -69
- data/spec/unit/htty/cli/commands/patch_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/path_set_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/port_set_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/post_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/put_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/query_add_spec.rb +0 -82
- data/spec/unit/htty/cli/commands/query_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/query_remove_spec.rb +0 -82
- data/spec/unit/htty/cli/commands/query_set_spec.rb +0 -82
- data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +0 -74
- data/spec/unit/htty/cli/commands/query_unset_spec.rb +0 -75
- data/spec/unit/htty/cli/commands/quit_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/reuse_spec.rb +0 -72
- data/spec/unit/htty/cli/commands/scheme_set_spec.rb +0 -74
- data/spec/unit/htty/cli/commands/shared_examples_for_commands.rb +0 -55
- data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +0 -67
- data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +0 -60
- data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +0 -65
- data/spec/unit/htty/cli/commands/status_spec.rb +0 -73
- data/spec/unit/htty/cli/commands/undo_spec.rb +0 -57
- data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +0 -64
- data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +0 -97
- data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +0 -72
- data/spec/unit/htty/cli/display_spec.rb +0 -84
- data/spec/unit/htty/cli_spec.rb +0 -28
- data/spec/unit/htty/command.rb +0 -47
- data/spec/unit/htty/headers_spec.rb +0 -40
- data/spec/unit/htty/payload_spec.rb +0 -60
- data/spec/unit/htty/preferences_spec.rb +0 -8
- data/spec/unit/htty/request_follow_spec.rb +0 -94
- data/spec/unit/htty/request_spec.rb +0 -1232
- data/spec/unit/htty/request_userinfo_spec.rb +0 -208
- data/spec/unit/htty/response_spec.rb +0 -0
- data/spec/unit/htty/session_spec.rb +0 -10
- data/spec/unit/htty/shared_examples_for_requests.rb +0 -32
- data/spec/unit/htty/url_escaping.rb +0 -70
- data/spec/unit/htty/version_spec.rb +0 -8
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/request")
|
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/response")
|
|
4
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/version")
|
|
5
|
-
|
|
6
|
-
require File.expand_path("#{File.dirname __FILE__}/shared_examples_for_requests")
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
shared_examples_for 'a request with basic authentication' do
|
|
10
|
-
it 'should have userinfo in the URI' do
|
|
11
|
-
expected_uri = URI.parse(uri)
|
|
12
|
-
expected_uri.userinfo = [username, password].compact.join(':')
|
|
13
|
-
subject.uri.should == expected_uri
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'should have the Authorization header' do
|
|
17
|
-
subject.headers.should == [
|
|
18
|
-
user_agent_header,
|
|
19
|
-
HTTY::Headers.basic_authentication_for(
|
|
20
|
-
username, password
|
|
21
|
-
)
|
|
22
|
-
]
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
shared_examples_for 'a request without basic authentication' do
|
|
27
|
-
it 'should not have userinfo in the URI' do
|
|
28
|
-
expected_uri = URI.parse(uri)
|
|
29
|
-
expected_uri.userinfo = nil
|
|
30
|
-
subject.uri.should == expected_uri
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'should not have the Authorization header' do
|
|
34
|
-
subject.headers.should == [user_agent_header]
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
describe HTTY::Request do
|
|
40
|
-
let(:request) {HTTY::Request.new uri}
|
|
41
|
-
let(:user_agent_header) {['User-Agent', 'htty/' + HTTY::VERSION]}
|
|
42
|
-
|
|
43
|
-
subject {request}
|
|
44
|
-
|
|
45
|
-
describe 'without basic authentication' do
|
|
46
|
-
let(:uri) do
|
|
47
|
-
"https://github.com:80/search/deep?q=http#content"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it_should_behave_like 'an empty request'
|
|
51
|
-
it_should_behave_like 'a request without basic authentication'
|
|
52
|
-
|
|
53
|
-
describe '#userinfo_unset' do
|
|
54
|
-
before :each do
|
|
55
|
-
subject.userinfo_unset
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it_should_behave_like 'a request without basic authentication'
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe '#userinfo_set' do
|
|
62
|
-
let(:username) {'njonsson'}
|
|
63
|
-
let(:password) {'123'}
|
|
64
|
-
|
|
65
|
-
before :each do
|
|
66
|
-
subject.userinfo_set username, password
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it_should_behave_like 'a request with basic authentication'
|
|
70
|
-
|
|
71
|
-
context 'with empty password' do
|
|
72
|
-
let(:password) {nil}
|
|
73
|
-
|
|
74
|
-
it_should_behave_like 'a request with basic authentication'
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe '#headers_set Authorization' do
|
|
79
|
-
let(:username) {'njonsson'}
|
|
80
|
-
let(:password) {'123'}
|
|
81
|
-
|
|
82
|
-
before :each do
|
|
83
|
-
subject.header_set 'Authorization',
|
|
84
|
-
HTTY::Headers.basic_authentication_for(username, password).last
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it_should_behave_like 'a request with basic authentication'
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
describe 'with basic authentication' do
|
|
92
|
-
let(:username) {'njonsson'}
|
|
93
|
-
let(:password) {'123'}
|
|
94
|
-
let(:uri) do
|
|
95
|
-
"https://#{username}:#{password}@github.com:80/search/deep?q=http#content"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
let(:basic_authentication) do
|
|
99
|
-
HTTY::Headers.basic_authentication_for(username, password)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it_should_behave_like 'an empty, authenticated request'
|
|
103
|
-
it_should_behave_like 'a request with basic authentication'
|
|
104
|
-
|
|
105
|
-
describe '#userinfo_unset' do
|
|
106
|
-
before :each do
|
|
107
|
-
subject.userinfo_unset
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it 'should have the same URI, without userinfo' do
|
|
111
|
-
expected_uri = URI.parse(uri)
|
|
112
|
-
expected_uri.user = nil
|
|
113
|
-
subject.uri.should == expected_uri
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
describe '#userinfo_set' do
|
|
118
|
-
context 'with the same credentials' do
|
|
119
|
-
before :each do
|
|
120
|
-
subject.userinfo_set username, password
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it 'should have the same URI' do
|
|
124
|
-
subject.uri.should == URI.parse(uri)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it 'should have the same Authorization header' do
|
|
128
|
-
subject.headers.should == [user_agent_header, basic_authentication]
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context 'with different credentials' do
|
|
133
|
-
let(:different_username) {'gabrielelana'}
|
|
134
|
-
let(:different_password) {'456'}
|
|
135
|
-
|
|
136
|
-
before :each do
|
|
137
|
-
subject.userinfo_set different_username, different_password
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
it 'should have the same URI, with the changed userinfo part' do
|
|
141
|
-
expected_uri = URI.parse(uri)
|
|
142
|
-
expected_uri.userinfo = [different_username, different_password].join(':')
|
|
143
|
-
subject.uri.should == expected_uri
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it 'should have changed the Authorization header' do
|
|
147
|
-
subject.headers.should == [
|
|
148
|
-
user_agent_header,
|
|
149
|
-
HTTY::Headers.basic_authentication_for(
|
|
150
|
-
different_username, different_password
|
|
151
|
-
)
|
|
152
|
-
]
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
context 'with credentials that contains an escaped character' do
|
|
157
|
-
let(:username) {'n%40'}
|
|
158
|
-
|
|
159
|
-
it 'should be escaped in the URI' do
|
|
160
|
-
subject.uri.userinfo.should start_with(username)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it 'should not be escaped in the Authorization header' do
|
|
164
|
-
subject.headers.should == [
|
|
165
|
-
user_agent_header,
|
|
166
|
-
HTTY::Headers.basic_authentication_for(
|
|
167
|
-
URI.unescape(username), password
|
|
168
|
-
)
|
|
169
|
-
]
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
context 'with a response' do
|
|
174
|
-
before :each do
|
|
175
|
-
subject.send :response=, HTTY::Response.new
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
it 'should return a request without a response' do
|
|
179
|
-
subject.userinfo_set(username, password).response.should be_nil
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
describe '#headers_unset Authorization' do
|
|
185
|
-
before :each do
|
|
186
|
-
subject.header_unset 'Authorization'
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it 'should have the same URI, without userinfo' do
|
|
190
|
-
expected_uri = URI.parse(uri)
|
|
191
|
-
expected_uri.user = nil
|
|
192
|
-
subject.uri.should == expected_uri
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
describe '#headers_unset_all' do
|
|
197
|
-
before :each do
|
|
198
|
-
subject.headers_unset_all
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
it 'should have the same URI, without userinfo' do
|
|
202
|
-
expected_uri = URI.parse(uri)
|
|
203
|
-
expected_uri.user = nil
|
|
204
|
-
subject.uri.should == expected_uri
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
end
|
|
File without changes
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/request")
|
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/session")
|
|
4
|
-
|
|
5
|
-
describe HTTY::Session do
|
|
6
|
-
it 'should have one request with the expected URI' do
|
|
7
|
-
session = HTTY::Session.new('foo')
|
|
8
|
-
session.requests.should == [HTTY::Request.new('foo')]
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
shared_examples_for 'an empty request' do
|
|
2
|
-
it 'should have only the default headers' do
|
|
3
|
-
request.headers.should == [
|
|
4
|
-
['User-Agent', "htty/#{HTTY::VERSION}"]
|
|
5
|
-
]
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it 'should have no body' do
|
|
9
|
-
request.body.should be_nil
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'should have no response' do
|
|
13
|
-
request.response.should be_nil
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
shared_examples_for 'an empty, authenticated request' do
|
|
18
|
-
it 'should the expected Authorization header plus the default headers' do
|
|
19
|
-
request.headers.should == [
|
|
20
|
-
['User-Agent', "htty/#{HTTY::VERSION}"],
|
|
21
|
-
HTTY::Headers.basic_authentication_for(username, password)
|
|
22
|
-
]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'should have no body' do
|
|
26
|
-
request.body.should be_nil
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'should have no response' do
|
|
30
|
-
request.response.should be_nil
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/cli/url_escaping")
|
|
3
|
-
|
|
4
|
-
describe HTTY::CLI::UrlEscaping do
|
|
5
|
-
subject do
|
|
6
|
-
o = Object.new.extend(HTTY::CLI::UrlEscaping)
|
|
7
|
-
o.stub(:say)
|
|
8
|
-
o
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe '.escape_or_warn_of_escape_sequences' do
|
|
12
|
-
context 'when argument is already escaped' do
|
|
13
|
-
let(:escaped_string) {'Hello%20World'}
|
|
14
|
-
|
|
15
|
-
it 'should not escape it twice' do
|
|
16
|
-
should_not_escape(escaped_string)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'should warn the user' do
|
|
20
|
-
subject.should_receive(:say).once
|
|
21
|
-
escape(escaped_string)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'when argument contains reserved characters' do
|
|
26
|
-
let(:unescaped_string) {'Hello World'}
|
|
27
|
-
|
|
28
|
-
it 'should escape it' do
|
|
29
|
-
should_escape(unescaped_string)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'should not warn the user' do
|
|
33
|
-
subject.should_receive(:say).never
|
|
34
|
-
escape(unescaped_string)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context 'when argument contains not reserved characters' do
|
|
39
|
-
let(:unescaped_string) {'HelloWorld'}
|
|
40
|
-
|
|
41
|
-
it 'should not escape it' do
|
|
42
|
-
should_not_escape(unescaped_string)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'should not warn the user' do
|
|
46
|
-
subject.should_receive(:say).never
|
|
47
|
-
escape(unescaped_string)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# http://tools.ietf.org/html/rfc3986#section-2.2
|
|
52
|
-
":/?#[]@!$&'()*+,;=".each_char do |reserved_character|
|
|
53
|
-
it "should escape reserved character '#{reserved_character}'" do
|
|
54
|
-
should_escape(reserved_character)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def should_escape(s)
|
|
60
|
-
escape(s).should_not == [s]
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def should_not_escape(s)
|
|
64
|
-
escape(s).should == [s]
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def escape(s)
|
|
68
|
-
subject.escape_or_warn_of_escape_sequences([s])
|
|
69
|
-
end
|
|
70
|
-
end
|