RSpec2 collides with Runt but why?

Hi,

A project of mine is using Runt expressions to match dates. When
upgraded my rake tasks to 2.5.1 (from 1.3.0) it get this

/usr/bin/ruby1.8 -S rspec spec/delivery_spec.rb spec/reporter_spec.rb
spec/mysql_dump_spec.rb spec/string_ext_spec.rb spec/
backup_configuration_spec.rb spec/postgres_dump_spec.rb spec/
system_command_spec.rb spec/archive_spec.rb spec/
configuration_dsl_spec.rb spec/mailer_spec.rb spec/backup_spec.rb spec/
intake/runt_spec.rb spec/intake/date_spec.rb
/var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/
configuration.rb:393: warning: toplevel constant VERSION referenced by
Runt::Spec::VERSION
/var/lib/gems/1.8/gems/diff-lcs-1.1.2/lib/diff/lcs.rb:16: Diff is not
a module (TypeError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /var/lib/gems/1.8/gems/rspec-expectations-2.5.0/lib/rspec/
expectations/differ.rb:1
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /var/lib/gems/1.8/gems/rspec-expectations-2.5.0/lib/rspec/
expectations.rb:9
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/expecting/
with_rspec.rb:1
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from /var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/
configuration.rb:173:in expectation_frameworks' from /var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/ configuration.rb:380:inconfigure_expectation_framework’
from /var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/
command_line.rb:20:in run' from /var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb: 55:inrun_in_process’
from /var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:
46:in run' from /var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb: 10:inautorun’
from /var/lib/gems/1.8/bin/rspec:19

So it seams that Runt::Spec collides with the old Spec namespace
checking code (there’s no VERSION constant in Runt::Spec) and the
Runt::Diff class in collides with the Diff module from diff-lcs. This
should not be the case as both Spec and Diff in Runt are namespaced
Runt.

I don’t really understand all the magic going on in RSpec but i
believe RSpec is to blame here. Am i right?

Cheers

Rob

I know why now. It was me to blame (of course). Error message about
the VERSION constant and the Diff is not a module could be more clear
though. There’s something strange going on in the Spec module check in
core/configuration.rb

I narrowed it down to a small example:

Given:
module MyModule
class Spec
# my spec implementation
end
class Diff
# my Diff implementation
end
end

When a spec includes the module like so:
require ‘my_module’
include MyModule

describe “collisions” do
it “collides with Diff class” do
1.should == 1
end
end

Then rspec spits out the errors:
/var/lib/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/
configuration.rb:393: warning: toplevel constant VERSION referenced by
MyModule::Spec::VERSION
and
/var/lib/gems/1.8/gems/diff-lcs-1.1.2/lib/diff/lcs.rb:16: Diff is not
a module

When an example group includes module like so:

require ‘my_module’

describe “collisions” do
include MyModule
it “collides with Diff class” do
1.should == 1
end
end

Then the spec runs without errors

When the example group is put in the same module like so:

require ‘my_module’

module MyModule
describe “collisions” do
it “collides with Diff class” do
1.should == 1
end
end
end

Then the spec runs without errors

So yep it was my fault. Sorry for blaming rspec. Apparently it is not
a good idea to include a module in the spec file outside of the
example groups.
What made me put the blame on rspec a few hours looking for clues in
rspecs error messages and code. Took me a while to narrow it down to
its essence.

Cheers
Rob