Where can I find good examples of testing a Thor script with RSpec?
My searches have so far not turned up anything good.
Running tests by their file or directory names is the most familiar way to run tests with RSpec. RSpec can take a file name or directory name and run the file or the contents of the directory. So you can do: rspec spec/jobs to run the tests found in the jobs directory.
RSpec is a testing tool for Ruby, created for behavior-driven development (BDD). It is the most frequently used testing library for Ruby in production applications. Even though it has a very rich and powerful DSL (domain-specific language), at its core it is a simple tool which you can start using rather quickly.
Try out Thor's own repo at https://github.com/wycats/thor/tree/master/spec
I'm trying to do rspec tests for thor in my homedir project (in the homedir3 branch, at the moment). Look in the CLI_spec.rb file.
I don't claim they are the paragon of unit tests but it's something to look at.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With