davetron5000 / gli

Make awesome command-line applications the easy way
http://davetron5000.github.io/gli
Apache License 2.0
1.26k stars 102 forks source link

--version switch takes priority over default_command #252

Closed specious closed 6 years ago

specious commented 7 years ago

As mentioned in #206, --version switch should take priority over default_command.

davetron5000 commented 7 years ago

Can you add a test for this?

specious commented 7 years ago

@davetron5000, I would love to.

I'm relatively new to Ruby and I don't feel like I'm sufficiently familiar with testing in this environment. I looked at the Travis CI logs which clued me in that I should run:

bundle exec rake test features

That generated results.html which I enjoyed reading. I scrolled through the code in test/ and it looks like maybe tests for the functionality in question can be added to test/tc_help.rb since the version switch is currently implemented as part of 'help' functionality.

Any advice you could impart on me at this point would be of significant value.

davetron5000 commented 7 years ago

Yeah, there's two bits of tests for this. rake test will run unit tests and rake features will run integration tests. Those are specified using Cucumber (files in features/). Since this affects the user interface of a generated app, you probably want to write an integration test.

If you are new to Ruby and especially if you haven't seen Cucumber, it's pretty gnarly.

You could also test this as a unit test as you describe.

specious commented 7 years ago

I added a feature test in features/todo.feature, which passes with the change made in 19eacdf9ee6d81918cc72600e42e23e03568e348 but not without. For the record, the command to run the integration tests is:

bundle exec rake features

And not:

rake features
specious commented 6 years ago

@davetron5000, could you take another look at this?

davetron5000 commented 6 years ago

So sorry to lose track of this. It looks good. Will merge and release today