Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Hidden mistake in new configuration_test

#3539

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."

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

State: resolved
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Matthias Hennemeyer
  2. Matthias Hennemeyer
    Matthias Hennemeyer
    • Assigned user set to Jeremy Kemper

    This is resolved with commit adc2115132f22cbb772716c167f75346ab6d6c36 by Jeremy Kemper.

    December 9th, 2009 @ 09:45 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to resolved

    December 9th, 2009 @ 12:31 PM