htty 1.1.6 → 1.2.0
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.
- data/History.markdown +46 -0
- data/README.markdown +12 -12
- data/VERSION +1 -1
- data/lib/htty/cli.rb +10 -0
- data/lib/htty/cli/command.rb +50 -41
- data/lib/htty/cli/commands/http_put.rb +3 -0
- data/lib/htty/cli/commands/query_unset.rb +4 -2
- data/lib/htty/cli/http_method_command.rb +5 -3
- data/spec/integration/htty/cli/commands/query_add_spec.rb +51 -0
- data/spec/integration/htty/cli/commands/query_remove_spec.rb +37 -0
- data/spec/integration/htty/cli/commands/query_set_spec.rb +72 -0
- data/spec/integration/htty/cli/commands/query_unset_spec.rb +37 -0
- data/spec/unit/htty/cli/commands/address_spec.rb +103 -0
- data/spec/unit/htty/cli/commands/body_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/body_request_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/body_response_spec.rb +70 -0
- data/spec/unit/htty/cli/commands/body_set_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/body_unset_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/cd_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/cookie_add_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/cookie_remove_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/cookies_add_spec.rb +78 -0
- data/spec/unit/htty/cli/commands/cookies_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/cookies_remove_all_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/cookies_remove_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/cookies_spec.rb +76 -0
- data/spec/unit/htty/cli/commands/cookies_use_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/delete_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/exit_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/follow_spec.rb +70 -0
- data/spec/unit/htty/cli/commands/form_add_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/form_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/form_remove_all_spec.rb +66 -0
- data/spec/unit/htty/cli/commands/form_remove_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/form_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/fragment_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/fragment_set_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/fragment_unset_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/get_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/header_set_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/header_unset_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/headers_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/headers_request_spec.rb +81 -0
- data/spec/unit/htty/cli/commands/headers_response_spec.rb +77 -0
- data/spec/unit/htty/cli/commands/headers_set_spec.rb +74 -0
- data/spec/unit/htty/cli/commands/headers_unset_all_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/headers_unset_spec.rb +63 -0
- data/spec/unit/htty/cli/commands/help_spec.rb +67 -0
- data/spec/unit/htty/cli/commands/history_spec.rb +65 -0
- data/spec/unit/htty/cli/commands/history_verbose_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/host_set_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/http_delete_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/http_get_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/http_head_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/http_options_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/http_post_spec.rb +71 -0
- data/spec/unit/htty/cli/commands/http_put_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/http_trace_spec.rb +69 -0
- data/spec/unit/htty/cli/commands/path_set_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/port_set_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/post_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/put_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/query_add_spec.rb +67 -36
- data/spec/unit/htty/cli/commands/query_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/query_remove_spec.rb +69 -24
- data/spec/unit/htty/cli/commands/query_set_spec.rb +59 -49
- data/spec/unit/htty/cli/commands/query_unset_all_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/query_unset_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/quit_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/reuse_spec.rb +72 -0
- data/spec/unit/htty/cli/commands/scheme_set_spec.rb +74 -0
- data/spec/unit/htty/cli/commands/ssl_verification_off_spec.rb +67 -0
- data/spec/unit/htty/cli/commands/ssl_verification_on_spec.rb +60 -0
- data/spec/unit/htty/cli/commands/ssl_verification_spec.rb +65 -0
- data/spec/unit/htty/cli/commands/status_spec.rb +73 -0
- data/spec/unit/htty/cli/commands/undo_spec.rb +57 -0
- data/spec/unit/htty/cli/commands/userinfo_clear_spec.rb +64 -0
- data/spec/unit/htty/cli/commands/userinfo_set_spec.rb +75 -0
- data/spec/unit/htty/cli/commands/userinfo_unset_spec.rb +72 -0
- data/spec/unit/htty/cli_spec.rb +8 -2
- data/spec/unit/htty/ordered_hash_spec.rb +14 -24
- data/spec/unit/htty/preferences_spec.rb +1 -1
- data/spec/unit/htty/request_spec.rb +454 -463
- metadata +80 -20
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'rspec'
|
|
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/query_unset")
|
|
4
|
+
|
|
5
|
+
describe HTTY::CLI::Commands::QueryUnset do
|
|
6
|
+
let :klass do
|
|
7
|
+
subject.class
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let :session do
|
|
11
|
+
HTTY::Session.new nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def instance(*arguments)
|
|
15
|
+
klass.new :session => session, :arguments => arguments
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'with existing query string with duplicate keys set' do
|
|
19
|
+
before :each do
|
|
20
|
+
session.requests.last.uri.query = 'test=true&test=false'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe 'with only key specified' do
|
|
24
|
+
it 'should remove all entries' do
|
|
25
|
+
instance('test').perform
|
|
26
|
+
session.requests.last.uri.query.should == ''
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe 'with key and value specified' do
|
|
31
|
+
it 'should remove matching entry only' do
|
|
32
|
+
instance('test', 'true').perform
|
|
33
|
+
session.requests.last.uri.query.should == 'test=false'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'rspec'
|
|
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/fragment_set")
|
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/host_set")
|
|
5
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/path_set")
|
|
6
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/port_set")
|
|
7
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_set")
|
|
8
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/scheme_set")
|
|
9
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/userinfo_set")
|
|
10
|
+
|
|
11
|
+
describe HTTY::CLI::Commands::Address do
|
|
12
|
+
describe 'class' do
|
|
13
|
+
let :klass do
|
|
14
|
+
subject.class
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should be an alias_for the expected command' do
|
|
18
|
+
klass.alias_for.should == nil
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should have the expected aliases' do
|
|
22
|
+
klass.aliases.should == []
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should belong to the expected category' do
|
|
26
|
+
klass.category.should == 'Navigation'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should have the expected command_line' do
|
|
30
|
+
klass.command_line.should == 'a[ddress]'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should have the expected command_line_arguments' do
|
|
34
|
+
klass.command_line_arguments.should == 'ADDRESS'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should have the expected help' do
|
|
38
|
+
klass.help.should == 'Changes the address of the request'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should have the expected help_extended' do
|
|
42
|
+
expected = <<-end_help_extended
|
|
43
|
+
Changes the address used for the request. Does not communicate with the host.
|
|
44
|
+
|
|
45
|
+
The URL you supply can be partial. At a minimum, you must specify a host. The optional and required elements of an address are illustrated below:
|
|
46
|
+
|
|
47
|
+
https://steve:woodside@apple.com:6666/store?q=ipad#sold-to-date
|
|
48
|
+
\\______/\\_____________/\\_______/\\___/\\____/\\_____/\\___________/
|
|
49
|
+
1. 2. 3. 4. 5. 6. 7.
|
|
50
|
+
|
|
51
|
+
1. A scheme, or protocol identifier (i.e., 'http://' or 'https://' -- optional)
|
|
52
|
+
2. Userinfo (e.g., 'username:password@' -- optional)
|
|
53
|
+
3. A host (i.e., a hostname or IP address -- required)
|
|
54
|
+
4. A TCP port number (i.e., ':0' through ':65535' -- optional)
|
|
55
|
+
5. A path (optional)
|
|
56
|
+
6. A query string (e.g., '?foo=bar&baz=qux' -- optional)
|
|
57
|
+
7. A fragment (e.g., '#fragment-name' -- optional)
|
|
58
|
+
|
|
59
|
+
If (1) is omitted, HTTP is used, except if (4) is specified as port 443, in which case HTTPS is used.
|
|
60
|
+
|
|
61
|
+
If (3) is omitted, host 0.0.0.0 is used.
|
|
62
|
+
|
|
63
|
+
If (4) is omitted, port 80 is used, except if (1) is specified as HTTPS, in which case port 443 is used.
|
|
64
|
+
|
|
65
|
+
If (5) is omitted, the root path (i.e., '/') is used.
|
|
66
|
+
|
|
67
|
+
The console prompt shows the address for the current request.
|
|
68
|
+
end_help_extended
|
|
69
|
+
klass.help_extended.should == expected.chomp
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'should have the expected see_also_commands' do
|
|
73
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::SchemeSet,
|
|
74
|
+
HTTY::CLI::Commands::UserinfoSet,
|
|
75
|
+
HTTY::CLI::Commands::HostSet,
|
|
76
|
+
HTTY::CLI::Commands::PortSet,
|
|
77
|
+
HTTY::CLI::Commands::PathSet,
|
|
78
|
+
HTTY::CLI::Commands::QuerySet,
|
|
79
|
+
HTTY::CLI::Commands::FragmentSet]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe 'build_for' do
|
|
83
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
|
84
|
+
built = klass.build_for('address foo', :session => :the_session)
|
|
85
|
+
built.should be_instance_of(klass)
|
|
86
|
+
built.arguments.should == ['foo']
|
|
87
|
+
built.session.should == :the_session
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'should correctly handle a valid, abbreviated command line' do
|
|
91
|
+
built = klass.build_for('a bar', :session => :a_session)
|
|
92
|
+
built.should be_instance_of(klass)
|
|
93
|
+
built.arguments.should == ['bar']
|
|
94
|
+
built.session.should == :a_session
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'should correctly handle a command line with a bad command' do
|
|
98
|
+
built = klass.build_for('x baz', :session => :another_session)
|
|
99
|
+
built.should == nil
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'rspec'
|
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_clear")
|
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_unset")
|
|
4
|
+
|
|
5
|
+
describe HTTY::CLI::Commands::BodyClear 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::BodyUnset
|
|
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 == 'body-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[1mbody-u[nset]\e[0m"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should have the expected help_extended' do
|
|
36
|
+
klass.help_extended.should == "Alias for \e[1mbody-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::BodyUnset]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe 'build_for' do
|
|
44
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
|
45
|
+
built = klass.build_for('body-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('body-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,72 @@
|
|
|
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/body_response")
|
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_set")
|
|
5
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_unset")
|
|
6
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_request")
|
|
7
|
+
|
|
8
|
+
describe HTTY::CLI::Commands::BodyRequest 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 == []
|
|
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 == 'body-req[uest]'
|
|
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 == 'Displays the body of the request'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should have the expected help_extended' do
|
|
39
|
+
klass.help_extended.should == 'Displays the body content 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::BodySet,
|
|
46
|
+
HTTY::CLI::Commands::BodyUnset,
|
|
47
|
+
HTTY::CLI::Commands::HeadersRequest,
|
|
48
|
+
HTTY::CLI::Commands::BodyResponse]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe 'build_for' do
|
|
52
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
|
53
|
+
built = klass.build_for('body-request', :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('body-req', :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
|
|
@@ -0,0 +1,70 @@
|
|
|
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/body_response")
|
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/headers_response")
|
|
5
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/status")
|
|
6
|
+
|
|
7
|
+
describe HTTY::CLI::Commands::BodyResponse 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 == []
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should belong to the expected category' do
|
|
22
|
+
klass.category.should == 'Inspecting Responses'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should have the expected command_line' do
|
|
26
|
+
klass.command_line.should == 'body[-response]'
|
|
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 == 'Displays the body of the response'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should have the expected help_extended' do
|
|
38
|
+
klass.help_extended.should == 'Displays the body content received in ' +
|
|
39
|
+
'the response. Does not communicate with ' +
|
|
40
|
+
'the host.'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should have the expected see_also_commands' do
|
|
44
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::HeadersResponse,
|
|
45
|
+
HTTY::CLI::Commands::Status,
|
|
46
|
+
HTTY::CLI::Commands::BodyRequest]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe 'build_for' do
|
|
50
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
|
51
|
+
built = klass.build_for('body-response', :session => :the_session)
|
|
52
|
+
built.should be_instance_of(klass)
|
|
53
|
+
built.arguments.should == []
|
|
54
|
+
built.session.should == :the_session
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should correctly handle a valid, abbreviated command line' do
|
|
58
|
+
built = klass.build_for('body', :session => :a_session)
|
|
59
|
+
built.should be_instance_of(klass)
|
|
60
|
+
built.arguments.should == []
|
|
61
|
+
built.session.should == :a_session
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'should correctly handle a command line with a bad command' do
|
|
65
|
+
built = klass.build_for('x', :session => :another_session)
|
|
66
|
+
built.should == nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
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/body_set")
|
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_unset")
|
|
5
|
+
|
|
6
|
+
describe HTTY::CLI::Commands::BodySet 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 == 'Building Requests'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should have the expected command_line' do
|
|
25
|
+
klass.command_line.should == 'body-s[et]'
|
|
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 == 'Sets the body of the request'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should have the expected help_extended' do
|
|
37
|
+
expected = <<-end_help_extended
|
|
38
|
+
Sets the body content used for the request. Does not communicate with the host.
|
|
39
|
+
|
|
40
|
+
Hit Return three times in a row to signify the end of the body.
|
|
41
|
+
end_help_extended
|
|
42
|
+
klass.help_extended.should == expected.chomp
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should have the expected see_also_commands' do
|
|
46
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::BodyRequest,
|
|
47
|
+
HTTY::CLI::Commands::BodyUnset]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe 'build_for' do
|
|
51
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
|
52
|
+
built = klass.build_for('body-set', :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('body-s', :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
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'rspec'
|
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_clear")
|
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_request")
|
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_set")
|
|
5
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/body_unset")
|
|
6
|
+
|
|
7
|
+
describe HTTY::CLI::Commands::BodyUnset 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::BodyClear]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should belong to the expected category' do
|
|
22
|
+
klass.category.should == 'Building Requests'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'should have the expected command_line' do
|
|
26
|
+
klass.command_line.should == 'body-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 == 'Clears the body of the request'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should have the expected help_extended' do
|
|
38
|
+
klass.help_extended.should == 'Clears the body content used for the ' +
|
|
39
|
+
'request. Does not communicate with the ' +
|
|
40
|
+
'host.'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should have the expected see_also_commands' do
|
|
44
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::BodyRequest,
|
|
45
|
+
HTTY::CLI::Commands::BodySet]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe 'build_for' do
|
|
49
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
|
50
|
+
built = klass.build_for('body-unset', :session => :the_session)
|
|
51
|
+
built.should be_instance_of(klass)
|
|
52
|
+
built.arguments.should == []
|
|
53
|
+
built.session.should == :the_session
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'should correctly handle a valid, abbreviated command line' do
|
|
57
|
+
built = klass.build_for('body-u', :session => :a_session)
|
|
58
|
+
built.should be_instance_of(klass)
|
|
59
|
+
built.arguments.should == []
|
|
60
|
+
built.session.should == :a_session
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'should correctly handle a command line with a bad command' do
|
|
64
|
+
built = klass.build_for('x', :session => :another_session)
|
|
65
|
+
built.should == nil
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|