Skip to content

Instantly share code, notes, and snippets.

@deepak
Created October 2, 2012 14:08
Show Gist options
  • Select an option

  • Save deepak/3819422 to your computer and use it in GitHub Desktop.

Select an option

Save deepak/3819422 to your computer and use it in GitHub Desktop.
tag on shared_example by explicitly passing the tag name
# fork of https://gist.github.com/3792621
# as per https://github.com/rspec/rspec-core/issues/692#issuecomment-8939172
# tag filtering does not work it_behaves_like (shared examples)
# the solution is to put the tag on the actual it block. ie use wip rather than derp tag
class Foo
def one
end
def two
one
end
end
require 'rspec'
require 'debugger'
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.order = "random"
end
shared_examples_for "something" do |tag|
it "should have some property", tag do
puts "== [2] actual shared example"
Foo.any_instance.should_receive(:one)
foo.two
end
end
describe Foo do
it_behaves_like "something", :derp do
puts "== [1] calling shared example"
let(:foo) { Foo.new }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment