Cucumber helper to run rake tasks in the current process, capturing properties to assert tests against
Ruby Gherkin
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
features
lib
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
cucumber_rake_runner.gemspec

README.md

CucumberRakeRunner

Cucumber helper to run rake tasks in the current process, capturing properties to assert tests against

Installation

Step 1

Add this line to your application's Gemfile:

gem 'cucumber_rake_runner', require: false

And then execute:

$ bundle

Or install it yourself as:

$ gem install cucumber_rake_runner

Step 2

Add the following line to your cucumber environment file typically found at features\support\env.rb

require 'cucumber_rake_runner'

Problem

Sometimes there is a need to test your rake tasks. Typically this is done by a system call such as

@output = `rake some:amazing:task`

Sometimes this is desirable, at other times, in particular when using Jruby it is not. For each execution of the above a new JVM must spin up costing significant delays to test turnaround time.

The solution is to run the task inline to the cucumber process via Rake's invoke command. This gem provides a handy dandy solution to get the above functionality and more while running the rake task inline to the current process.

Usage

Simply incorportate the following call appropriately in your step definitions

@rake_output = run_rake_task(task_name, arg1, arg2, ... )

This will run the rake tasks with the specified parameters. If the rake task does not take parameters only the task_name is required.

The returned obect from this call is an OpenStruct with the following properties

  1. stdout - All output generated by the task sent to stdout
  2. stderr - All output generated by the task sent to stderr
  3. time - Time taken to execute rake task.

for example

@rake_output.stdout.include? 'Some expected output from task'

See the features and step definitions in this gem for example usage.

Contributing

Tests can be run via

cucumber

There are rake task definitions that the tests depend on. Please feel free to expand.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request