[rspec-devel] [ rspec-Bugs-10748 ] Shared descriptions in separate files causes 'already exists' error

noreply at rubyforge.org noreply at rubyforge.org
Thu May 10 13:54:42 EDT 2007


Bugs item #10748, was opened at 2007-05-10 10:54
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10748&group_id=797

Category: runner module
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Greg Spurrier (gregspurrier)
Assigned to: Nobody (None)
Summary: Shared descriptions in separate files causes 'already exists' error

Initial Comment:
There does not appear to be any protection against multiple inclusions of spec files.  This shows up when splitting out a shared description into its own file so that it can be included into multiple spec files.  The shared description file is then required into the other files and works as expected when spec is invoked on one such file.  If, however, spec is invoked on the directory or on all files in the directory (as the 'rake spec' task in rspec_on_rails does), an error results.

To reproduce, define the following files:

a_spec.rb
---------
describe "shared", :shared => true do
   it "should do something" do
   end
end

b_spec.rb
---------
require 'a_spec'

describe "not shared" do
   it_should_behave_like "shared"
end


Then run spec on *_spec.rb:

% spec -v
RSpec-0.9.3 (r1916) - BDD for Ruby
http://rspec.rubyforge.org/
% spec *_spec.rb
/usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/dsl/behaviour.rb:9:in `add_shared_behaviour': Shared Behaviour 'shared' already exists (ArgumentError)
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/runner/extensions/kernel.rb:16:in `register_behaviour'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/runner/extensions/kernel.rb:4:in `describe'
        from ./a_spec.rb:1
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
        from ./b_spec.rb:1
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/runner/behaviour_runner.rb:85:in `load_specs'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/runner/behaviour_runner.rb:84:in `load_specs'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/runner/behaviour_runner.rb:22:in `run'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/lib/spec/runner/command_line.rb:17:in `run'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-0.9.3/bin/spec:3
        from /usr/local/bin/spec:18





----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10748&group_id=797


More information about the rspec-devel mailing list