Project

rspec-loop

0.0
The project is in a healthy, maintained state
Run RSpec tests multiple times
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 13.0
~> 3.10.0
~> 1.21

Runtime

~> 3.10
 Project Readme

rspec-loop

Build Status

rspec-loop adds a :loop option to run rspec examples multiple times.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add rspec-loop --group test

If bundler is not being used to manage dependencies, install the gem by executing:

gem install rspec-loop

Configuration

Configure the options in your project's spec_helper.rb:

require "rspec/loop"

RSpec.configure do |config|
  config.default_loop_count = 5
end

Options

Name Description Type Default
default_loop_count How many iterations to run each test by default. Integer 3

Usage

To configure an individual test to run multiple times:

it "runs three times", loop: 3 do
  # test code here
end

To configure a group of examples to run multiple times:

describe "a group of tests", loop: 3 do
  it "runs three times" do
    # test code here
  end

  it "also runs three times" do
    # test code here
  end
end

Formatter

To use the included formatter, use RSpec's --format option:

rspec spec --format RSpec::Loop::Formatter

Or via a rake task:

RSpec::Core::RakeTask.new(:loop) do |t|
  t.rspec_opts = "--format RSpec::Loop::Formatter"
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake to run the tests and linter. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kcboschert/rspec-loop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the rspec-loop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.