razor-client 0.15.1 → 0.16.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.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/NEWS.md +22 -0
  3. data/bin/razor +24 -0
  4. data/lib/razor/cli/command.rb +139 -0
  5. data/lib/razor/cli/document.rb +8 -4
  6. data/lib/razor/cli/format.rb +46 -22
  7. data/lib/razor/cli/navigate.rb +27 -149
  8. data/lib/razor/cli/parse.rb +21 -5
  9. data/lib/razor/cli/query.rb +68 -0
  10. data/lib/razor/cli/table_format.rb +41 -0
  11. data/lib/razor/cli/transforms.rb +18 -0
  12. data/lib/razor/cli/version.rb +1 -1
  13. data/lib/razor/cli/views.yaml +38 -0
  14. data/lib/razor/cli.rb +5 -2
  15. data/spec/cli/format_spec.rb +95 -5
  16. data/spec/cli/navigate_spec.rb +49 -5
  17. data/spec/cli/parse_spec.rb +21 -0
  18. data/spec/fixtures/vcr/Razor_CLI_Navigate/argument_formatting/should_allow_in_string.yml +322 -0
  19. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--api_command_--help_.yml +110 -0
  20. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--api_command_help_.yml +110 -0
  21. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--api_help_command_.yml +110 -0
  22. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_--help_--api_command_.yml +110 -0
  23. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_-a_-h_command_.yml +110 -0
  24. data/spec/fixtures/vcr/Razor_CLI_Navigate/for_command_help/should_provide_API_command_help_for_razor_-a_command_-h_.yml +110 -0
  25. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_construct_a_json_object.yml +181 -49
  26. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_construct_a_json_object_with_unicode.yml +121 -46
  27. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_fail_with_mixed_types_array_then_hash_.yml +68 -65
  28. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_fail_with_mixed_types_hash_then_array_.yml +177 -45
  29. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_append_limit.yml +69 -0
  30. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_append_start.yml +69 -0
  31. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_not_fail_when_query_returns_details_for_one_item.yml +421 -0
  32. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_store_query_without_query_parameters.yml +773 -0
  33. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_throw_an_error_if_the_query_parameter_is_not_in_the_API.yml +36 -0
  34. data/spec/fixtures/vcr/Razor_CLI_Navigate/with_query_parameters/should_throw_an_error_if_the_query_parameter_is_not_in_the_API_from_a_single_item.yml +388 -0
  35. metadata +94 -82
@@ -18,12 +18,12 @@ module Razor::CLI
18
18
  @dump = true
19
19
  end
20
20
 
21
- opts.on "-f", "--full", "Show full details when viewing entities" do
22
- @format = 'full'
21
+ opts.on "-a", "--api", "Show API help for a command" do
22
+ @api_help = true
23
23
  end
24
24
 
25
- opts.on "-s", "--short", "Show shortened details when viewing entities" do
26
- @format = 'short'
25
+ opts.on "-k", "--insecure", "Allow SSL connections without verified certificates" do
26
+ @verify_ssl = false
27
27
  end
28
28
 
29
29
  opts.on "-u", "--url URL",
@@ -93,6 +93,10 @@ ERR
93
93
  !!@show_version
94
94
  end
95
95
 
96
+ def show_api_help?
97
+ !!@api_help
98
+ end
99
+
96
100
  def show_help?
97
101
  !!@option_help
98
102
  end
@@ -105,12 +109,21 @@ ERR
105
109
  !!@dump
106
110
  end
107
111
 
108
- attr_reader :api_url, :format, :args
112
+ def verify_ssl?
113
+ !!@verify_ssl
114
+ end
115
+
116
+ attr_reader :api_url, :args
117
+ # The format can be determined from later segments.
118
+ attr_accessor :format, :stripped_args
109
119
 
110
120
  def initialize(args)
111
121
  parse_and_set_api_url(ENV["RAZOR_API"] || DEFAULT_RAZOR_API, :env)
112
122
  @args = args.dup
123
+ # To be populated externally.
124
+ @stripped_args = []
113
125
  @format = 'short'
126
+ @verify_ssl = true
114
127
  @args = get_optparse.order(@args)
115
128
  @args = set_help_vars(@args)
116
129
  if @args == ['version'] or @show_version
@@ -150,6 +163,9 @@ ERR
150
163
  private
151
164
  def parse_and_set_api_url(url, source)
152
165
  begin
166
+ unless url.start_with?('http:') or url.start_with?('https:')
167
+ raise Razor::CLI::InvalidURIError.new(url, source)
168
+ end
153
169
  @api_url = URI.parse(url)
154
170
  rescue URI::InvalidURIError => e
155
171
  raise Razor::CLI::InvalidURIError.new(url, source)
@@ -0,0 +1,68 @@
1
+ class Razor::CLI::Query
2
+ def initialize(parse, navigate, collections, segments)
3
+ @parse = parse
4
+ @navigate = navigate
5
+ @collections = collections
6
+ @segments = segments
7
+ @stripped_segments = []
8
+ @options = {}
9
+ end
10
+
11
+ def stripped_segments
12
+ @stripped_segments.join
13
+ end
14
+
15
+ def get_optparse(doc, nav)
16
+ # If the last document is an Array, we need to find
17
+ # which element matches the given query. Once found,
18
+ # return the 'params' section, if it has one.
19
+ if doc.is_a?(Array)
20
+ query = doc.find {|coll| coll['name'] == nav}
21
+ params = (query && query['params']) || {}
22
+ elsif doc.is_a?(Hash)
23
+ params = (doc[nav] && doc[nav]['params']) || {}
24
+ end
25
+ @queryoptparse = OptionParser.new do |opts|
26
+ opts.on "-f", "--full", "Show full details when viewing entities" do
27
+ @parse.format = 'full'
28
+ end
29
+
30
+ opts.on "-s", "--short", "Show shortened details when viewing entities" do
31
+ @parse.format = 'short'
32
+ end
33
+
34
+ params.each do |param, args|
35
+ if args['type'] == 'boolean'
36
+ opts.on "--#{param}" do
37
+ @options[param] = true
38
+ end
39
+ else
40
+ opts.on "--#{param} VALUE" do |value|
41
+ @options[param] = value
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def run
49
+ @doc = @collections
50
+ while @segments.any?
51
+ nav = @segments.shift
52
+ @parse.stripped_args << nav
53
+ @segments = get_optparse(@doc, nav).order(@segments)
54
+ @doc = @navigate.move_to nav, @doc, @options
55
+ end
56
+
57
+ # Get the next level if it's a list of objects.
58
+ if @doc.is_a?(Hash) and @doc['items'].is_a?(Array)
59
+ # Cache doc_resource since these queries are just for extra detail.
60
+ temp_doc_resource = @navigate.doc_resource
61
+ @doc['items'] = @doc['items'].map do |item|
62
+ item.is_a?(Hash) && item.has_key?('id') ? @navigate.json_get(URI.parse(item['id'])) : item
63
+ end
64
+ @navigate.doc_resource = temp_doc_resource
65
+ end
66
+ @doc
67
+ end
68
+ end
@@ -0,0 +1,41 @@
1
+ require 'command_line_reporter'
2
+ class Razor::CLI::TableFormat
3
+ include CommandLineReporter
4
+
5
+ def run(doc, column_overrides)
6
+ suppress_output
7
+ table(:border => true, :encoding => :ascii) do
8
+ headings = (column_overrides or get_headers(doc))
9
+ row do
10
+ headings.each do |header|
11
+ column(header, :width => get_width(header, doc))
12
+ end
13
+ end
14
+ doc.each do |page|
15
+ row do
16
+ headings.each do |heading|
17
+ column(page[heading])
18
+ end
19
+ end
20
+ end
21
+ end
22
+ # Capturing stores the string, rather than printing to STDOUT (default).
23
+ capture_output.strip
24
+ end
25
+
26
+ def get_width(header, doc)
27
+ (doc.map do |page|
28
+ (page[header] or '').to_s.length
29
+ end << header.to_s.length).max
30
+ end
31
+
32
+ def get_headers(doc)
33
+ [].tap do |headers|
34
+ doc.map do |page|
35
+ page.map do |item|
36
+ headers << item[0] unless headers.include?(item[0])
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -26,6 +26,10 @@ module Razor::CLI
26
26
  def name(obj)
27
27
  obj ? obj['name'] : "---"
28
28
  end
29
+ def name_hide_nil(obj)
30
+ raise Razor::CLI::HideColumnError if obj.nil?
31
+ obj['name']
32
+ end
29
33
  def name_if_present(obj)
30
34
  obj ? obj['name'] : "---"
31
35
  end
@@ -38,5 +42,19 @@ module Razor::CLI
38
42
  def count_hash(hash)
39
43
  hash.is_a?(Hash) ? hash.keys.size : 0
40
44
  end
45
+ def event_msg(obj)
46
+ raise Razor::CLI::HideColumnError if obj['msg'].nil?
47
+ obj['msg'][0..50] + ('...' if obj['msg'].size > 50) if obj['msg']
48
+ end
49
+ def full_event_msg(obj)
50
+ raise Razor::CLI::HideColumnError if obj['msg'].nil?
51
+ obj['msg']
52
+ end
53
+ def event_entities(hash)
54
+ shallow_hash(Hash[hash].keep_if {|k,_| ['task', 'policy', 'broker', 'repo', 'node', 'command'].include?(k)})
55
+ end
56
+ def event_misc(hash)
57
+ shallow_hash(Hash[hash].delete_if {|k,_|['task', 'policy', 'broker', 'repo', 'node', 'msg', 'command'].include?(k)})
58
+ end
41
59
  end
42
60
  end
@@ -18,7 +18,7 @@ module Razor
18
18
  #
19
19
  # The next line is the one that our packaging tools modify, so please make
20
20
  # sure that any change to it is discussed and agreed first.
21
- version = '0.15.1'
21
+ version = '0.16.0'
22
22
 
23
23
  if version == "DEVELOPMENT"
24
24
  root = File.expand_path("../../..", File.dirname(__FILE__))
@@ -9,6 +9,7 @@
9
9
  # `+show`: This section configures which attributes are shown in the output.
10
10
  # `+layout`: This configures whether to use 'list' or 'table' output.
11
11
  # `+column`: This changes which column is used in the field formatting.
12
+ # `+format`: This references a method inside `transforms.rb` which will mutate the column's value.
12
13
  collections:
13
14
  brokers:
14
15
  +short:
@@ -194,3 +195,40 @@ collections:
194
195
  +format: count
195
196
  status:
196
197
  submitted_at:
198
+ events:
199
+ +short:
200
+ +layout: table
201
+ +show:
202
+ name:
203
+ timestamp:
204
+ message:
205
+ +column: entry
206
+ +format: event_msg
207
+ entities:
208
+ +column: entry
209
+ +format: event_entities
210
+ entry:
211
+ +column: entry
212
+ +format: event_misc
213
+ member:
214
+ +short:
215
+ +show:
216
+ name:
217
+ timestamp:
218
+ message:
219
+ +column: entry
220
+ +format: full_event_msg
221
+ broker:
222
+ +format: name_hide_nil
223
+ node:
224
+ +format: name_hide_nil
225
+ policy:
226
+ +format: name_hide_nil
227
+ repo:
228
+ +format: name_hide_nil
229
+ command:
230
+ +format: name_hide_nil
231
+ task:
232
+ +format: name_hide_nil
233
+ entry:
234
+ +format: event_misc
data/lib/razor/cli.rb CHANGED
@@ -19,7 +19,7 @@ module Razor
19
19
  when :env
20
20
  super "URL '#{url}' in ENV variable RAZOR_API is not valid"
21
21
  when :opts
22
- super "URL '#{url}' provided by -U or --url is not valid"
22
+ super "URL '#{url}' provided by -u or --url is not valid"
23
23
  else
24
24
  super "URL '#{url}' is not valid"
25
25
  end
@@ -39,6 +39,9 @@ require_relative 'cli/version'
39
39
  require_relative 'cli/navigate'
40
40
  require_relative 'cli/parse'
41
41
  require_relative 'cli/format'
42
+ require_relative 'cli/table_format'
42
43
  require_relative 'cli/document'
43
44
  require_relative 'cli/views'
44
- require_relative 'cli/transforms'
45
+ require_relative 'cli/transforms'
46
+ require_relative 'cli/query'
47
+ require_relative 'cli/command'
@@ -1,3 +1,4 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  # Needed to make the client work on Ruby 1.8.7
2
3
  unless Kernel.respond_to?(:require_relative)
3
4
  module Kernel
@@ -14,7 +15,8 @@ describe Razor::CLI::Format do
14
15
  include described_class
15
16
 
16
17
  def format(doc, args = {})
17
- args = {:format => 'short', :args => ['something', 'else'], :query? => true, :show_command_help? => false}.merge(args)
18
+ args = {:format => 'short', :stripped_args => ['something', 'else'], :query? => true, :show_command_help? => false,
19
+ :show_api_help? => false}.merge(args)
18
20
  parse = double(args)
19
21
  format_document doc, parse
20
22
  end
@@ -86,14 +88,102 @@ describe Razor::CLI::Format do
86
88
  "items"=>[{'a' => 'b', 'c' => 'd'},
87
89
  {'b' => 'c', 'e' => 'f'}]}
88
90
  result = format doc
89
- result.should == <<-OUTPUT.rstrip
91
+ result.should ==
92
+ # The framework seems to be adding unnecessary spaces at the end of each data line;
93
+ # Working around this by adding \s to the expectation.
94
+
95
+ # Unicode:
96
+ #┏━━━┳━━━┳━━━┳━━━┓
97
+ #┃ a ┃ c ┃ b ┃ e ┃\s
98
+ #┣━━━╊━━━╊━━━╊━━━┫
99
+ #┃ b ┃ d ┃ ┃ ┃\s
100
+ #┣━━━╊━━━╊━━━╊━━━┫
101
+ #┃ ┃ ┃ c ┃ f ┃\s
102
+ #┗━━━┻━━━┻━━━┻━━━┛
103
+ # ASCII:
104
+ <<-OUTPUT.rstrip
105
+ +---+---+---+---+
106
+ | a | c | b | e |\s
90
107
  +---+---+---+---+
91
- | a | c | b | e |
108
+ | b | d | | |\s
92
109
  +---+---+---+---+
93
- | b | d | | |
94
- | | | c | f |
110
+ | | | c | f |\s
95
111
  +---+---+---+---+
112
+ OUTPUT
113
+ end
114
+
115
+ it "works right with unicode" do
116
+ doc = {"spec"=>"http://api.puppetlabs.com/razor/v1/collections/nodes/log",
117
+ "items"=>[{'a' => 'ᓱᓴᓐ ᐊᒡᓗᒃᑲᖅ'}]}
118
+ result = format doc
119
+ result.should ==
120
+ # The framework seems to be adding unnecessary spaces at the end of each data line;
121
+ # Working around this by adding \s to the expectation.
122
+
123
+ # Unicode:
124
+ #┏━━━━━━━━━━━━┓
125
+ #┃ a ┃\s
126
+ #┣━━━━━━━━━━━━┫
127
+ #┃ ᓱᓴᓐ ᐊᒡᓗᒃᑲᖅ ┃\s
128
+ #┗━━━━━━━━━━━━┛
129
+ # ASCII:
130
+ <<-OUTPUT.rstrip
131
+ +------------+
132
+ | a |\s
133
+ +------------+
134
+ | ᓱᓴᓐ ᐊᒡᓗᒃᑲᖅ |\s
135
+ +------------+
96
136
  OUTPUT
97
137
  end
98
138
  end
139
+
140
+ context 'api help' do
141
+ it "displays the CLI help by default" do
142
+ doc = {"name"=>"some-help", "help" => {"summary"=>"summary here",
143
+ "examples"=>{"api"=>"api example is here", "cli"=>"cli example is here"},
144
+ "full" => "shouldn't show this"},
145
+ "schema" => {"name"=>{"type"=>"string"}}}
146
+ result = format doc, show_command_help?: true
147
+ result.should =~ /cli example is here/
148
+ end
149
+
150
+ it "displays the API help when the --api flag is true" do
151
+ doc = {"name"=>"some-help", "help" => {"summary"=>"summary here",
152
+ "examples"=>{"api"=>"api example is here", "cli"=>"cli example is here"},
153
+ "full" => "shouldn't show this"},
154
+ "schema" => {"name"=>{"type"=>"string"}}}
155
+ result = format doc, show_api_help?: true, show_command_help?: true
156
+ result.should =~ /api example is here/
157
+ end
158
+
159
+ it "displays the full help if on an older server" do
160
+ doc = {"name"=>"some-help", "help" => {"full" => "full help is here"},
161
+ "schema" => {"name"=>{"type"=>"string"}}}
162
+ result = format doc, show_command_help?: true
163
+ result.should =~ /full help is here/
164
+ end
165
+
166
+ it "displays the full help if on an older server and api is specified" do
167
+ doc = {"name"=>"some-help", "help" => {"full" => "full help is here"},
168
+ "schema" => {"name"=>{"type"=>"string"}}}
169
+ result = format doc, show_api_help?: true, show_command_help?: true
170
+ result.should =~ /full help is here/
171
+ end
172
+
173
+ it "skips the 'Examples' section if cli examples are not included" do
174
+ doc = {"name"=>"some-help", "help" => {"summary"=>"summary here",
175
+ "examples"=>{"api"=>"api example is here"},
176
+ "full" => "shouldn't show this"},
177
+ "schema" => {"name"=>{"type"=>"string"}}}
178
+ result = format doc, show_cli_help?: true, show_command_help?: true
179
+ result.should =~ /summary here/
180
+ result.should_not =~ /EXAMPLES/
181
+ end
182
+
183
+ it "errors if help does not exist" do
184
+ doc = {"name"=>"some-help", "schema" => {"name"=>{"type"=>"string"}}}
185
+ expect { format doc, show_cli_help?: true, show_command_help?: true }.
186
+ to raise_error(Razor::CLI::Error, /Could not find help for that entry/)
187
+ end
188
+ end
99
189
  end
@@ -38,7 +38,7 @@ describe Razor::CLI::Navigate do
38
38
  context "with invalid parameter", :vcr do
39
39
  it "should fail with bad JSON" do
40
40
  nav = Razor::CLI::Parse.new(['create-broker', '--name', 'broker', '--type', 'puppet', '--configuration', 'not-json']).navigate
41
- expect{nav.get_document}.to raise_error(ArgumentError, /Invalid JSON for argument 'configuration'/)
41
+ expect{nav.get_document}.to raise_error(ArgumentError, /Invalid object for argument 'configuration'/)
42
42
  end
43
43
 
44
44
  it "should fail with malformed argument" do
@@ -107,13 +107,13 @@ describe Razor::CLI::Navigate do
107
107
  nav = Razor::CLI::Parse.new(['create-broker', '--name', 'broker2', '--broker-type', 'puppet',
108
108
  '--configuration', '["server"]',
109
109
  '--configuration', 'environment=production']).navigate
110
- expect {nav.get_document}.to raise_error(ArgumentError, "Cannot handle mixed types for argument configuration")
110
+ expect {nav.get_document}.to raise_error(ArgumentError, "Invalid object for argument 'configuration'")
111
111
  end
112
112
  it "should fail with mixed types (hash then array)" do
113
113
  nav = Razor::CLI::Parse.new(['create-broker', '--name', 'broker3', '--broker-type', 'puppet',
114
114
  '--configuration', 'environment=production',
115
115
  '--configuration', '["server"]']).navigate
116
- expect {nav.get_document}.to raise_error(ArgumentError, "Cannot handle mixed types for argument configuration")
116
+ expect {nav.get_document}.to raise_error(ArgumentError, "Invalid object for argument 'configuration'")
117
117
  end
118
118
  end
119
119
  end
@@ -124,6 +124,10 @@ describe Razor::CLI::Navigate do
124
124
  Razor::CLI::Parse.new(['create-repo', '--name="double-quote with spaces"', '--url', 'http://url.com/some.iso', '--task', 'noop']).navigate.get_document
125
125
  Razor::CLI::Parse.new(['create-repo', '--name=\'single-quote with spaces\'', '--url', 'http://url.com/some.iso', '--task', 'noop']).navigate.get_document
126
126
  end
127
+
128
+ it "should allow '=' in string" do
129
+ Razor::CLI::Parse.new(['create-repo', '--name=\'with=equals\'', '--url', 'http://url.com/some.iso', '--task', 'noop']).navigate.get_document['name'].should =~ /with=equals/
130
+ end
127
131
  end
128
132
 
129
133
  context "for command help", :vcr do
@@ -149,13 +153,53 @@ describe Razor::CLI::Navigate do
149
153
  it "should supply that to the API service" do
150
154
  nav = Razor::CLI::Parse.new(AuthArg).navigate
151
155
  nav.get_document.should be_an_instance_of Hash
152
- URI.parse(nav.last_url.to_s).userinfo.should == "fred:dead"
156
+ nav.last_url.user.should == 'fred'
157
+ nav.last_url.password.should == 'dead'
153
158
  end
154
159
 
155
160
  it "should preserve that across navigation" do
156
161
  nav = Razor::CLI::Parse.new(AuthArg + ['tags']).navigate
157
162
  nav.get_document['items'].should == []
158
- URI.parse(nav.last_url.to_s).userinfo.should == "fred:dead"
163
+ nav.last_url.user.should == 'fred'
164
+ nav.last_url.password.should == 'dead'
165
+ end
166
+ end
167
+
168
+ context "with query parameters", :vcr do
169
+ it "should append limit" do
170
+ nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8080/api events --limit 1]).navigate
171
+ nav.get_document.should be_an_instance_of Hash
172
+ nav.last_url.to_s.should =~ /limit=1/
173
+ end
174
+ it "should append start" do
175
+ nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8080/api events --start 1]).navigate
176
+ nav.get_document.should be_an_instance_of Hash
177
+ nav.last_url.to_s.should =~ /start=1/
178
+ end
179
+ it "should throw an error if the query parameter is not in the API" do
180
+ nav = Razor::CLI::Parse.new(%w[-u http://fred:dead@localhost:8080/api events --not-in-api 1]).navigate
181
+ expect {nav.get_document}.to raise_error(OptionParser::InvalidOption, 'invalid option: --not-in-api')
182
+ end
183
+ it "should not fail when query returns details for one item" do
184
+ nav = Razor::CLI::Parse.new(['register-node', '--installed', 'true', '--hw-info', 'net0=78:31:c1:be:c8:00']).navigate.get_document
185
+ name = nav['name']
186
+ nav = Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8080/api', 'nodes', name]).navigate
187
+ nav.get_document['name'].should == name
188
+ end
189
+ it "should throw an error if the query parameter is not in the API from a single item" do
190
+ nav = Razor::CLI::Parse.new(['register-node', '--installed', 'true', '--hw-info', 'net0=78:31:c1:be:c8:00']).navigate.get_document
191
+ name = nav['name']
192
+ expect {Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8080/api', 'nodes', name, '--limit', '1']).
193
+ navigate.get_document}.to raise_error(OptionParser::InvalidOption, 'invalid option: --limit')
194
+ end
195
+ it "should store query without query parameters" do
196
+ name = Razor::CLI::Parse.new(['register-node', '--installed', 'true', '--hw-info', 'net0=78:31:c1:be:c8:00']).
197
+ navigate.get_document['name']
198
+ Razor::CLI::Parse.new(['register-node', '--installed', 'true', '--hw-info', 'net0=78:31:c1:be:c8:01']).
199
+ navigate.get_document
200
+ parse = Razor::CLI::Parse.new(['-u', 'http://fred:dead@localhost:8080/api', 'nodes', name, 'log', '--limit', '1'])
201
+ parse.navigate.get_document
202
+ parse.stripped_args.should == ['nodes', name, 'log']
159
203
  end
160
204
  end
161
205
  end