No commit activity in last 3 years
No release in over 3 years
rspec-subject-extensions let's you use short-hands to generate nested examples groups
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.4
~> 0.4
~> 1.2
~> 1.0
~> 1.5
~> 0.9
~> 0.5
~> 0.8

Runtime

>= 0.5.0
>= 2.6.0
 Project Readme

RSpec Subject Extensions build status

rspec-subject-extensions adds each short-hand to generate a nested example group with a single example that specifies the expected value of each attribute of the subject. If no attribute is given, each element of the subject will be used.

Documentation

The Cucumber features are the most comprehensive and up-to-date docs for end-users.

The RDoc provides additional information for contributors and/or extenders.

All of the documentation is open source and a work in progress. If you find it lacking or confusing, you can help improve it by submitting requests and patches to the rspec-subject-extensions issue tracker.

Install

gem install rspec-subject-extensions

Requirements

rspec ~> 3.0
i18n >= 0.5.0
activesupport >= 3.0

Usage

Each

Using the singular name of the attributes

Creates a nested example group named by each and the submitted attribute, and then generates an example for each attribute using the submitted block.

# This ...
describe User do
  each(:address) { is_expected.to be_an Address }
end

# ... generates the same runtime structure as this:
describe User do
  describe "each address"
    it "is an Address" do
      subject.addresses.each do |address|
        expect(address).to be_an Address
      end
    end
  end
end

The attribute can be a Symbol or a String.

Using no attribute (ideal for testing scopes)

Creates a nested example group and then generates an example for each instance using the submitted block.

# This ...
describe User do
  subject { User.active }
  each { is_expected.to be_active }
end

# ... generates the same runtime structure as this:
describe User do
  describe "each instance" do
    it "is active" do
      subject.each do |user|
        expect(user).to be_active
      end
    end
  end
end

Also see

License

MIT License. Copyright 2011-2014 Sébastien Grosjean, sponsored by BookingSync, Vacation Rental's Booking Calendar Software