Created
May 1, 2014 21:56
-
-
Save apeckham/0a3a84d0c9c8fd5d06b8 to your computer and use it in GitHub Desktop.
passing callables to shared examples in rspec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
shared_examples_for 'shared examples with proc' do |param1, param2| | |
it do | |
expect(param1).to eq param2.call | |
end | |
end | |
def true_method | |
true | |
end | |
describe 'test' do | |
it_behaves_like 'shared examples with proc', true, (-> { true }) | |
it_behaves_like 'shared examples with proc', true, (lambda { true }) | |
it_behaves_like 'shared examples with proc', true, (Proc.new { true }) | |
it_behaves_like 'shared examples with proc', true, method(:true_method) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment