0.0
No commit activity in last 3 years
No release in over 3 years
add 'acton' and some useful methods for rspec one-liner syntax.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Rspec::DoAction

Build Status Code Climate Test Coverage Dependency Status Gem Version

add 'acton' and some useful methods for rspec one-liner syntax.

Installation

Add this line to your application's Gemfile:

gem 'rspec-do_action'

Usage

describe "invoke 'do_action' automatically" do
  subject(:result) { [] }
  action { result << 2 } # will invoke after all before hook run finished
  before { result << 1 }
  it { should eq [ 1, 2 ] }
end

describe "explicit invoke 'do_action'" do
  subject(:result) { [] }
  action { result << 2 }
  before { result << 1 }
  do_action
  before { result << 3 }

  it { should eq [ 1, 2, 3 ] }
end

describe "skip auto 'do_action' invoke" do
  action(skip: true) { raise RuntimeError }
  it { expect{ do_action }.to raise_error(RuntimeError) }
end

describe "skip auto 'do_action' invoke" do
  action { raise RuntimeError }
  skip_do_action

  it { expect{ do_action }.to raise_error(RuntimeError) }
end

describe 'action with metadata', foo: 1 do
  action { |example| expect(example.metadata[:foo]).to eq 1; @result = true }
  it { expect(@result).to eq true }
end

Contributing

  1. Fork it ( http://github.com/sunteya/rspec-do_action/fork )
  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