Project

conjurer

0.0
No commit activity in last 3 years
No release in over 3 years
RSpec Plugin For Preloading
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
>= 0

Runtime

~> 2.10
 Project Readme

Conjurer

Simple plug-in for RSpec that allows for explicit pre-loading of let.

This allows for the general elimination of let! while providing a more semantic alternative. See my post The Bang is for Surprise for more details.

Installation

Add this line to your application's Gemfile:

group :test do
  gem 'conjurer'
end

And then execute:

$ bundle

Or install it yourself as:

$ gem install conjurer

Usage

If using Rails, the gem should automatically be loaded. Otherwise, just add the following to your spec_helper:

require 'conjurer'

You can also use Bundler.setup for any other auto loading.

You can use the preload or more mystical conjur methods in your RSpec example groups. These methods are simply aliases of each other:

describe "Loading barewords" do

  context "preloading works with `let`" do
    subject(:array) { [1, 2, 3] }
    let(:popped) { array.pop }

    conjur :popped

    it { expect(array).to eq [1, 2] }

    it { expect(popped).to eq 3 }
  end

  context "preloading works on methods" do
    subject(:array) { [] }

    def some_data
      array << [1, 2]
    end

    preload :some_data

    it { expect(array).to eq [1, 2] }
  end

end

Contributing

  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