Permalink
Browse files

run share_examples_for examples against shared_examples and shared_co…

…ntext
  • Loading branch information...
dchelimsky committed Jun 4, 2012
1 parent 092a9c6 commit 4feeec6db1f532eb685426a6d07acf3cd615409f
Showing with 9 additions and 9 deletions.
  1. +9 −9 spec/rspec/core/shared_example_group_spec.rb
@@ -6,17 +6,17 @@ module RSpec::Core
ExampleModule = Module.new
ExampleClass = Class.new
- %w[share_examples_for shared_examples_for].each do |method_name|
- describe method_name do
+ %w[share_examples_for shared_examples_for shared_examples shared_context].each do |shared_method_name|
+ describe shared_method_name do
it "is exposed to the global namespace" do
- Kernel.should respond_to(method_name)
+ Kernel.should respond_to(shared_method_name)
end
it "raises an ArgumentError when adding a second shared example group with the same name" do
group = ExampleGroup.describe('example group')
- group.send(method_name, 'shared group') {}
+ group.send(shared_method_name, 'shared group') {}
lambda do
- group.send(method_name, 'shared group') {}
+ group.send(shared_method_name, 'shared group') {}
end.should raise_error(ArgumentError, "Shared example group 'shared group' already exists")
end
@@ -26,15 +26,15 @@ module RSpec::Core
it "captures the given #{type} and block in the World's collection of shared example groups" do
implementation = lambda {}
RSpec.world.shared_example_groups.should_receive(:[]=).with(object, implementation)
- send(method_name, object, &implementation)
+ send(shared_method_name, object, &implementation)
end
end
end
context "given a hash" do
it "delegates extend on configuration" do
implementation = Proc.new { def bar; 'bar'; end }
- send(method_name, :foo => :bar, &implementation)
+ send(shared_method_name, :foo => :bar, &implementation)
a = RSpec.configuration.include_or_extend_modules.first
a[0].should eq(:extend)
Class.new.extend(a[1]).new.bar.should eq('bar')
@@ -46,12 +46,12 @@ module RSpec::Core
it "captures the given string and block in the World's collection of shared example groups" do
implementation = lambda {}
RSpec.world.shared_example_groups.should_receive(:[]=).with("name", implementation)
- send(method_name, "name", :foo => :bar, &implementation)
+ send(shared_method_name, "name", :foo => :bar, &implementation)
end
it "delegates extend on configuration" do
implementation = Proc.new { def bar; 'bar'; end }
- send(method_name, "name", :foo => :bar, &implementation)
+ send(shared_method_name, "name", :foo => :bar, &implementation)
a = RSpec.configuration.include_or_extend_modules.first
a[0].should eq(:extend)
Class.new.extend(a[1]).new.bar.should eq('bar')

0 comments on commit 4feeec6

Please sign in to comment.