Skip to content
Browse files

Merge pull request #564 from pyromaniac/patch-1

Prefer described_class over describes
  • Loading branch information...
2 parents 49ea20b + a4c33a5 commit 8a6f77b93ffcf23e17a37be88ed11c88ada146c4 @dchelimsky dchelimsky committed
Showing with 17 additions and 1 deletion.
  1. +1 −1 lib/rspec/core/metadata.rb
  2. +16 −0 spec/rspec/core/example_group_spec.rb
View
2 lib/rspec/core/metadata.rb
@@ -102,8 +102,8 @@ module GroupMetadataHash
def described_class
container_stack.each do |g|
- return g[:describes] if g.has_key?(:describes)
return g[:described_class] if g.has_key?(:described_class)
+ return g[:describes] if g.has_key?(:describes)
end
container_stack.reverse.each do |g|
View
16 spec/rspec/core/example_group_spec.rb
@@ -293,6 +293,22 @@ def metadata_hash(*args)
group.run.should be_true
end
end
+
+ context "and metadata redefinition after `described_class` call" do
+ it "is the redefined level constant" do
+ group = ExampleGroup.describe(String) do
+ described_class
+ metadata[:example_group][:described_class] = Object
+ describe :symbol do
+ example "described_class is Object" do
+ described_class.should eq(Object)
+ end
+ end
+ end
+
+ group.run.should be_true
+ end
+ end
end
context "in a nested group" do

0 comments on commit 8a6f77b

Please sign in to comment.
Something went wrong with that request. Please try again.