This project is archived and is in readonly mode.

#3539 ✓resolved
Matthias Hennemeyer

Hidden mistake in new configuration_test

Reported by Matthias Hennemeyer | December 3rd, 2009 @ 01:20 PM

In railties/test/application/configuration_test.rb:53
a regex is passed as last argument to assert_raises. The last arg is intended to be the assertion message and not an expectation to the error message raised inside the applied block (like it would be expected with RSpec):

test "config.active_support.bare does not require all of ActiveSupport" do
  add_to_config "config.frameworks = []; config.active_support.bare = true"

  Dir.chdir("#{app_path}/app") do
    require "#{app_path}/config/environment"      #
    assert_raise(NoMethodError, /day/) { 1.day }  # <------
  end                                             #
end

This shows its buggyness only when run with classic test unit:

1) Error:
test_config.active_support.bare_does_not_require_all_of_ActiveSupport(ApplicationTests::InitializerTest):
ActiveSupport::Testing::RemoteError: caught TypeError: compared with non class/module

test/application/configuration_test.rb:53:in `block (2 levels) in <class:InitializerTest>'
test/application/configuration_test.rb:51:in `chdir'

The patch replaces the assertion:

assert_raises(NoMethodError, /day/) { 1.day }
with:
assert !1.methods.include?(:day), "Integer should not know #day."

Comments and changes to this ticket

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Tags

Pages