I've converted a couple of my smaller libraries' spec suites to rspec 2 with no trouble. (I'm enjoying the new version -- thanks to all involved.) I'm trying to convert one a larger suite now and I've run into two problems on ruby 1.9.1 (but not 1.8.7) related to constant resolution in describes inside of modules. One of the problems haven't been able to reproduce in a simple test case, but the other one I have. Here's the reproducible one:
# ---- baz_spec.rb
module Foo
module Quux
class Baz
def name
"noise"
end
end
end
end
module Foo::Quux
describe Baz do
it "has a name" do
Baz.new.name.should == 'noise'
end
end
end
# ----
This spec passes on rspec 2.0.1 and 1.3.0 on Ruby 1.8.7:
----
$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10.4.0]
$ spec _1.3.0_ baz_spec.rb
.
Finished in 0.002011 seconds
1 example, 0 failures
$ rspec _2.0.1_ baz_spec.rb
.
Finished in 0.00077 seconds
1 example, 0 failures
----
It also passes on rspec 1.3.0 on Ruby 1.9.1. On rspec 2.0.1, it fails:
----
$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.3.0]
$ spec _1.3.0_ baz_spec.rb
.
Finished in 0.020187 seconds
1 example, 0 failures
$ rspec _2.0.1_ baz_spec.rb
F
Failures:
1) Foo::Quux::Baz has a name
Failure/Error: Baz.new.name.should == 'noise'
uninitialized constant RSpec::Core::ExampleGroup::Nested_1::Baz
# ./baz_spec.rb:14:in `block (2 levels) in <module:Quux>'
Finished in 0.00159 seconds
1 example, 1 failure
----
Is this a bug or expected behavior in rspec 2? I'll file an issue if it's a bug -- this would be against rspec-core, correct?
Thanks,
Rhett
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
On Nov 3, 4:49 pm, Rhett Sutphin <rh...@detailedbalance.net> wrote:
> Hi,
>
> I've converted a couple of my smaller libraries' spec suites to rspec 2 with no trouble. (I'm enjoying the new version -- thanks to all involved.) I'm trying to convert one a larger suite now and I've run into two problems on ruby 1.9.1 (but not 1.8.7) related to constant resolution in describes inside of modules. One of the problems haven't been able to reproduce in a simple test case, but the other one I have. Here's the reproducible one:
>
> # ---- baz_spec.rb
>
> module Foo
> module Quux
> class Baz
> def name
> "noise"
> end
> end
> end
> end
>
> module Foo::Quux
> describe Baz do
> it "has a name" do
> Baz.new.name.should == 'noise'
> end
> end
> end
>
> # ----
>
> This spec passes on rspec 2.0.1 and 1.3.0 on Ruby 1.8.7:
>
> ----
> $ ruby -v
> ruby1.8.7(2010-08-16 patchlevel 302) [i686-darwin10.4.0]
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
module Foo
module Quux
class Baz
def name
"noise"
end
end
end
end
describe Foo::Quux::Baz do
it "has a name" do
described_class.new.name.should == 'noise'
end
end