On 28 Mar 2011, at 04:04, Mike T wrote:

> Any ideas? All I'd like to do is have two specs in different files use the 
> same shared example group. I saw a similar thread about autotest, but I am 
> not using that.
> 
> $ uname -a
> Darwin mbp.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 
> 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386
> $ ruby -v
> ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
> $ rails -v
> Rails 3.0.5
> $ rails new shared
> $ cd shared/
> $ echo "gem 'rspec-rails', '~> 2.5'" >> Gemfile
> $ bundle --without production
> $ rails generate rspec:install
> $ rails generate scaffold foo
> $ rake db:migrate
> $ mkdir spec/support
> $ nano spec/support/stuff_spec.rb
> 
> -- spec/support/stuff_spec.rb 
> shared_examples_for "bar" do
> end

I'm sure David already replied about this - don't name your shared examples 
group *_spec.rb otherwise RSpec will load it and try to run it as a spec file.

> 
> $ rake spec
> (in /tmp/shared)
> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S bundle 
> exec rspec ./spec/controllers/foos_controller_spec.rb 
> ./spec/helpers/foos_helper_spec.rb ./spec/models/foo_spec.rb 
> ./spec/requests/foos_spec.rb ./spec/routing/foos_routing_spec.rb 
> ./spec/support/stuff_spec.rb ./spec/views/foos/edit.html.erb_spec.rb 
> ./spec/views/foos/index.html.erb_spec.rb 
> ./spec/views/foos/new.html.erb_spec.rb ./spec/views/foos/show.html.erb_spec.rb
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/shared_example_group.rb:45:in
>  `ensure_shared_example_group_name_not_taken': Shared example group 'bar' 
> already exists (ArgumentError)
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/shared_example_group.rb:6:in
>  `shared_examples_for'
>       from /private/tmp/shared/spec/support/stuff_spec.rb:1
>       from 
> /Library/Ruby/Gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in
>  `load'
>       from 
> /Library/Ruby/Gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in
>  `load'
>       from 
> /Library/Ruby/Gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:227:in
>  `load_dependency'
>       from 
> /Library/Ruby/Gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in
>  `load'
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in
>  `load_spec_files'
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in
>  `map'
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:386:in
>  `load_spec_files'
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/command_line.rb:18:in
>  `run'
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:55:in 
> `run_in_process'
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:46:in 
> `run'
>       from 
> /Library/Ruby/Gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/runner.rb:10:in 
> `autorun'
>       from /Library/Ruby/Gems/1.8/bin/rspec:19
> rake aborted!
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

cheers,
Matt

m...@mattwynne.net
07974 430184

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to