Project

rspec-the

0.0
No commit activity in last 3 years
No release in over 3 years
Easily make assertions about the contents of your `let` blocks
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

 Project Readme

RSpec::The

Easily make assertions about the contents of your let blocks

Travis Status RubyGems Version

Installation

Add this line to your application's Gemfile:

gem 'rspec-the'

And then execute:

bundle install

Or install it yourself as:

gem install rspec-the

Usage

Using rspec-its to test your given subject works for simple method invocations, but requires excessive nesting in more complex scenarios.

describe Array do
  let(:array) { [1, 2, 3, 4, 5] }
  subject { array }

  its(:count) { is_expected.to eq 5 }
  its(:first) { is_expected.to eq 1 }

  describe 'select #even?' do
    subject { array.select(&:even?) }
    it { is_expected.to eq [2, 4] }
  end

  describe 'select #odd?' do
    subject { array.select(&:odd?) }
    it { is_expected.to eq [1, 3, 5] }
  end
end

Instead, rspec-the allows us to use let to define many pseudo-subject blocks which can easily be tested.

describe Array do
  subject { [1, 2, 3, 4, 5] }

  its(:count) { is_expected.to eq 5 }
  its(:first) { is_expected.to eq 1 }

  let(:evens) { subject.select(&:even?) }
  the(:evens) { are_expected.to eq [2, 4] }

  let(:odds) { subject.select(&:odd?) }
  the(:odds) { are_expected.to eq [1, 3, 5] }
end

See, isn't that easier?!?

Contributing

  1. Fork it ( https://github.com/jamesottaway/rspec-the/fork )
  2. Create your feature branch (git checkout -b $BRANCH_NAME)
  3. Commit your changes (git commit --all --message $COMMIT_MESSAGE)
  4. Push to the branch (git push $REMOTE $BRANCH_NAME)
  5. Create a new Pull Request ( https://github.com/jamesottaway/rspec-the/compare )