htty 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -9
  3. data/.rspec +2 -1
  4. data/.travis.yml +11 -8
  5. data/.yardopts +1 -1
  6. data/Gemfile +22 -10
  7. data/Guardfile +31 -13
  8. data/History.markdown +6 -0
  9. data/README.markdown +29 -13
  10. data/Rakefile +2 -64
  11. data/bin/console +10 -0
  12. data/bin/setup +8 -0
  13. data/exe/htty +5 -0
  14. data/htty.gemspec +27 -29
  15. data/lib/htty.rb +29 -4
  16. data/lib/htty/cli.rb +9 -16
  17. data/lib/htty/cli/body_open_command.rb +2 -7
  18. data/lib/htty/cli/command.rb +10 -18
  19. data/lib/htty/cli/commands.rb +76 -11
  20. data/lib/htty/cli/commands/address.rb +1 -14
  21. data/lib/htty/cli/commands/body_clear.rb +1 -8
  22. data/lib/htty/cli/commands/body_edit.rb +1 -11
  23. data/lib/htty/cli/commands/body_request.rb +1 -12
  24. data/lib/htty/cli/commands/body_request_open.rb +1 -10
  25. data/lib/htty/cli/commands/body_response.rb +1 -12
  26. data/lib/htty/cli/commands/body_response_open.rb +1 -11
  27. data/lib/htty/cli/commands/body_set.rb +1 -10
  28. data/lib/htty/cli/commands/body_unset.rb +1 -9
  29. data/lib/htty/cli/commands/cd.rb +1 -8
  30. data/lib/htty/cli/commands/cookie_add.rb +1 -8
  31. data/lib/htty/cli/commands/cookie_remove.rb +1 -8
  32. data/lib/htty/cli/commands/cookies.rb +1 -15
  33. data/lib/htty/cli/commands/cookies_add.rb +1 -11
  34. data/lib/htty/cli/commands/cookies_clear.rb +1 -8
  35. data/lib/htty/cli/commands/cookies_remove.rb +1 -11
  36. data/lib/htty/cli/commands/cookies_remove_all.rb +1 -11
  37. data/lib/htty/cli/commands/cookies_use.rb +1 -14
  38. data/lib/htty/cli/commands/delete.rb +1 -8
  39. data/lib/htty/cli/commands/exit.rb +1 -8
  40. data/lib/htty/cli/commands/follow.rb +1 -10
  41. data/lib/htty/cli/commands/form.rb +1 -7
  42. data/lib/htty/cli/commands/form_add.rb +1 -7
  43. data/lib/htty/cli/commands/form_clear.rb +1 -8
  44. data/lib/htty/cli/commands/form_remove.rb +1 -7
  45. data/lib/htty/cli/commands/form_remove_all.rb +1 -7
  46. data/lib/htty/cli/commands/fragment_clear.rb +1 -8
  47. data/lib/htty/cli/commands/fragment_set.rb +1 -10
  48. data/lib/htty/cli/commands/fragment_unset.rb +1 -9
  49. data/lib/htty/cli/commands/get.rb +1 -8
  50. data/lib/htty/cli/commands/header_set.rb +1 -8
  51. data/lib/htty/cli/commands/header_unset.rb +1 -8
  52. data/lib/htty/cli/commands/headers_clear.rb +1 -8
  53. data/lib/htty/cli/commands/headers_request.rb +1 -15
  54. data/lib/htty/cli/commands/headers_response.rb +1 -15
  55. data/lib/htty/cli/commands/headers_set.rb +1 -10
  56. data/lib/htty/cli/commands/headers_unset.rb +1 -10
  57. data/lib/htty/cli/commands/headers_unset_all.rb +1 -10
  58. data/lib/htty/cli/commands/help.rb +4 -12
  59. data/lib/htty/cli/commands/history.rb +1 -10
  60. data/lib/htty/cli/commands/history_verbose.rb +1 -12
  61. data/lib/htty/cli/commands/host_set.rb +1 -8
  62. data/lib/htty/cli/commands/http_delete.rb +1 -12
  63. data/lib/htty/cli/commands/http_get.rb +1 -13
  64. data/lib/htty/cli/commands/http_head.rb +1 -9
  65. data/lib/htty/cli/commands/http_options.rb +1 -9
  66. data/lib/htty/cli/commands/http_patch.rb +1 -13
  67. data/lib/htty/cli/commands/http_post.rb +1 -13
  68. data/lib/htty/cli/commands/http_put.rb +1 -12
  69. data/lib/htty/cli/commands/http_trace.rb +1 -9
  70. data/lib/htty/cli/commands/patch.rb +1 -8
  71. data/lib/htty/cli/commands/path_set.rb +11 -11
  72. data/lib/htty/cli/commands/port_set.rb +1 -9
  73. data/lib/htty/cli/commands/post.rb +1 -8
  74. data/lib/htty/cli/commands/put.rb +1 -8
  75. data/lib/htty/cli/commands/query_add.rb +1 -13
  76. data/lib/htty/cli/commands/query_clear.rb +1 -8
  77. data/lib/htty/cli/commands/query_remove.rb +1 -13
  78. data/lib/htty/cli/commands/query_set.rb +1 -13
  79. data/lib/htty/cli/commands/query_unset.rb +1 -13
  80. data/lib/htty/cli/commands/query_unset_all.rb +1 -10
  81. data/lib/htty/cli/commands/quit.rb +1 -7
  82. data/lib/htty/cli/commands/reuse.rb +5 -12
  83. data/lib/htty/cli/commands/scheme_set.rb +1 -9
  84. data/lib/htty/cli/commands/ssl_verification.rb +1 -11
  85. data/lib/htty/cli/commands/ssl_verification_off.rb +1 -10
  86. data/lib/htty/cli/commands/ssl_verification_on.rb +1 -10
  87. data/lib/htty/cli/commands/status.rb +1 -11
  88. data/lib/htty/cli/commands/undo.rb +1 -7
  89. data/lib/htty/cli/commands/userinfo_clear.rb +1 -8
  90. data/lib/htty/cli/commands/userinfo_set.rb +1 -11
  91. data/lib/htty/cli/commands/userinfo_unset.rb +1 -9
  92. data/lib/htty/cli/display.rb +4 -6
  93. data/lib/htty/cli/http_method_command.rb +1 -10
  94. data/lib/htty/cli/input_device.rb +1 -0
  95. data/lib/htty/cli/url_escaping.rb +1 -6
  96. data/lib/htty/cookies_util.rb +3 -3
  97. data/lib/htty/headers.rb +3 -4
  98. data/lib/htty/http_patch.rb +20 -23
  99. data/lib/htty/no_header_error.rb +1 -1
  100. data/lib/htty/no_location_header_error.rb +1 -3
  101. data/lib/htty/no_response_error.rb +1 -1
  102. data/lib/htty/no_set_cookie_header_error.rb +1 -3
  103. data/lib/htty/payload.rb +1 -5
  104. data/lib/htty/platform.rb +1 -1
  105. data/lib/htty/preferences.rb +1 -1
  106. data/lib/htty/request.rb +3 -13
  107. data/lib/htty/requests_util.rb +1 -5
  108. data/lib/htty/response.rb +1 -4
  109. data/lib/htty/session.rb +1 -3
  110. data/lib/htty/tempfile_preserving_extname.rb +1 -2
  111. data/lib/htty/uri.rb +1 -2
  112. data/lib/htty/version.rb +1 -1
  113. data/lib/tasks.rb +3 -0
  114. data/lib/tasks/build_doc.rake +8 -0
  115. data/lib/tasks/lib_each.rake +25 -0
  116. data/lib/tasks/spec.rake +68 -0
  117. data/lib/tasks/spec_each.rake +19 -0
  118. metadata +48 -209
  119. data/bin/htty +0 -5
  120. data/spec/integration/htty/cli/commands/query_add_spec.rb +0 -57
  121. data/spec/integration/htty/cli/commands/query_remove_spec.rb +0 -55
  122. data/spec/integration/htty/cli/commands/query_set_spec.rb +0 -78
  123. data/spec/integration/htty/cli/commands/query_unset_spec.rb +0 -43
  124. data/spec/spec_helper.rb +0 -76
  125. data/spec/unit/htty/cli/commands/address_spec.rb +0 -103
  126. data/spec/unit/htty/cli/commands/body_clear_spec.rb +0 -64
  127. data/spec/unit/htty/cli/commands/body_edit_spec.rb +0 -18
  128. data/spec/unit/htty/cli/commands/body_request_spec.rb +0 -67
  129. data/spec/unit/htty/cli/commands/body_response_spec.rb +0 -72
  130. data/spec/unit/htty/cli/commands/body_set_spec.rb +0 -71
  131. data/spec/unit/htty/cli/commands/body_unset_spec.rb +0 -69
  132. data/spec/unit/htty/cli/commands/cd_spec.rb +0 -57
  133. data/spec/unit/htty/cli/commands/cookie_add_spec.rb +0 -64
  134. data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +0 -64
  135. data/spec/unit/htty/cli/commands/cookies_add_spec.rb +0 -78
  136. data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +0 -64
  137. data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +0 -73
  138. data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +0 -69
  139. data/spec/unit/htty/cli/commands/cookies_spec.rb +0 -76
  140. data/spec/unit/htty/cli/commands/cookies_use_spec.rb +0 -75
  141. data/spec/unit/htty/cli/commands/delete_spec.rb +0 -64
  142. data/spec/unit/htty/cli/commands/exit_spec.rb +0 -64
  143. data/spec/unit/htty/cli/commands/follow_spec.rb +0 -70
  144. data/spec/unit/htty/cli/commands/form_add_spec.rb +0 -64
  145. data/spec/unit/htty/cli/commands/form_clear_spec.rb +0 -64
  146. data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +0 -66
  147. data/spec/unit/htty/cli/commands/form_remove_spec.rb +0 -57
  148. data/spec/unit/htty/cli/commands/form_spec.rb +0 -57
  149. data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +0 -64
  150. data/spec/unit/htty/cli/commands/fragment_set_spec.rb +0 -73
  151. data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +0 -72
  152. data/spec/unit/htty/cli/commands/get_spec.rb +0 -64
  153. data/spec/unit/htty/cli/commands/header_set_spec.rb +0 -64
  154. data/spec/unit/htty/cli/commands/header_unset_spec.rb +0 -64
  155. data/spec/unit/htty/cli/commands/headers_clear_spec.rb +0 -64
  156. data/spec/unit/htty/cli/commands/headers_request_spec.rb +0 -81
  157. data/spec/unit/htty/cli/commands/headers_response_spec.rb +0 -77
  158. data/spec/unit/htty/cli/commands/headers_set_spec.rb +0 -74
  159. data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +0 -71
  160. data/spec/unit/htty/cli/commands/headers_unset_spec.rb +0 -63
  161. data/spec/unit/htty/cli/commands/help_spec.rb +0 -67
  162. data/spec/unit/htty/cli/commands/history_spec.rb +0 -65
  163. data/spec/unit/htty/cli/commands/history_verbose_spec.rb +0 -72
  164. data/spec/unit/htty/cli/commands/host_set_spec.rb +0 -71
  165. data/spec/unit/htty/cli/commands/http_delete_spec.rb +0 -75
  166. data/spec/unit/htty/cli/commands/http_get_spec.rb +0 -77
  167. data/spec/unit/htty/cli/commands/http_head_spec.rb +0 -69
  168. data/spec/unit/htty/cli/commands/http_options_spec.rb +0 -69
  169. data/spec/unit/htty/cli/commands/http_patch_spec.rb +0 -73
  170. data/spec/unit/htty/cli/commands/http_post_spec.rb +0 -73
  171. data/spec/unit/htty/cli/commands/http_put_spec.rb +0 -71
  172. data/spec/unit/htty/cli/commands/http_trace_spec.rb +0 -69
  173. data/spec/unit/htty/cli/commands/patch_spec.rb +0 -64
  174. data/spec/unit/htty/cli/commands/path_set_spec.rb +0 -72
  175. data/spec/unit/htty/cli/commands/port_set_spec.rb +0 -73
  176. data/spec/unit/htty/cli/commands/post_spec.rb +0 -64
  177. data/spec/unit/htty/cli/commands/put_spec.rb +0 -64
  178. data/spec/unit/htty/cli/commands/query_add_spec.rb +0 -82
  179. data/spec/unit/htty/cli/commands/query_clear_spec.rb +0 -64
  180. data/spec/unit/htty/cli/commands/query_remove_spec.rb +0 -82
  181. data/spec/unit/htty/cli/commands/query_set_spec.rb +0 -82
  182. data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +0 -74
  183. data/spec/unit/htty/cli/commands/query_unset_spec.rb +0 -75
  184. data/spec/unit/htty/cli/commands/quit_spec.rb +0 -64
  185. data/spec/unit/htty/cli/commands/reuse_spec.rb +0 -72
  186. data/spec/unit/htty/cli/commands/scheme_set_spec.rb +0 -74
  187. data/spec/unit/htty/cli/commands/shared_examples_for_commands.rb +0 -55
  188. data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +0 -67
  189. data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +0 -60
  190. data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +0 -65
  191. data/spec/unit/htty/cli/commands/status_spec.rb +0 -73
  192. data/spec/unit/htty/cli/commands/undo_spec.rb +0 -57
  193. data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +0 -64
  194. data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +0 -97
  195. data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +0 -72
  196. data/spec/unit/htty/cli/display_spec.rb +0 -84
  197. data/spec/unit/htty/cli_spec.rb +0 -28
  198. data/spec/unit/htty/command.rb +0 -47
  199. data/spec/unit/htty/headers_spec.rb +0 -40
  200. data/spec/unit/htty/payload_spec.rb +0 -60
  201. data/spec/unit/htty/preferences_spec.rb +0 -8
  202. data/spec/unit/htty/request_follow_spec.rb +0 -94
  203. data/spec/unit/htty/request_spec.rb +0 -1232
  204. data/spec/unit/htty/request_userinfo_spec.rb +0 -208
  205. data/spec/unit/htty/response_spec.rb +0 -0
  206. data/spec/unit/htty/session_spec.rb +0 -10
  207. data/spec/unit/htty/shared_examples_for_requests.rb +0 -32
  208. data/spec/unit/htty/url_escaping.rb +0 -70
  209. data/spec/unit/htty/version_spec.rb +0 -8
@@ -1,73 +0,0 @@
1
- require 'spec_helper'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_response")
3
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_response")
4
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/status")
5
-
6
- describe HTTY::CLI::Commands::Status do
7
- describe 'class' do
8
- let :klass do
9
- subject.class
10
- end
11
-
12
- it 'should be an alias_for the expected command' do
13
- klass.alias_for.should == nil
14
- end
15
-
16
- it 'should have the expected aliases' do
17
- klass.aliases.should == []
18
- end
19
-
20
- it 'should belong to the expected category' do
21
- klass.category.should == 'Inspecting Responses'
22
- end
23
-
24
- it 'should have the expected command_line' do
25
- klass.command_line.should == 'st[atus]'
26
- end
27
-
28
- it 'should have the expected command_line_arguments' do
29
- klass.command_line_arguments.should == nil
30
- end
31
-
32
- it 'should have the expected help' do
33
- klass.help.should == 'Displays the status of the response'
34
- end
35
-
36
- it 'should have the expected help_extended' do
37
- expected = <<-end_help_extended
38
- Displays the status signal, the number of headers, and size of the body received in the response. Does not communicate with the host.
39
-
40
- If a 'Set-Cookie' request header is present, a bold asterisk (it looks like a cookie) appears next to the headers summary.
41
-
42
- Status is displayed automatically when a response is received.
43
- end_help_extended
44
- klass.help_extended.should == expected.chomp
45
- end
46
-
47
- it 'should have the expected see_also_commands' do
48
- klass.see_also_commands.should == [HTTY::CLI::Commands::BodyResponse,
49
- HTTY::CLI::Commands::HeadersResponse]
50
- end
51
-
52
- describe 'build_for' do
53
- it 'should correctly handle a valid, unabbreviated command line' do
54
- built = klass.build_for('status', :session => :the_session)
55
- built.should be_instance_of(klass)
56
- built.arguments.should == []
57
- built.session.should == :the_session
58
- end
59
-
60
- it 'should correctly handle a valid, abbreviated command line' do
61
- built = klass.build_for('st', :session => :a_session)
62
- built.should be_instance_of(klass)
63
- built.arguments.should == []
64
- built.session.should == :a_session
65
- end
66
-
67
- it 'should correctly handle a command line with a bad command' do
68
- built = klass.build_for('x', :session => :another_session)
69
- built.should == nil
70
- end
71
- end
72
- end
73
- end
@@ -1,57 +0,0 @@
1
- require 'spec_helper'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/undo")
3
-
4
- describe HTTY::CLI::Commands::Undo do
5
- describe 'class' do
6
- let :klass do
7
- subject.class
8
- end
9
-
10
- it 'should be an alias_for the expected command' do
11
- klass.alias_for.should == nil
12
- end
13
-
14
- it 'should have the expected aliases' do
15
- klass.aliases.should == []
16
- end
17
-
18
- it 'should belong to the expected category' do
19
- klass.category.should == nil
20
- end
21
-
22
- it 'should have the expected command_line' do
23
- klass.command_line.should == 'un[do]'
24
- end
25
-
26
- it 'should have the expected command_line_arguments' do
27
- klass.command_line_arguments.should == nil
28
- end
29
-
30
- it 'should have the expected help' do
31
- klass.help.should == "(Help for \e[1mun[do]\e[0m is not available)"
32
- end
33
-
34
- it 'should have the expected help_extended' do
35
- klass.help_extended.should == "(Help for \e[1mun[do]\e[0m is not " +
36
- 'available).'
37
- end
38
-
39
- it 'should have the expected see_also_commands' do
40
- klass.see_also_commands.should == []
41
- end
42
-
43
- describe 'build_for' do
44
- it 'should correctly handle a valid, unabbreviated command line' do
45
- built = klass.build_for('undo', :session => :the_session)
46
- built.should be_instance_of(klass)
47
- built.arguments.should == []
48
- built.session.should == :the_session
49
- end
50
-
51
- it 'should correctly handle a command line with a bad command' do
52
- built = klass.build_for('x', :session => :another_session)
53
- built.should == nil
54
- end
55
- end
56
- end
57
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_clear")
3
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_unset")
4
-
5
- describe HTTY::CLI::Commands::UserinfoClear do
6
- describe 'class' do
7
- let :klass do
8
- subject.class
9
- end
10
-
11
- it 'should be an alias_for the expected command' do
12
- klass.alias_for.should == HTTY::CLI::Commands::UserinfoUnset
13
- end
14
-
15
- it 'should have the expected aliases' do
16
- klass.aliases.should == []
17
- end
18
-
19
- it 'should belong to the expected category' do
20
- klass.category.should == 'Navigation'
21
- end
22
-
23
- it 'should have the expected command_line' do
24
- klass.command_line.should == 'userinfo-c[lear]'
25
- end
26
-
27
- it 'should have the expected command_line_arguments' do
28
- klass.command_line_arguments.should == nil
29
- end
30
-
31
- it 'should have the expected help' do
32
- klass.help.should == "Alias for \e[1muserinfo-u[nset]\e[0m"
33
- end
34
-
35
- it 'should have the expected help_extended' do
36
- klass.help_extended.should == "Alias for \e[1muserinfo-u[nset]\e[0m."
37
- end
38
-
39
- it 'should have the expected see_also_commands' do
40
- klass.see_also_commands.should == [HTTY::CLI::Commands::UserinfoUnset]
41
- end
42
-
43
- describe 'build_for' do
44
- it 'should correctly handle a valid, unabbreviated command line' do
45
- built = klass.build_for('userinfo-clear', :session => :the_session)
46
- built.should be_instance_of(klass)
47
- built.arguments.should == []
48
- built.session.should == :the_session
49
- end
50
-
51
- it 'should correctly handle a valid, abbreviated command line' do
52
- built = klass.build_for('userinfo-c', :session => :a_session)
53
- built.should be_instance_of(klass)
54
- built.arguments.should == []
55
- built.session.should == :a_session
56
- end
57
-
58
- it 'should correctly handle a command line with a bad command' do
59
- built = klass.build_for('x', :session => :another_session)
60
- built.should == nil
61
- end
62
- end
63
- end
64
- end
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/address")
3
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_set")
4
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_unset")
5
-
6
- describe HTTY::CLI::Commands::UserinfoSet do
7
- describe 'class' do
8
- let :klass do
9
- subject.class
10
- end
11
-
12
- it 'should be an alias_for the expected command' do
13
- klass.alias_for.should == nil
14
- end
15
-
16
- it 'should have the expected aliases' do
17
- klass.aliases.should == []
18
- end
19
-
20
- it 'should belong to the expected category' do
21
- klass.category.should == 'Navigation'
22
- end
23
-
24
- it 'should have the expected command_line' do
25
- klass.command_line.should == 'userinfo-s[et]'
26
- end
27
-
28
- it 'should have the expected command_line_arguments' do
29
- klass.command_line_arguments.should == 'USERNAME [PASSWORD]'
30
- end
31
-
32
- it 'should have the expected help' do
33
- klass.help.should == "Sets the userinfo of the request's address"
34
- end
35
-
36
- it 'should have the expected help_extended' do
37
- expected = <<-end_help_extended
38
- Sets the userinfo used for the request. Does not communicate with the host.
39
-
40
- Userinfo will be URL-encoded if necessary.
41
-
42
- When userinfo is set, a corresponding 'Authorization' header is set automatically.
43
-
44
- The console prompt shows the address for the current request. Userinfo appears in normal type while the rest of the address appears in bold to indicate that userinfo is sent to the host in the form of a header.
45
- end_help_extended
46
- klass.help_extended.should == expected.chomp
47
- end
48
-
49
- it 'should have the expected see_also_commands' do
50
- klass.see_also_commands.should == [HTTY::CLI::Commands::UserinfoUnset,
51
- HTTY::CLI::Commands::Address]
52
- end
53
-
54
- describe 'build_for' do
55
- it 'should correctly handle a valid, unabbreviated command line' do
56
- built = klass.build_for('userinfo-set foo bar', :session => :the_session)
57
- built.should be_instance_of(klass)
58
- built.arguments.should == %w(foo bar)
59
- built.session.should == :the_session
60
- end
61
-
62
- it 'should correctly handle a valid, abbreviated command line' do
63
- built = klass.build_for('userinfo-s baz', :session => :a_session)
64
- built.should be_instance_of(klass)
65
- built.arguments.should == ['baz']
66
- built.session.should == :a_session
67
- end
68
-
69
- it 'should correctly handle a command line with a bad command' do
70
- built = klass.build_for('x qux', :session => :another_session)
71
- built.should == nil
72
- end
73
- end
74
-
75
- describe '#sanitize_arguments' do
76
- context 'when only one argument like username:password' do
77
- let(:arguments) {['username:password']}
78
-
79
- it 'should be splitted in two arguments' do
80
- klass.sanitize_arguments(arguments).should == [
81
- 'username', 'password'
82
- ]
83
- end
84
- end
85
-
86
- context 'when arguments contains special characters' do
87
- let(:arguments) {['user/name', 'password']}
88
-
89
- it 'should escape them' do
90
- klass.sanitize_arguments(arguments).should == [
91
- 'user%2Fname', 'password'
92
- ]
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,72 +0,0 @@
1
- require 'spec_helper'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/address")
3
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_clear")
4
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_set")
5
- require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_unset")
6
-
7
- describe HTTY::CLI::Commands::UserinfoUnset do
8
- describe 'class' do
9
- let :klass do
10
- subject.class
11
- end
12
-
13
- it 'should be an alias_for the expected command' do
14
- klass.alias_for.should == nil
15
- end
16
-
17
- it 'should have the expected aliases' do
18
- klass.aliases.should == [HTTY::CLI::Commands::UserinfoClear]
19
- end
20
-
21
- it 'should belong to the expected category' do
22
- klass.category.should == 'Navigation'
23
- end
24
-
25
- it 'should have the expected command_line' do
26
- klass.command_line.should == 'userinfo-u[nset]'
27
- end
28
-
29
- it 'should have the expected command_line_arguments' do
30
- klass.command_line_arguments.should == nil
31
- end
32
-
33
- it 'should have the expected help' do
34
- klass.help.should == "Removes the userinfo from the request's address"
35
- end
36
-
37
- it 'should have the expected help_extended' do
38
- expected = <<-end_help_extended
39
- Removes the userinfo used for the request. Does not communicate with the host.
40
-
41
- The console prompt shows the address for the current request.
42
- end_help_extended
43
- klass.help_extended.should == expected.chomp
44
- end
45
-
46
- it 'should have the expected see_also_commands' do
47
- klass.see_also_commands.should == [HTTY::CLI::Commands::UserinfoSet,
48
- HTTY::CLI::Commands::Address]
49
- end
50
-
51
- describe 'build_for' do
52
- it 'should correctly handle a valid, unabbreviated command line' do
53
- built = klass.build_for('userinfo-unset', :session => :the_session)
54
- built.should be_instance_of(klass)
55
- built.arguments.should == []
56
- built.session.should == :the_session
57
- end
58
-
59
- it 'should correctly handle a valid, abbreviated command line' do
60
- built = klass.build_for('userinfo-u', :session => :a_session)
61
- built.should be_instance_of(klass)
62
- built.arguments.should == []
63
- built.session.should == :a_session
64
- end
65
-
66
- it 'should correctly handle a command line with a bad command' do
67
- built = klass.build_for('x', :session => :another_session)
68
- built.should == nil
69
- end
70
- end
71
- end
72
- end
@@ -1,84 +0,0 @@
1
- require 'spec_helper'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../../lib/htty/headers")
3
- require File.expand_path("#{File.dirname __FILE__}/../../../../lib/htty/cli/display")
4
-
5
- describe HTTY::CLI::Display do
6
- let(:display) {Class.new.new.extend(HTTY::CLI::Display)}
7
-
8
- describe '#show_headers' do
9
- it 'displays headers keeping the text case' do
10
- headers = HTTY::Headers.new('user-agent' => 'htty/1.4.1').to_a
11
-
12
- expect {display.show_headers(headers)}.to print_on_stdout(
13
- "user-agent:#{display.strong('')} htty/1.4.1\n"
14
- )
15
- end
16
-
17
- context 'with one header' do
18
- let(:headers) {HTTY::Headers.new('User-Agent' => 'htty/1.4.1').to_a}
19
-
20
- it 'displays the header starting from the beginning of the line' do
21
- expect {display.show_headers(headers)}.to print_on_stdout(
22
- "User-Agent:#{display.strong('')} htty/1.4.1\n"
23
- )
24
- end
25
- end
26
-
27
- context 'with few headers' do
28
- let(:headers) {
29
- headers = HTTY::Headers.new
30
- headers['User-Agent'] = 'htty/1.4.1'
31
- headers['Content-Type'] = 'application/json'
32
- headers.to_a
33
- }
34
-
35
- it 'aligns headers on colons' do
36
- expect {display.show_headers(headers)}.to print_on_stdout(
37
- " User-Agent:#{display.strong('')} htty/1.4.1\n" +
38
- "Content-Type:#{display.strong('')} application/json\n"
39
- )
40
- end
41
- end
42
-
43
- context 'with marked headers' do
44
- context 'with one header' do
45
- let(:headers) {HTTY::Headers.new('User-Agent' => 'htty/1.4.1').to_a}
46
- let(:options) {{:show_mercantile_next_to => 'User-Agent'}}
47
-
48
- it 'displays the header starting from the beginning of the line' do
49
- expect {display.show_headers(headers, options)}.to print_on_stdout(
50
- "User-Agent:#{display.strong('@')} htty/1.4.1\n"
51
- )
52
- end
53
- end
54
-
55
- context 'with few headers' do
56
- let(:options) {{:show_mercantile_next_to => 'Content-Type'}}
57
- let(:headers) {
58
- headers = HTTY::Headers.new
59
- headers['User-Agent'] = 'htty/1.4.1'
60
- headers['Content-Type'] = 'application/json'
61
- headers.to_a
62
- }
63
-
64
- it 'aligns colons and mercantiles' do
65
- expect {display.show_headers(headers, options)}.to print_on_stdout(
66
- " User-Agent:#{display.strong('')} htty/1.4.1\n" +
67
- "Content-Type:#{display.strong('@')} application/json\n"
68
- )
69
- end
70
- end
71
- end
72
-
73
- context 'when asked to mark an header' do
74
- let(:options) {{:show_mercantile_next_to => 'Content-Type'}}
75
- let(:headers) {HTTY::Headers.new('content-type' => 'application/json').to_a}
76
-
77
- it 'marks headers indipendently of the text case' do
78
- expect {display.show_headers(headers, options)}.to print_on_stdout(
79
- "content-type:#{display.strong('@')} application/json\n"
80
- )
81
- end
82
- end
83
- end
84
- end