This project is archived and is in readonly mode.

#1776 ✓wontfix

Models Named Test* cause test failures

Reported by Chris | January 17th, 2009 @ 06:22 PM | in 2.x

We do A/B tests and multivariate testing in my rails app and so we have some models named Test*

This is causing some unfortunate testing errors:

$ rails -v Rails 2.1.1

$ rails foo $ cd foo $ ./script/generate model test_something $ rake db:migrate $ rake test

1) Error:

test_somethings(ActionController::TestCase): ArgumentError: wrong number of arguments (0 for 1)

  /Library/Ruby/Gems/1.8/gems/actionpack-2.1.1/lib/action_controller/test_case.rb:73:in `initialize'
  /Library/Ruby/Gems/1.8/gems/actionpack-2.1.1/lib/action_controller/test_case.rb:73:in `new'
  /Library/Ruby/Gems/1.8/gems/actionpack-2.1.1/lib/action_controller/test_case.rb:73:in `setup_controller_request_and_response'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:173:in `send'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:173:in `evaluate_method'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:161:in `call'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:90:in `run'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:90:in `each'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:90:in `send'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:90:in `run'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/callbacks.rb:272:in `run_callbacks'
  /Library/Ruby/Gems/1.8/gems/activesupport-2.1.1/lib/active_support/testing/setup_and_teardown.rb:65:in `run'

6 tests, 1 assertions, 0 failures, 1 errors

Comments and changes to this ticket

  • Matt Jones

    Matt Jones January 17th, 2009 @ 09:01 PM

    This is a gotcha with the fixture loading; if you remove test_somethings.yml from fixtures/ the test will pass.

    The conflict comes from the accessor method that AR generates; it would be test_somethings(:fixture_name) for this case. Unfortunately, then Test::Unit tries to run that function...

  • Michael Koziarski

    Michael Koziarski January 17th, 2009 @ 11:31 PM

    • State changed from “new” to “wontfix”

    This is an inherent limitation with test/unit. The fixture accessors are treated as test methods.

    The only option short of renaming all those models is to not use the fixtures as mentioned by matt.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket