On Mar 16, 6:31 pm, Mattias Amnefelt <[email protected]> wrote:
> I can replicate this in all released versions rails3 using the test case
> below. I've tested it using both ruby 1.8.7 and 1.9.2. This is also a
> new behavior in rails 3 and I cannot replicate it with rails 2.3.11.
>
> What I can see with ruby-debug it's caused by to_s calling inspect on
> each Active Record object created in the earlier test. This seems
> unnecessary since it's not actually included in the final error message.
>

That is very curious. The slow part seems to be calling inspect on the
testcase object, which seems to go through a bunch of routes related
stuff, although I don't understand how or why that matters.

Fred

> Before I dig deeper, is this expected and known behavior or am I
> actually looking at a bug?
>
> The following is a test case which shows this behavior.
>
> =================
> # $ cat functional/foo_test.rb
> require 'test_helper'
>
> class FooTest < ActionController::TestCase
>    test "test a" do
>      p "Start of create"
>      (1..10000).each do |i|
>        Bar.create!
>      end
>      p "Done with create"
>    end
>
> #  def blahonga()
> #  end
>
>    test "test b" do
>      start = Time.now
>      p "Start of test"
>      begin
>        blahonga()
>      rescue Exception => e
>        p "Caught exception at time #{((Time.now - start)*1000000).to_i} us"
>        msg = e.to_s
>        p "ERROR #{msg} at time #{((Time.now - start)*1000000).to_i} us"
>      end
>      p "Done with exception handler at time #{((Time.now -
> start)*1000000).to_i} us"
>      p "Done with test"
>    end
> end
> =================
>
> Regards
> /mattiasa

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to