rack-oauth2-server icon indicating copy to clipboard operation
rack-oauth2-server copied to clipboard

Improve tests

Open mulderp opened this issue 12 years ago • 6 comments

Hi,

I wanted to ping whether there are needs to improve the tests for this project. Some issues/ideas:

  • add integration tests with e.g. cucumber or capybara
  • split test setups into different files
  • use helper scripts for different frameworks
  • make smaller tests/files
  • move to another test framework (?)

What do you think, am I missing something, or confusing?

Thanks for feedback evt.

Patrick

mulderp avatar Apr 01 '13 20:04 mulderp

What are the issues with the tests?

assaf avatar Apr 02 '13 04:04 assaf

I find running the tests not so easy, i.e. I was exploring how to make this project run with an SQL orm adapter (see https://github.com/mulderp/rack-oauth2-server/tree/active_record )

However, as far as I can see:

  1. It is difficult to run tests that would just concern the ORM adapter, the finest test granularity to run is e.g. with

    ruby -I . test/oauth/access_grant_test.rb -n "/using authorization code should response with sc/"

  2. The setup of a test is not clear to me, e.g. I get with my SQLLite:

  1) Error:
test: using authorization code should response with scope. (AccessGrantTest):
URI::InvalidURIError: bad URI(is not URI?):
    test/oauth/access_grant_test.rb:71:in `setup'
    /Users/pmu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/testing/setup_and_teardown.rb:36:in `block in run'
    /Users/pmu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:425:in `_run__1710559639028385245__setup__3451353526551626419__callbacks'
    /Users/pmu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/pmu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
    /Users/pmu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/pmu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/testing/setup_and_teardown.rb:35:in `run'

It is not clear to me, where/what initial values to set here.

That is why I was thinking before taking the larger step of introducing an ActiveRecord setup, it would be interesting to me, to learn more on the test setups, evt. start with some small improvements, to get going.

mulderp avatar Apr 02 '13 06:04 mulderp

Another issue is upgrading Shoulda, since it includes a broken version of Mocha, if I see correctly :https://github.com/freerange/mocha

Versions 0.10.2, 0.10.3 & 0.11.0 of the Mocha gem were broken

mulderp avatar Apr 06 '13 11:04 mulderp

I don't see where Shoulda requires Mocha.

assaf avatar Apr 08 '13 16:04 assaf

Hmm.. I think the problem is shoulda-matchers, requiring bourne:

shoulda-matchers (1.4.2)
  activesupport (>= 3.0.0)
  bourne (~> 1.1.2)

And bourne requires an old Mocha version. But indeed it's possible to work with it, but somehow it gave problems to my test setup. I'll check currently how to upgrade the setup.

mulderp avatar Apr 08 '13 21:04 mulderp

I forked the repo and I'm working on porting the gem for mongo 2.0. Now I'm running the tests for well over 3 hours already. This surely isn't normal, is it? The framework it's testing with is sinatra. Any ideas of how to speed up the tests?

I know that devise sets special params for the crypto in test environment. Maybe the token generation is the bottle neck. CPU usage is at 100% constantly.

repomaa avatar Apr 08 '15 11:04 repomaa