Rspec::Launchbox
Bundle of RSpec DSL helpers, providing timeout matchers, service runners. Work in progress.
Installation
Add this line to your application's Gemfile:
gem 'rspec-launchbox'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-launchbox
Usage
in_presence_of
#spec/spec_helper.rb
require 'rspec/launchbox'
RSpec.configure do |config|
#...
config.extend RSpec::InPresenceOf
config.include RSpec::Matchers::Timeout
end
include RSpec::DescribeExecutable
Then in spec file:
describe MyClass do
in_presence_of 'external_program' do
it 'should listen on port' do
#here goes expectation
end
end
end
describe_executable
describe_executable 'ls' do
its_stdout do
it { is_expected.to be_a String }
end
end
expect { }.to persist
expect do
#routine
end.to persist.at_least(3) # or 3.seconds if you use ActiveSupport
This snippet runs binary called external_program (should be in path, or pass absolute path), and makes sure process started by that command is dead.
TODO: One day there will be optional parameters e.g. signal to send to process.
Contributing
- Fork it ( https://github.com/[my-github-username]/rspec-launchbox/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 a new Pull Request