Hey everyone,

(I'm a newbie, so if I'm doing something wrong, please let me know! ^^)

I'm getting weird errors when I mix RSpec and Test::Unit tests.  Here is
how to reproduce it with Rails 3:

Run "rails new railsapp".  Add "gem 'rspec'" to the Gemfile, and create
test/unit/demo_test.rb with the following code:

require 'test_helper'
class FirstTest < ActiveSupport::TestCase
  test 'something' do
    assert_equal 42, 42
  end
end
class SecondTest < ActiveSupport::TestCase
  test 'something' do
    assert_equal 42, 42
  end
end

Run "bundle install; rake db:migrate; rake test".  The two tests pass.
Now add the following code to the end of test/unit/demo_test.rb:

describe 'this is an rspec test' do
end

Run "rake test" again, and it fails with the following errors message:

(in /home/jo/tmp/railsapp)
/var/lib/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/testing/declarative.rb:28:in
`test': test_something is already defined in FirstTest (RuntimeError)
  from /home/jo/tmp/railsapp/test/unit/demo_test.rb:4:in
`<class:FirstTest>'
  from /home/jo/tmp/railsapp/test/unit/demo_test.rb:3:in `<top
(required)>'
  from
/var/lib/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in
`load'
  from
/var/lib/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in
`block in load'
  from
/var/lib/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:227:in
`load_dependency'
  from
/var/lib/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in
`load'
  from
/var/lib/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in
`block in load_spec_files'
  from
/var/lib/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in
`map'
  from
/var/lib/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in
`load_spec_files'
  from
/var/lib/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:18:in
`run'
  from
/var/lib/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:55:in
`run_in_process'
  from
/var/lib/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:46:in
`run'
  from
/var/lib/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:10:in
`block in autorun'
Errors running test:units!

I googled for the error message and came up with
http://osdir.com/ml/RubyonRails:Core/2009-12/msg00084.html , which tells
me that since "FirstTest" and "SecondTest" have different class names,
there shouldn't be a problem.

Am I doing something wrong?

I'm not even sure whether this is a Test::Unit or RSpec problem, but
since RSpec seems to trigger it, I figured I'd post here...

Thanks,
Jo

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to