Installing RSpec and Sinatra with Rake
Installing Rspec into Sinatra with Rake
This will give you a friendly ‘rails-like’ interface to running your automation tests.
Sinatra doesn’t come with any test harness by default and so you’ll find yourself needing to integrate something.
As a bonus I include a way to gain access to an instance of your sinatra module while the test is running. This allows you to do unit style testing on the Module object itself as it moves through the request life-cycle.
- Open the Gist GIST with complete instructions and files
- Update the Gemfile
- Update the Rakefile
- Create a .rspec file
- Follow the Instructions
Instructions
1 2 |
# run the bundle command
$ bundle |
1 2 3 |
# .rspec file
$ echo "--color" >> .rspec
$ echo "--backtrace" >> .rspec |
1 2 3 |
# .rspec file
$ echo "--color" >> .rspec
$ echo "--backtrace" >> .rspec |
1 2 3 4 5 6 7 |
# spec directory
$ mkdir spec
$ touch spec/spec_helper.rb
# Update spec/spec_helper.rb to match file in gist.
# mkdir spec/sample
$ touch spec/sample/instance_variable_spec.rb
# update spec/sample/instance_variable_spec.rb to match file in gist |