Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Now the both values are stored, but i.e. `controller` method, created an... #564

Merged
merged 2 commits into from

2 participants

Arkadiy Zabazhanov David Chelimsky
Arkadiy Zabazhanov

Now the both values are stored, but i.e. controller method, created an anonymouus controller in corresponding example group, redefines only :described_class, but later we try to get described_class it examples to instantiate anonymous controller and got :describes value. Described class chould be taken first.

Arkadiy Zabazhanov pyromaniac Now the both values are stored, but i.e. `controller` method, created…
… anonymouus controller in corresponding example group, redefines only :described_class, but later we try to get `described_class` it examples to instantiate anonymous controller and got :describes value. Described class chould be taken first.
ffeaf62
David Chelimsky
Owner

I'll be happy to merge this if you add a spec that fails with the code as it is today and passes with this change.

Arkadiy Zabazhanov

Ok, I'll do. But I should implement spec at rspec-rails )

David Chelimsky
Owner

No, spec goes here. The issue revealed itself to you in rspec-rails, but the problem is here. Just specify that pulling described_class and describes give you the same answer when either get redefined.

Arkadiy Zabazhanov

Ha! It was hard, but I did this. It is really stange case. The first call of described_class caches matadata values. And the second call return stange results. It was hard to catch ) But there is exatcly this behavior in rspec-rails controller example group controller method. And i've got it in my puffer specs ( Apply please.

Arkadiy Zabazhanov

@dchelimsky, would you apply this patch? Or forgot? )

David Chelimsky dchelimsky merged commit 8a6f77b into from
David Chelimsky dchelimsky referenced this pull request from a commit
David Chelimsky dchelimsky Changelog for #564 c6dc90b
George Ogata oggy referenced this pull request from a commit in oggy/rspec-core
George Ogata oggy Merge branch 'master' into retry-failures
* master: (24 commits)
  fix copy/paste oversight
  Don't process filters when the metadata doesn't even have the key.
  Changelog for #564
  Fix autotest when RSpec executable path contains spaces
  it was rescue false, not rescue nil
  Changelog for #556
  don't rescue from calling proc filters
  dev: need to include dev rspec in case dependent gems depend on rspec
  ci: it's gem, not rubygems
  ci: it's before_install (RTFM)
  ci: one more try ...
  ci: before_script doesn't run before bundling, so no way to run against ree for now
  ci: update rubygems if < 1.8 (needed for ZenTest in ree)
  simplify spec for #reset
  Spec for RSpec::Core::World#reset
  Changelog for prev commit
  doc formatter strips whitespace from group and example descriptions
  changelog
  Pluralization support for runtime duration output (minute).
  Added spec for patched case
  ...
1ce51ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 29, 2012
  1. Arkadiy Zabazhanov

    Now the both values are stored, but i.e. `controller` method, created…

    pyromaniac authored
    … anonymouus controller in corresponding example group, redefines only :described_class, but later we try to get `described_class` it examples to instantiate anonymous controller and got :describes value. Described class chould be taken first.
  2. Arkadiy Zabazhanov

    Added spec for patched case

    pyromaniac authored
This page is out of date. Refresh to see the latest.
2  lib/rspec/core/metadata.rb
View
@@ -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|
16 spec/rspec/core/example_group_spec.rb
View
@@ -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
Something went wrong with that request. Please try again.