htty 1.1.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/History.markdown +46 -0
  2. data/README.markdown +12 -12
  3. data/VERSION +1 -1
  4. data/lib/htty/cli.rb +10 -0
  5. data/lib/htty/cli/command.rb +50 -41
  6. data/lib/htty/cli/commands/http_put.rb +3 -0
  7. data/lib/htty/cli/commands/query_unset.rb +4 -2
  8. data/lib/htty/cli/http_method_command.rb +5 -3
  9. data/spec/integration/htty/cli/commands/query_add_spec.rb +51 -0
  10. data/spec/integration/htty/cli/commands/query_remove_spec.rb +37 -0
  11. data/spec/integration/htty/cli/commands/query_set_spec.rb +72 -0
  12. data/spec/integration/htty/cli/commands/query_unset_spec.rb +37 -0
  13. data/spec/unit/htty/cli/commands/address_spec.rb +103 -0
  14. data/spec/unit/htty/cli/commands/body_clear_spec.rb +64 -0
  15. data/spec/unit/htty/cli/commands/body_request_spec.rb +72 -0
  16. data/spec/unit/htty/cli/commands/body_response_spec.rb +70 -0
  17. data/spec/unit/htty/cli/commands/body_set_spec.rb +71 -0
  18. data/spec/unit/htty/cli/commands/body_unset_spec.rb +69 -0
  19. data/spec/unit/htty/cli/commands/cd_spec.rb +57 -0
  20. data/spec/unit/htty/cli/commands/cookie_add_spec.rb +64 -0
  21. data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +64 -0
  22. data/spec/unit/htty/cli/commands/cookies_add_spec.rb +78 -0
  23. data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +64 -0
  24. data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +73 -0
  25. data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +69 -0
  26. data/spec/unit/htty/cli/commands/cookies_spec.rb +76 -0
  27. data/spec/unit/htty/cli/commands/cookies_use_spec.rb +75 -0
  28. data/spec/unit/htty/cli/commands/delete_spec.rb +64 -0
  29. data/spec/unit/htty/cli/commands/exit_spec.rb +64 -0
  30. data/spec/unit/htty/cli/commands/follow_spec.rb +70 -0
  31. data/spec/unit/htty/cli/commands/form_add_spec.rb +64 -0
  32. data/spec/unit/htty/cli/commands/form_clear_spec.rb +64 -0
  33. data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +66 -0
  34. data/spec/unit/htty/cli/commands/form_remove_spec.rb +57 -0
  35. data/spec/unit/htty/cli/commands/form_spec.rb +57 -0
  36. data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +64 -0
  37. data/spec/unit/htty/cli/commands/fragment_set_spec.rb +73 -0
  38. data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +72 -0
  39. data/spec/unit/htty/cli/commands/get_spec.rb +64 -0
  40. data/spec/unit/htty/cli/commands/header_set_spec.rb +64 -0
  41. data/spec/unit/htty/cli/commands/header_unset_spec.rb +64 -0
  42. data/spec/unit/htty/cli/commands/headers_clear_spec.rb +64 -0
  43. data/spec/unit/htty/cli/commands/headers_request_spec.rb +81 -0
  44. data/spec/unit/htty/cli/commands/headers_response_spec.rb +77 -0
  45. data/spec/unit/htty/cli/commands/headers_set_spec.rb +74 -0
  46. data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +71 -0
  47. data/spec/unit/htty/cli/commands/headers_unset_spec.rb +63 -0
  48. data/spec/unit/htty/cli/commands/help_spec.rb +67 -0
  49. data/spec/unit/htty/cli/commands/history_spec.rb +65 -0
  50. data/spec/unit/htty/cli/commands/history_verbose_spec.rb +72 -0
  51. data/spec/unit/htty/cli/commands/host_set_spec.rb +71 -0
  52. data/spec/unit/htty/cli/commands/http_delete_spec.rb +73 -0
  53. data/spec/unit/htty/cli/commands/http_get_spec.rb +75 -0
  54. data/spec/unit/htty/cli/commands/http_head_spec.rb +69 -0
  55. data/spec/unit/htty/cli/commands/http_options_spec.rb +69 -0
  56. data/spec/unit/htty/cli/commands/http_post_spec.rb +71 -0
  57. data/spec/unit/htty/cli/commands/http_put_spec.rb +69 -0
  58. data/spec/unit/htty/cli/commands/http_trace_spec.rb +69 -0
  59. data/spec/unit/htty/cli/commands/path_set_spec.rb +72 -0
  60. data/spec/unit/htty/cli/commands/port_set_spec.rb +73 -0
  61. data/spec/unit/htty/cli/commands/post_spec.rb +64 -0
  62. data/spec/unit/htty/cli/commands/put_spec.rb +64 -0
  63. data/spec/unit/htty/cli/commands/query_add_spec.rb +67 -36
  64. data/spec/unit/htty/cli/commands/query_clear_spec.rb +64 -0
  65. data/spec/unit/htty/cli/commands/query_remove_spec.rb +69 -24
  66. data/spec/unit/htty/cli/commands/query_set_spec.rb +59 -49
  67. data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +73 -0
  68. data/spec/unit/htty/cli/commands/query_unset_spec.rb +75 -0
  69. data/spec/unit/htty/cli/commands/quit_spec.rb +64 -0
  70. data/spec/unit/htty/cli/commands/reuse_spec.rb +72 -0
  71. data/spec/unit/htty/cli/commands/scheme_set_spec.rb +74 -0
  72. data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +67 -0
  73. data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +60 -0
  74. data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +65 -0
  75. data/spec/unit/htty/cli/commands/status_spec.rb +73 -0
  76. data/spec/unit/htty/cli/commands/undo_spec.rb +57 -0
  77. data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +64 -0
  78. data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +75 -0
  79. data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +72 -0
  80. data/spec/unit/htty/cli_spec.rb +8 -2
  81. data/spec/unit/htty/ordered_hash_spec.rb +14 -24
  82. data/spec/unit/htty/preferences_spec.rb +1 -1
  83. data/spec/unit/htty/request_spec.rb +454 -463
  84. metadata +80 -20
@@ -0,0 +1,64 @@
1
+ require 'rspec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/header_set")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_set")
4
+
5
+ describe HTTY::CLI::Commands::HeaderSet 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::HeadersSet
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 == 'Building Requests'
21
+ end
22
+
23
+ it 'should have the expected command_line' do
24
+ klass.command_line.should == 'header-s[et]'
25
+ end
26
+
27
+ it 'should have the expected command_line_arguments' do
28
+ klass.command_line_arguments.should == 'NAME VALUE'
29
+ end
30
+
31
+ it 'should have the expected help' do
32
+ klass.help.should == "Alias for \e[1mheaders-s[et]\e[0m"
33
+ end
34
+
35
+ it 'should have the expected help_extended' do
36
+ klass.help_extended.should == "Alias for \e[1mheaders-s[et]\e[0m."
37
+ end
38
+
39
+ it 'should have the expected see_also_commands' do
40
+ klass.see_also_commands.should == [HTTY::CLI::Commands::HeadersSet]
41
+ end
42
+
43
+ describe 'build_for' do
44
+ it 'should correctly handle a valid, unabbreviated command line' do
45
+ built = klass.build_for('header-set foo bar', :session => :the_session)
46
+ built.should be_instance_of(klass)
47
+ built.arguments.should == %w(foo bar)
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('header-s baz qux', :session => :a_session)
53
+ built.should be_instance_of(klass)
54
+ built.arguments.should == %w(baz qux)
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 quux corge', :session => :another_session)
60
+ built.should == nil
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,64 @@
1
+ require 'rspec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/header_unset")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset")
4
+
5
+ describe HTTY::CLI::Commands::HeaderUnset 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::HeadersUnset
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 == 'Building Requests'
21
+ end
22
+
23
+ it 'should have the expected command_line' do
24
+ klass.command_line.should == 'header-u[nset]'
25
+ end
26
+
27
+ it 'should have the expected command_line_arguments' do
28
+ klass.command_line_arguments.should == 'NAME'
29
+ end
30
+
31
+ it 'should have the expected help' do
32
+ klass.help.should == "Alias for \e[1mheaders-unset\e[0m"
33
+ end
34
+
35
+ it 'should have the expected help_extended' do
36
+ klass.help_extended.should == "Alias for \e[1mheaders-unset\e[0m."
37
+ end
38
+
39
+ it 'should have the expected see_also_commands' do
40
+ klass.see_also_commands.should == [HTTY::CLI::Commands::HeadersUnset]
41
+ end
42
+
43
+ describe 'build_for' do
44
+ it 'should correctly handle a valid, unabbreviated command line' do
45
+ built = klass.build_for('header-unset foo', :session => :the_session)
46
+ built.should be_instance_of(klass)
47
+ built.arguments.should == ['foo']
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('header-u bar', :session => :a_session)
53
+ built.should be_instance_of(klass)
54
+ built.arguments.should == ['bar']
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 baz', :session => :another_session)
60
+ built.should == nil
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,64 @@
1
+ require 'rspec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_clear")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset_all")
4
+
5
+ describe HTTY::CLI::Commands::HeadersClear 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::HeadersUnsetAll
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 == 'Building Requests'
21
+ end
22
+
23
+ it 'should have the expected command_line' do
24
+ klass.command_line.should == 'headers-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[1mheaders-unset-[all]\e[0m"
33
+ end
34
+
35
+ it 'should have the expected help_extended' do
36
+ klass.help_extended.should == "Alias for \e[1mheaders-unset-[all]\e[0m."
37
+ end
38
+
39
+ it 'should have the expected see_also_commands' do
40
+ klass.see_also_commands.should == [HTTY::CLI::Commands::HeadersUnsetAll]
41
+ end
42
+
43
+ describe 'build_for' do
44
+ it 'should correctly handle a valid, unabbreviated command line' do
45
+ built = klass.build_for('headers-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('headers-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
@@ -0,0 +1,81 @@
1
+ require 'rspec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_request")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/cookies")
4
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_request")
5
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_response")
6
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_set")
7
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset")
8
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset_all")
9
+
10
+ describe HTTY::CLI::Commands::HeadersRequest do
11
+ describe 'class' do
12
+ let :klass do
13
+ subject.class
14
+ end
15
+
16
+ it 'should be an alias_for the expected command' do
17
+ klass.alias_for.should == nil
18
+ end
19
+
20
+ it 'should have the expected aliases' do
21
+ klass.aliases.should == []
22
+ end
23
+
24
+ it 'should belong to the expected category' do
25
+ klass.category.should == 'Building Requests'
26
+ end
27
+
28
+ it 'should have the expected command_line' do
29
+ klass.command_line.should == 'headers-req[uest]'
30
+ end
31
+
32
+ it 'should have the expected command_line_arguments' do
33
+ klass.command_line_arguments.should == nil
34
+ end
35
+
36
+ it 'should have the expected help' do
37
+ klass.help.should == 'Displays the headers of the request'
38
+ end
39
+
40
+ it 'should have the expected help_extended' do
41
+ expected = <<-end_help_extended
42
+ Displays the headers used for the request. Does not communicate with the host.
43
+
44
+ Headers must have unique names. When you set a header that already exists, its value will be changed.
45
+
46
+ A 'Cookie' request header is marked with a bold asterisk (it looks like a cookie). Similarly, an 'Authorization' request header is marked with a bold mercantile symbol ('@').
47
+ end_help_extended
48
+ klass.help_extended.should == expected.chomp
49
+ end
50
+
51
+ it 'should have the expected see_also_commands' do
52
+ klass.see_also_commands.should == [HTTY::CLI::Commands::HeadersSet,
53
+ HTTY::CLI::Commands::HeadersUnset,
54
+ HTTY::CLI::Commands::HeadersUnsetAll,
55
+ HTTY::CLI::Commands::BodyRequest,
56
+ HTTY::CLI::Commands::Cookies,
57
+ HTTY::CLI::Commands::HeadersResponse]
58
+ end
59
+
60
+ describe 'build_for' do
61
+ it 'should correctly handle a valid, unabbreviated command line' do
62
+ built = klass.build_for('headers-request', :session => :the_session)
63
+ built.should be_instance_of(klass)
64
+ built.arguments.should == []
65
+ built.session.should == :the_session
66
+ end
67
+
68
+ it 'should correctly handle a valid, abbreviated command line' do
69
+ built = klass.build_for('headers-req', :session => :a_session)
70
+ built.should be_instance_of(klass)
71
+ built.arguments.should == []
72
+ built.session.should == :a_session
73
+ end
74
+
75
+ it 'should correctly handle a command line with a bad command' do
76
+ built = klass.build_for('x', :session => :another_session)
77
+ built.should == nil
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,77 @@
1
+ require 'rspec'
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/cookies")
4
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/cookies_use")
5
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_request")
6
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_response")
7
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/status")
8
+
9
+ describe HTTY::CLI::Commands::HeadersResponse do
10
+ describe 'class' do
11
+ let :klass do
12
+ subject.class
13
+ end
14
+
15
+ it 'should be an alias_for the expected command' do
16
+ klass.alias_for.should == nil
17
+ end
18
+
19
+ it 'should have the expected aliases' do
20
+ klass.aliases.should == []
21
+ end
22
+
23
+ it 'should belong to the expected category' do
24
+ klass.category.should == 'Inspecting Responses'
25
+ end
26
+
27
+ it 'should have the expected command_line' do
28
+ klass.command_line.should == 'headers[-response]'
29
+ end
30
+
31
+ it 'should have the expected command_line_arguments' do
32
+ klass.command_line_arguments.should == nil
33
+ end
34
+
35
+ it 'should have the expected help' do
36
+ klass.help.should == 'Displays the headers of the response'
37
+ end
38
+
39
+ it 'should have the expected help_extended' do
40
+ expected = <<-end_help_extended
41
+ Displays the headers received in the response. Does not communicate with the host.
42
+
43
+ A 'Set-Cookie' request header is marked with a bold asterisk (it looks like a cookie).
44
+ end_help_extended
45
+ klass.help_extended.should == expected.chomp
46
+ end
47
+
48
+ it 'should have the expected see_also_commands' do
49
+ klass.see_also_commands.should == [HTTY::CLI::Commands::BodyResponse,
50
+ HTTY::CLI::Commands::Cookies,
51
+ HTTY::CLI::Commands::CookiesUse,
52
+ HTTY::CLI::Commands::Status,
53
+ HTTY::CLI::Commands::HeadersRequest]
54
+ end
55
+
56
+ describe 'build_for' do
57
+ it 'should correctly handle a valid, unabbreviated command line' do
58
+ built = klass.build_for('headers-response', :session => :the_session)
59
+ built.should be_instance_of(klass)
60
+ built.arguments.should == []
61
+ built.session.should == :the_session
62
+ end
63
+
64
+ it 'should correctly handle a valid, abbreviated command line' do
65
+ built = klass.build_for('headers', :session => :a_session)
66
+ built.should be_instance_of(klass)
67
+ built.arguments.should == []
68
+ built.session.should == :a_session
69
+ end
70
+
71
+ it 'should correctly handle a command line with a bad command' do
72
+ built = klass.build_for('x', :session => :another_session)
73
+ built.should == nil
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,74 @@
1
+ require 'rspec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/header_set")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_request")
4
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_set")
5
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset")
6
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset_all")
7
+
8
+ describe HTTY::CLI::Commands::HeadersSet do
9
+ describe 'class' do
10
+ let :klass do
11
+ subject.class
12
+ end
13
+
14
+ it 'should be an alias_for the expected command' do
15
+ klass.alias_for.should == nil
16
+ end
17
+
18
+ it 'should have the expected aliases' do
19
+ klass.aliases.should == [HTTY::CLI::Commands::HeaderSet]
20
+ end
21
+
22
+ it 'should belong to the expected category' do
23
+ klass.category.should == 'Building Requests'
24
+ end
25
+
26
+ it 'should have the expected command_line' do
27
+ klass.command_line.should == 'headers-s[et]'
28
+ end
29
+
30
+ it 'should have the expected command_line_arguments' do
31
+ klass.command_line_arguments.should == 'NAME VALUE'
32
+ end
33
+
34
+ it 'should have the expected help' do
35
+ klass.help.should == 'Sets a header of the request'
36
+ end
37
+
38
+ it 'should have the expected help_extended' do
39
+ expected = <<-end_help_extended
40
+ Sets a header used for the request. Does not communicate with the host.
41
+
42
+ Headers must have unique names. When you set a header that already exists, its value will be changed.
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::HeadersRequest,
49
+ HTTY::CLI::Commands::HeadersUnset,
50
+ HTTY::CLI::Commands::HeadersUnsetAll]
51
+ end
52
+
53
+ describe 'build_for' do
54
+ it 'should correctly handle a valid, unabbreviated command line' do
55
+ built = klass.build_for('headers-set foo bar', :session => :the_session)
56
+ built.should be_instance_of(klass)
57
+ built.arguments.should == %w(foo bar)
58
+ built.session.should == :the_session
59
+ end
60
+
61
+ it 'should correctly handle a valid, abbreviated command line' do
62
+ built = klass.build_for('headers-s baz qux', :session => :a_session)
63
+ built.should be_instance_of(klass)
64
+ built.arguments.should == %w(baz qux)
65
+ built.session.should == :a_session
66
+ end
67
+
68
+ it 'should correctly handle a command line with a bad command' do
69
+ built = klass.build_for('x quux corge', :session => :another_session)
70
+ built.should == nil
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,71 @@
1
+ require 'rspec'
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_clear")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_request")
4
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_set")
5
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset")
6
+ require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_unset_all")
7
+
8
+ describe HTTY::CLI::Commands::HeadersUnsetAll do
9
+ describe 'class' do
10
+ let :klass do
11
+ subject.class
12
+ end
13
+
14
+ it 'should be an alias_for the expected command' do
15
+ klass.alias_for.should == nil
16
+ end
17
+
18
+ it 'should have the expected aliases' do
19
+ klass.aliases.should == [HTTY::CLI::Commands::HeadersClear]
20
+ end
21
+
22
+ it 'should belong to the expected category' do
23
+ klass.category.should == 'Building Requests'
24
+ end
25
+
26
+ it 'should have the expected command_line' do
27
+ klass.command_line.should == 'headers-unset-[all]'
28
+ end
29
+
30
+ it 'should have the expected command_line_arguments' do
31
+ klass.command_line_arguments.should == nil
32
+ end
33
+
34
+ it 'should have the expected help' do
35
+ klass.help.should == 'Removes all headers from the request'
36
+ end
37
+
38
+ it 'should have the expected help_extended' do
39
+ klass.help_extended.should == 'Removes all headers used for the ' +
40
+ 'request. Does not communicate with the ' +
41
+ 'host.'
42
+ end
43
+
44
+ it 'should have the expected see_also_commands' do
45
+ klass.see_also_commands.should == [HTTY::CLI::Commands::HeadersRequest,
46
+ HTTY::CLI::Commands::HeadersUnset,
47
+ HTTY::CLI::Commands::HeadersSet]
48
+ end
49
+
50
+ describe 'build_for' do
51
+ it 'should correctly handle a valid, unabbreviated command line' do
52
+ built = klass.build_for('headers-unset-all', :session => :the_session)
53
+ built.should be_instance_of(klass)
54
+ built.arguments.should == []
55
+ built.session.should == :the_session
56
+ end
57
+
58
+ it 'should correctly handle a valid, abbreviated command line' do
59
+ built = klass.build_for('headers-unset-', :session => :a_session)
60
+ built.should be_instance_of(klass)
61
+ built.arguments.should == []
62
+ built.session.should == :a_session
63
+ end
64
+
65
+ it 'should correctly handle a command line with a bad command' do
66
+ built = klass.build_for('x', :session => :another_session)
67
+ built.should == nil
68
+ end
69
+ end
70
+ end
71
+ end