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,64 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/post")
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/http_post")
|
4
|
+
|
5
|
+
describe HTTY::CLI::Commands::Post 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::HttpPost
|
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 == 'Issuing Requests'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have the expected command_line' do
|
24
|
+
klass.command_line.should == 'pos[t]'
|
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[1mhttp-po[st]\e[0m"
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have the expected help_extended' do
|
36
|
+
klass.help_extended.should == "Alias for \e[1mhttp-po[st]\e[0m."
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have the expected see_also_commands' do
|
40
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::HttpPost]
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'build_for' do
|
44
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
45
|
+
built = klass.build_for('post', :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('pos', :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,64 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/put")
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/http_put")
|
4
|
+
|
5
|
+
describe HTTY::CLI::Commands::Put 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::HttpPut
|
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 == 'Issuing Requests'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have the expected command_line' do
|
24
|
+
klass.command_line.should == 'pu[t]'
|
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[1mhttp-pu[t]\e[0m"
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have the expected help_extended' do
|
36
|
+
klass.help_extended.should == "Alias for \e[1mhttp-pu[t]\e[0m."
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have the expected see_also_commands' do
|
40
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::HttpPut]
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'build_for' do
|
44
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
45
|
+
built = klass.build_for('put', :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('pu', :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,51 +1,82 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/address")
|
2
3
|
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_add")
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_remove")
|
5
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_set")
|
6
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_unset")
|
7
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_unset_all")
|
4
8
|
|
5
9
|
describe HTTY::CLI::Commands::QueryAdd do
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
describe 'class' do
|
11
|
+
let :klass do
|
12
|
+
subject.class
|
13
|
+
end
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
it 'should add key' do
|
13
|
-
query_add = create_query_add_and_perform('test')
|
14
|
-
query_add.session.requests.last.uri.query.should == 'test'
|
15
|
-
end
|
15
|
+
it 'should be an alias_for the expected command' do
|
16
|
+
klass.alias_for.should == nil
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
@session.requests.last.uri.query = 'test=true'
|
21
|
-
query_add = create_query_add_and_perform('test')
|
22
|
-
query_add.session.requests.last.uri.query.should == 'test=true&test'
|
23
|
-
end
|
19
|
+
it 'should have the expected aliases' do
|
20
|
+
klass.aliases.should == []
|
24
21
|
end
|
25
|
-
end
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
it 'should add key and value' do
|
30
|
-
query_add = create_query_add_and_perform('test', 'true')
|
31
|
-
query_add.session.requests.last.uri.query.should == 'test=true'
|
32
|
-
end
|
23
|
+
it 'should belong to the expected category' do
|
24
|
+
klass.category.should == 'Navigation'
|
33
25
|
end
|
34
26
|
|
35
|
-
|
36
|
-
|
37
|
-
@session.requests.last.uri.query = 'test=true'
|
38
|
-
query_add = create_query_add_and_perform('test', 'false')
|
39
|
-
query_add.session.requests.last.uri.query.should == 'test=true&test=false'
|
40
|
-
end
|
27
|
+
it 'should have the expected command_line' do
|
28
|
+
klass.command_line.should == 'query-a[dd]'
|
41
29
|
end
|
42
|
-
end
|
43
30
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
31
|
+
it 'should have the expected command_line_arguments' do
|
32
|
+
klass.command_line_arguments.should == 'NAME [VALUE [NAME [VALUE ...]]]'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have the expected help' do
|
36
|
+
klass.help.should == "Adds query-string parameters to the request's " +
|
37
|
+
'address'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have the expected help_extended' do
|
41
|
+
expected = <<-end_help_extended
|
42
|
+
Adds one or more query-string parameters used for the request. Does not communicate with the host.
|
50
43
|
|
44
|
+
The difference between this command and \e[1mquery-s[et]\e[0m is that this command adds duplicate parameters instead of replacing any of them.
|
45
|
+
|
46
|
+
The name(s) and value(s) of the query-string parameter(s) will be URL-encoded if necessary.
|
47
|
+
|
48
|
+
The console prompt shows the address for the current request.
|
49
|
+
end_help_extended
|
50
|
+
klass.help_extended.should == expected.chomp
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should have the expected see_also_commands' do
|
54
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::QueryRemove,
|
55
|
+
HTTY::CLI::Commands::QuerySet,
|
56
|
+
HTTY::CLI::Commands::QueryUnset,
|
57
|
+
HTTY::CLI::Commands::QueryUnsetAll,
|
58
|
+
HTTY::CLI::Commands::Address]
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'build_for' do
|
62
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
63
|
+
built = klass.build_for('query-add foo bar', :session => :the_session)
|
64
|
+
built.should be_instance_of(klass)
|
65
|
+
built.arguments.should == %w(foo bar)
|
66
|
+
built.session.should == :the_session
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should correctly handle a valid, abbreviated command line' do
|
70
|
+
built = klass.build_for('query-a baz', :session => :a_session)
|
71
|
+
built.should be_instance_of(klass)
|
72
|
+
built.arguments.should == ['baz']
|
73
|
+
built.session.should == :a_session
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should correctly handle a command line with a bad command' do
|
77
|
+
built = klass.build_for('x qux', :session => :another_session)
|
78
|
+
built.should == nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
51
82
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_clear")
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_unset_all")
|
4
|
+
|
5
|
+
describe HTTY::CLI::Commands::QueryClear 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::QueryUnsetAll
|
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 == 'query-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[1mquery-unset-[all]\e[0m"
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have the expected help_extended' do
|
36
|
+
klass.help_extended.should == "Alias for \e[1mquery-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::QueryUnsetAll]
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'build_for' do
|
44
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
45
|
+
built = klass.build_for('query-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('query-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,37 +1,82 @@
|
|
1
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_add")
|
2
4
|
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_remove")
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/
|
5
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_set")
|
6
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_unset")
|
7
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_unset_all")
|
4
8
|
|
5
9
|
describe HTTY::CLI::Commands::QueryRemove do
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
describe 'class' do
|
11
|
+
let :klass do
|
12
|
+
subject.class
|
13
|
+
end
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
@session.requests.last.uri.query = 'test=true&test=false'
|
15
|
+
it 'should be an alias_for the expected command' do
|
16
|
+
klass.alias_for.should == nil
|
13
17
|
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
query_remove = create_query_remove_and_perform('test')
|
18
|
-
query_remove.session.requests.last.uri.query.should == 'test=true'
|
19
|
-
end
|
19
|
+
it 'should have the expected aliases' do
|
20
|
+
klass.aliases.should == []
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
query_remove = create_query_remove_and_perform('test', 'true')
|
25
|
-
query_remove.session.requests.last.uri.query.should == 'test=false'
|
26
|
-
end
|
23
|
+
it 'should belong to the expected category' do
|
24
|
+
klass.category.should == 'Navigation'
|
27
25
|
end
|
28
|
-
end
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
it 'should have the expected command_line' do
|
28
|
+
klass.command_line.should == 'query-r[emove]'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have the expected command_line_arguments' do
|
32
|
+
klass.command_line_arguments.should == 'NAME [VALUE]'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have the expected help' do
|
36
|
+
klass.help.should == 'Removes query-string parameters from the end of ' +
|
37
|
+
"the request's address"
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have the expected help_extended' do
|
41
|
+
expected = <<-end_help_extended
|
42
|
+
Removes one or more a query-string parameters used for the request. Does not communicate with the host.
|
43
|
+
|
44
|
+
The difference between this command and \e[1mquery-unset\e[0m is that this command removes matching parameters one at a time from the end of the address instead of removing all matches.
|
36
45
|
|
46
|
+
The name and value of the query-string parameter will be URL-encoded if necessary.
|
47
|
+
|
48
|
+
The console prompt shows the address for the current request.
|
49
|
+
end_help_extended
|
50
|
+
klass.help_extended.should == expected.chomp
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should have the expected see_also_commands' do
|
54
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::QueryAdd,
|
55
|
+
HTTY::CLI::Commands::QuerySet,
|
56
|
+
HTTY::CLI::Commands::QueryUnset,
|
57
|
+
HTTY::CLI::Commands::QueryUnsetAll,
|
58
|
+
HTTY::CLI::Commands::Address]
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'build_for' do
|
62
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
63
|
+
built = klass.build_for('query-remove foo bar', :session => :the_session)
|
64
|
+
built.should be_instance_of(klass)
|
65
|
+
built.arguments.should == %w(foo bar)
|
66
|
+
built.session.should == :the_session
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should correctly handle a valid, abbreviated command line' do
|
70
|
+
built = klass.build_for('query-r baz', :session => :a_session)
|
71
|
+
built.should be_instance_of(klass)
|
72
|
+
built.arguments.should == ['baz']
|
73
|
+
built.session.should == :a_session
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should correctly handle a command line with a bad command' do
|
77
|
+
built = klass.build_for('x qux', :session => :another_session)
|
78
|
+
built.should == nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
37
82
|
end
|
@@ -1,72 +1,82 @@
|
|
1
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_add")
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_remove")
|
2
5
|
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_set")
|
3
|
-
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/
|
6
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_unset")
|
7
|
+
require File.expand_path("#{File.dirname __FILE__}/../../../../../lib/htty/cli/commands/query_unset_all")
|
4
8
|
|
5
9
|
describe HTTY::CLI::Commands::QuerySet do
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
describe 'class' do
|
11
|
+
let :klass do
|
12
|
+
subject.class
|
13
|
+
end
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
query_set = create_query_set_and_perform('test')
|
13
|
-
query_set.session.requests.last.uri.query.should == 'test'
|
15
|
+
it 'should be an alias_for the expected command' do
|
16
|
+
klass.alias_for.should == nil
|
14
17
|
end
|
15
|
-
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
query_set = create_query_set_and_perform('test', 'true')
|
20
|
-
query_set.session.requests.last.uri.query.should == 'test=true'
|
19
|
+
it 'should have the expected aliases' do
|
20
|
+
klass.aliases.should == []
|
21
21
|
end
|
22
|
-
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
query_set = create_query_set_and_perform('test', 'true', 'more')
|
27
|
-
query_set.session.requests.last.uri.query.should == 'test=true&more'
|
23
|
+
it 'should belong to the expected category' do
|
24
|
+
klass.category.should == 'Navigation'
|
28
25
|
end
|
29
|
-
end
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
query_set = create_query_set_and_perform('test', 'true', 'more', 'false')
|
34
|
-
query_set.session.requests.last.uri.query.should == 'test=true&more=false'
|
27
|
+
it 'should have the expected command_line' do
|
28
|
+
klass.command_line.should == 'query-s[et]'
|
35
29
|
end
|
36
|
-
end
|
37
30
|
|
38
|
-
|
39
|
-
|
40
|
-
@session.requests.last.uri.query = 'test=true'
|
41
|
-
query_set = create_query_set_and_perform('test', 'false')
|
42
|
-
query_set.session.requests.last.uri.query.should == 'test=false'
|
31
|
+
it 'should have the expected command_line_arguments' do
|
32
|
+
klass.command_line_arguments.should == 'NAME [VALUE [NAME [VALUE ...]]]'
|
43
33
|
end
|
44
34
|
|
45
|
-
it 'should
|
46
|
-
|
47
|
-
|
48
|
-
query_set.session.requests.last.uri.query.should == 'test=false&more=true'
|
35
|
+
it 'should have the expected help' do
|
36
|
+
klass.help.should == "Sets query-string parameters in the request's " +
|
37
|
+
'address'
|
49
38
|
end
|
50
39
|
|
51
|
-
it 'should
|
52
|
-
|
53
|
-
|
54
|
-
|
40
|
+
it 'should have the expected help_extended' do
|
41
|
+
expected = <<-end_help_extended
|
42
|
+
Sets one or more query-string parameters used for the request. Does not communicate with the host.
|
43
|
+
|
44
|
+
The difference between this command and \e[1mquery-a[dd]\e[0m is that this command replaces any duplicate parameters instead of adding more.
|
45
|
+
|
46
|
+
The name(s) and value(s) of the query-string parameter(s) will be URL-encoded if necessary.
|
47
|
+
|
48
|
+
The console prompt shows the address for the current request.
|
49
|
+
end_help_extended
|
50
|
+
klass.help_extended.should == expected.chomp
|
55
51
|
end
|
56
52
|
|
57
|
-
it 'should
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
it 'should have the expected see_also_commands' do
|
54
|
+
klass.see_also_commands.should == [HTTY::CLI::Commands::QueryUnset,
|
55
|
+
HTTY::CLI::Commands::QueryUnsetAll,
|
56
|
+
HTTY::CLI::Commands::QueryAdd,
|
57
|
+
HTTY::CLI::Commands::QueryRemove,
|
58
|
+
HTTY::CLI::Commands::Address]
|
62
59
|
end
|
63
|
-
end
|
64
60
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
61
|
+
describe 'build_for' do
|
62
|
+
it 'should correctly handle a valid, unabbreviated command line' do
|
63
|
+
built = klass.build_for('query-set foo bar', :session => :the_session)
|
64
|
+
built.should be_instance_of(klass)
|
65
|
+
built.arguments.should == %w(foo bar)
|
66
|
+
built.session.should == :the_session
|
67
|
+
end
|
71
68
|
|
69
|
+
it 'should correctly handle a valid, abbreviated command line' do
|
70
|
+
built = klass.build_for('query-s baz', :session => :a_session)
|
71
|
+
built.should be_instance_of(klass)
|
72
|
+
built.arguments.should == ['baz']
|
73
|
+
built.session.should == :a_session
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should correctly handle a command line with a bad command' do
|
77
|
+
built = klass.build_for('x qux', :session => :another_session)
|
78
|
+
built.should == nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
72
82
|
end
|