performance testing

491 views
Skip to first unread message

Josh

unread,
Jan 10, 2011, 10:39:31 PM1/10/11
to Devise
I posted earlier on stackoverflow but there is very little traffic on
this subject: http://stackoverflow.com/questions/4653788/performance-testing-with-devise-authentication

So I thought I would re-ask the question here:

How can I run performance tests with devise (functional tests are
working). Using the Devise docs I have this in my test_helper.rb

class ActionController::TestCase
include Devise::TestHelpers
end

From http://stackoverflow.com/questions/4577737/functional-testing-with-rails-and-devise-what-to-put-in-my-fixtures,
I have this in my performance test:

require 'test_helper'
require 'rails/performance_test_help'

class EditorTest < ActionDispatch::PerformanceTest

def test_create

@user = users(:one)
sign_in @user

get 'documents/new/1'
end

end

I get the following error

NoMethodError: undefined method `sign_in' for #<EditorTest:
0xb6bc0654 ...>
/test/performance/editor_test.rb:9:in `test_create'

How do I properly include the Devise TestHelpers in a performance
test?

Thank you!

Carlos Antonio da Silva

unread,
Jan 10, 2011, 10:49:28 PM1/10/11
to plataforma...@googlegroups.com
Just include Devise::TestHelpers inside your EditorsTest and give it a try, although I'm not sure it'll work (have never tried).
To include in all performance tests:

class ActionDispatch::PerformanceTest
 include Devise::TestHelpers
end
--
At.
Carlos A. da Silva

Josh

unread,
Jan 10, 2011, 10:58:49 PM1/10/11
to Devise
Both suggestions result in:

NoMethodError: undefined method `env' for nil:NilClass

Has this worked for you in the past?

On 10 jan, 22:49, Carlos Antonio da Silva
<carlosantoniodasi...@gmail.com> wrote:
> Just include Devise::TestHelpers inside your EditorsTest and give it a try,
> although I'm not sure it'll work (have never tried).
> To include in all performance tests:
>
> class ActionDispatch::PerformanceTest
>  include Devise::TestHelpers
> end
>
>
>
>
>
>
>
>
>
> On Tue, Jan 11, 2011 at 1:39 AM, Josh <joshs.silver...@gmail.com> wrote:
> > I posted earlier on stackoverflow but there is very little traffic on
> > this subject:
> >http://stackoverflow.com/questions/4653788/performance-testing-with-d...
>
> > So I thought I would re-ask the question here:
>
> > How can I run performance tests with devise (functional tests are
> > working). Using the Devise docs I have this in my test_helper.rb
>
> > class ActionController::TestCase
> >  include Devise::TestHelpers
> > end
>
> > From
> >http://stackoverflow.com/questions/4577737/functional-testing-with-ra...
> > ,

Josh

unread,
Jan 10, 2011, 11:12:55 PM1/10/11
to Devise
end of the stack trace when i run this using ruby -d as opposed to
rake test:benchmark :

/usr/lib/ruby/gems/1.8/gems/devise-1.1.rc2/lib/devise/test_helpers.rb:
53: warning: instance variable @request not initialized
Exception `NoMethodError' at /usr/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/whiny_nil.rb:48 - undefined
method `env' for nil:NilClass
EEditorTest#test_create (0 ms warmup)
/usr/lib/ruby/gems/1.8/gems/devise-1.1.rc2/lib/devise/test_helpers.rb:
53: warning: instance variable @request not initialized
Exception `NoMethodError' at /usr/lib/ruby/gems/1.8/gems/
activesupport-3.0.3/lib/active_support/whiny_nil.rb:48 - undefined
method `env' for nil:NilClass
E process_time: 0 ms
Exception `Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File
exists - tmp/performance
Exception `Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File
exists - tmp/performance
Exception `Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File
exists - tmp/performance

Carlos Antonio da Silva

unread,
Jan 10, 2011, 11:35:14 PM1/10/11
to plataforma...@googlegroups.com
Nope, I wasn't expecting this to work, I haven't been using Rails performance tests for some time.
You'd have to take a look at how Devise setups TestHelpers within functional tests, and the differences between functional and performance setups in Rails, to see what you have to change to make it work on performance tests. I'm sorry but I can't help you on this from now.

Josh

unread,
Jan 10, 2011, 11:56:08 PM1/10/11
to Devise
Thanks anyway! I'd like to be able run performance tests on the app so
I will keep looking (although I'm going on 3 hours here :-).

On 10 jan, 23:35, Carlos Antonio da Silva

José Valim

unread,
Jan 11, 2011, 5:20:44 AM1/11/11
to Devise
I think PerformanceTest rather inherit from IntegrationTest than
AC::TestCase. That said, you should not use Devise::TestHelpers. You
need to sign in like you would in an integration test (i.e. filling in
the form). Please try this approach!

Josh

unread,
Jan 11, 2011, 9:13:19 PM1/11/11
to Devise
Thank you José!!!

Any reason why there isn't a test helper for PerformanceTest? On the
to-do list or is it by design?

Andrés Mejía

unread,
Jan 12, 2011, 3:57:49 AM1/12/11
to plataforma...@googlegroups.com
These are busy days. Feel free to contribute it yourself!
Reply all
Reply to author
Forward
0 new messages