GitXplorerGitXplorer
Z

rspec-subject-extensions

public
7 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
9c58d174300d1ece66b94bda48e92205cb4f89ac

Merge pull request #2 from grk/remove-i18n-dep

ZZenCocoon committed 10 years ago
Unverified
f41e6c010d3dec74caaa13af45cd7cee3e16baf7

Don't explicitly depend on i18n version

ggrk committed 10 years ago
Unverified
271a9b5e0008f3cb1737933999e68f300a70a464

Bump version to 1.0.0 [ci skip]

ZZenCocoon committed 10 years ago
Unverified
2efd8240e538f9f938ee40fd753dccb4dd22f142

Add support for RSpec 3.1

ZZenCocoon committed 10 years ago
Unverified
f0406474f2edf271b3428717f0a13a972ef7ec1c

Upgrade to RSpec 3.0+ support and drop previous versions

ZZenCocoon committed 11 years ago
Unverified
43bab654634fc1f10b07f92c05ef2fd508d66aea

Fix travis config

ZZenCocoon committed 11 years ago

README

The README file for this repository.

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