Speculator is a Ruby tool to generate RSpec tests automatically by tracing live/fixture code execution.
The general use case is that you have some code that works as expected within a Rails app or in some sort of integration test harness or fixture. Speculator will record the execution of that code up to any calls into classes you plan to stub and then produce a _spec file that calls your methods using the recorded parameters. Classes specified for stubbing will have stubs generated appropriately.
This is all at an early stage. Currently, the package is able to run a test harness in test/examples/run_example.rb and produce a spec for the test class test/examples/target.rb. It can also (using the --dogfood option) generate tests for selected classes/methods within the Speculator codebase.
- Integrate with Rails
- Provide a command line tool to specify testing for a class/method in a Rails web application
- Improve stub handling (for multiple congruent method calls, etc)
- Support use of FactoryGirl in mocking ActiveRecord
- Deal with non-determinacy (updated_at)
Add this line to your application's Gemfile:
gem 'speculator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install speculator
Run the test harness with:
bundle exec ruby test/examples/run_example.rb [method] [--all] [--dogfood]
method is a method name on Target (test/examples/target.tb)
--all generates tests on all methods
--dogfood generates test for internal code
Run the generated example tests with:
bundle exec rspec test/examples/gen_specs
Run the internal dogfood tests with:
bundle exec rspec test/gen_specs
TODO: Write proper usage instructions here
- Fork it ( http://github.com/richdrich/speculator/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
gem uninstall speculator
mail [email protected] <
How can you even try and make such a thing? Tests should be written before examples, do you here.
Considered Harmful! Go to the back of the class at once.
{browser} http://www.youtube.com/watch?v=gx4jn77VKlQ