[rspec-users] autotest giving error when having shared example in specs

Amiruddin Nagri amir.nagri at gmail.com
Wed Sep 29 02:42:26 EDT 2010


I am having a shared example 'allow authorized actions' for my Rails 3 RSpec
2.beta.20 application. The shared example looks like

share_examples_for 'allow authorized actions' do
  ...
end

This shared example is in file
spec/controllers/support/authorization_shared_example.rb, which I am
requiring in spec_helper.rb. I am also using autotest to give me quick
feedback. Autotest is generating following command to run rspec

<path to
ruby>/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/bin/rspec <path
to rails root>/spec/controllers/support/authorization_shared_example.rb
<other spec files>

Since autotest is also including support file when running rspec, I am
getting following errors with autotest

/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/shared_example_group.rb:43:in
`ensure_shared_example_group_name_not_taken': Shared example group 'allow
authorized actions' already exists (ArgumentError)
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/shared_example_group.rb:6:in
`share_examples_for'
    from
/Users/arusarh/work/ece/carbonomist/spec/controllers/support/authorization_shared_example.rb:1:in
`<top (required)>'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:235:in
`load'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:235:in
`block in load'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:227:in
`load_dependency'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:235:in
`load'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/configuration.rb:302:in
`block in load_spec_files'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/configuration.rb:302:in
`map'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/configuration.rb:302:in
`load_spec_files'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/command_line.rb:18:in
`run'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/runner.rb:46:in
`run_in_process'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/runner.rb:37:in
`run'
    from
/Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/runner.rb:10:in
`block in autorun'


Any ideas how to not make autotest include shared example files loaded
through command line, but only include files with pattern "*_spec.rb", or
have anyone else facing same situation.

Regards,
Amiruddin Nagri,
Bangalore, 560008, KA
India

Y! IM : amir_nagri at yahoo.com
GTalk : amir.nagri at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100929/8fc0b5db/attachment.html>


More information about the rspec-users mailing list