htty 1.1.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,65 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/ssl_verification")
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/ssl_verification_off")
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/ssl_verification_on")
|
5
|
+
|
6
|
+
describe HTTY::CLI::Commands::SslVerification 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 == 'Preferences'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have the expected command_line' do
|
25
|
+
klass.command_line.should == 'ssl-verification'
|
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 preference for SSL certificate ' +
|
34
|
+
'verification'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have the expected help_extended' do
|
38
|
+
expected = <<-end_help_extended
|
39
|
+
Displays the preference for SSL certificate verification. Does not communicate with the host.
|
40
|
+
|
41
|
+
When issuing HTTP Secure requests, server certificates will be verified. You can disable and reenable this behavior.
|
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::SslVerificationOff,
|
48
|
+
HTTY::CLI::Commands::SslVerificationOn]
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'build_for' do
|
52
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
53
|
+
built = klass.build_for('ssl-verification', :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 command line with a bad command' do
|
60
|
+
built = klass.build_for('x', :session => :another_session)
|
61
|
+
built.should == nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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/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
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rspec'
|
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
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rspec'
|
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
|
@@ -0,0 +1,75 @@
|
|
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/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
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,72 @@
|
|
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/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
|
data/spec/unit/htty/cli_spec.rb
CHANGED
@@ -4,15 +4,21 @@ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/request")
|
|
4
4
|
|
5
5
|
describe HTTY::CLI do
|
6
6
|
describe 'with empty arguments' do
|
7
|
+
let :cli do
|
8
|
+
HTTY::CLI.new([])
|
9
|
+
end
|
10
|
+
|
7
11
|
it 'should have a session with the URI http://0.0.0.0:80/' do
|
8
|
-
cli = HTTY::CLI.new([])
|
9
12
|
cli.session.requests.should == [HTTY::Request.new('http://0.0.0.0:80/')]
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
13
16
|
describe 'with an address argument' do
|
17
|
+
let :cli do
|
18
|
+
HTTY::CLI.new(%w(https://njonsson@github.com/njonsson/htty))
|
19
|
+
end
|
20
|
+
|
14
21
|
it 'should have a session with a URI corresponding to the address' do
|
15
|
-
cli = HTTY::CLI.new(%w(https://njonsson@github.com/njonsson/htty))
|
16
22
|
cli.session.requests.should == [HTTY::Request.new('https://' +
|
17
23
|
'njonsson@github.com' +
|
18
24
|
':443' +
|
@@ -3,48 +3,38 @@ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/ordered_has
|
|
3
3
|
|
4
4
|
describe HTTY::OrderedHash do
|
5
5
|
describe 'that is empty' do
|
6
|
-
|
6
|
+
it { should be_empty }
|
7
7
|
|
8
|
-
|
9
|
-
hash.should be_empty
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '-- when values are added out of order' do
|
8
|
+
describe 'when values are added out of order' do
|
13
9
|
before :each do
|
14
|
-
|
15
|
-
|
10
|
+
subject['foo'] = 'bar'
|
11
|
+
subject['baz'] = 'qux'
|
16
12
|
end
|
17
13
|
|
18
|
-
it
|
19
|
-
hash.should == {'foo' => 'bar', 'baz' => 'qux'}
|
20
|
-
end
|
14
|
+
it { should == {'foo' => 'bar', 'baz' => 'qux'} }
|
21
15
|
|
22
|
-
it '
|
23
|
-
|
16
|
+
it 'should return the expected array when sent #to_a' do
|
17
|
+
subject.to_a.should == [%w(foo bar), %w(baz qux)]
|
24
18
|
end
|
25
19
|
end
|
26
20
|
end
|
27
21
|
|
28
22
|
describe 'that has values out of order' do
|
29
|
-
|
23
|
+
subject { HTTY::OrderedHash.new('foo' => 'bar', 'baz' => 'qux') }
|
30
24
|
|
31
|
-
it
|
32
|
-
hash.should == {'foo' => 'bar', 'baz' => 'qux'}
|
33
|
-
end
|
25
|
+
it { should == {'foo' => 'bar', 'baz' => 'qux'} }
|
34
26
|
|
35
27
|
it 'should index the values as expected' do
|
36
|
-
|
37
|
-
|
28
|
+
subject['foo'].should == 'bar'
|
29
|
+
subject['baz'].should == 'qux'
|
38
30
|
end
|
39
31
|
|
40
|
-
describe '
|
32
|
+
describe 'when sent #clear' do
|
41
33
|
before :each do
|
42
|
-
|
34
|
+
subject.clear
|
43
35
|
end
|
44
36
|
|
45
|
-
it
|
46
|
-
hash.should be_empty
|
47
|
-
end
|
37
|
+
it { should be_empty }
|
48
38
|
end
|
49
39
|
end
|
50
40
|
end
|