Mike T
2011-Mar-28 03:04 UTC
[rspec-users] Can''t put shared example group in its own file
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* $ 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! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110327/0226d47b/attachment-0001.html>
Mike Tsao
2011-Mar-28 03:18 UTC
[rspec-users] Can''t put shared example group in its own file
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. [Sorry for the double post on Google Groups; didn''t realize at the time it was a read-only group.] $ 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 $ 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!
Mike Tsao
2011-Mar-29 02:29 UTC
[rspec-users] Can''t put shared example group in its own file
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. [Sorry for the double post on Google Groups; didn''t realize at the time it was a read-only group.] $ 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 $ 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!
David Chelimsky
2011-Mar-29 04:44 UTC
[rspec-users] Can''t put shared example group in its own file
On Mar 28, 2011, at 9:29 PM, Mike Tsao 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. [Sorry for the double post on Google Groups; > didn''t realize at the time it was a read-only group.] > > $ 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.rbDon''t name this file ^^ ending with _spec.rb - that is the default pattern that RSpec looks for specs in, so it''s getting loaded as a spec. Name it something like shared_examples_for_stuff.rb. HTH, David> > -- spec/support/stuff_spec.rb > shared_examples_for "bar" do > end > > $ 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!
Matt Wynne
2011-Apr-02 22:22 UTC
[rspec-users] Can''t put shared example group in its own file
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 > endI''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 at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-userscheers, Matt matt at mattwynne.net 07974 430184 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110402/f865cdd6/attachment-0001.html>