-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remember command's optoins #60
Conversation
"set_params" is a confusing subcommand name. How about instead:
|
I have made changes. Now you can review please. |
self.class.display | ||
end | ||
|
||
desc 'server:set HOST [PORT] [PROTO] [INSECURE]', "saves connection info" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description does not match the implementation. The options in the description are all positional, but as you havr defined the thor task, they need to be passed with flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...Options should be with flags, or without?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine either with flags or without.
The problem is that method_option
in thor uses flags ( tddium server:set --host HOST [--port PORT] [--proto PROTO] [--insecure]
) but the description on line 11 says that the command takes positional parameters without any flags (tddium server:set HOST [PORT] [PROTO] [INSECURE]
).
What happens when you run:
bin/tddium server:set foo.example.com 2345 https false
I'm pretty sure it won't actually save any settings, because options will be empty.
Needs a test for the server and server commands themselves. |
@@ -270,6 +272,8 @@ module Process | |||
Extract details of a session with `tddium describe <session_id>`. | |||
|
|||
EOF | |||
OPTIONS_SAVED = 'Options have been successfully saved.' | |||
NOT_SAVED_OPTIONS = 'You do not have file with options. Run `tddium server:add`.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "tddium server:set" ?
added tests for server commands |
let(:options){ {host: 'localhost', port: 3000, proto: 'http', insecure: true} } | ||
|
||
it 'stores options and returns successfully message' do | ||
subject.stub('server:set').with(options).and_return(self.class::Text::Process::OPTIONS_SAVED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think is actually testing anything.
(that is: if you were to change the code in cli/commands/server.rb to be broken, this test would still pass)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I have also test in spec/params_helper_spec.rb. I forgot to change file name and also there is one extra line in code(I will remove it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with removing the test is that there's then nothing that actually validates the end-to-end functionality of setting the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Now I just need to add additional tests for ParamsHelper module (lib/tddium/cli/params_helper.rb)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test for params_helper is not sufficient.
There needs to be a test that calls
Tddium::TddiumCli.send("server:set", options)
And checks either that write_params
was called, or that the setting file was actually written out.
Changed tests. Please check. |
end | ||
rescue Errno::ENOENT => e | ||
# when was called from class 'TddiumCli', return {} to use default options | ||
if caller[1][/`([^']*)'/, 1] == '<class:TddiumCli>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to test to see if Default::PARAMS_PATH exists with File.exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I will also test presence of PARAMS_PATH constant
2014-08-05 21:14 GMT+03:00 wkj notifications@github.com:
In lib/tddium/cli/params_helper.rb:
@@ -0,0 +1,40 @@
+# Copyright (c) 2014 Solano Labs All Rights Reserved
+
+module ParamsHelper
- include TddiumConstant
- def load_params
- begin
File.open(Default::PARAMS_PATH, 'r') do |file|
return JSON.parse file.read
end
- rescue Errno::ENOENT => e
# when was called from class 'TddiumCli', return {} to use default options
if caller[1][/`([^']*)'/, 1] == 'class:TddiumCli'
Is it better to test to see if Default::PARAMS_PATH exists with
File.exists?—
Reply to this email directly or view it on GitHub
https://github.com/solanolabs/tddium/pull/60/files#r15830829.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think William is using "test" in the sense of "checking the condition" in the code itself.
i.e, instead of rescuing Errno::ENOENT, to use File.exists? explicity:
if File.exists?(Default::PARAMS_PATH) then
JSON.parse(File.read(Default::PARAMS_PATH))
else
nil
end
Have made changes. Please check. |
08e40cb
to
4443f61
Compare
server whitch displays saved options; server:set whitch save options in an file;
4443f61
to
ff51c86
Compare
Store options in file in home folder.
Use just '.tddium' file, because when I save options and then user enter command without them I can't guess from what host use config file (e.x. '.tddium' or '.tddium.localhost').
https://bugs.tddium.com/bugzilla/show_bug.cgi?id=619