wepay-rails icon indicating copy to clipboard operation
wepay-rails copied to clipboard

Tests are needed. Any volunteers?

Open adamthedeveloper opened this issue 12 years ago • 9 comments

Tests are indeed needed. I will create some - OR - if someone out there would like to create some tests, please do so and send me a pull request. Thanks for helping.

adamthedeveloper avatar Nov 29 '11 20:11 adamthedeveloper

I'd love to run some tests but I'm getting this issue when running bundle exec rake test :

/home/steve/Desktop/wepay-rails/lib/wepay-rails.rb:1:in `require': no such file to load -- active_record (LoadError)
  from /home/steve/Desktop/wepay-rails/lib/wepay-rails.rb:1:in `<top (required)>'
  from /home/steve/Desktop/wepay-rails/test/helper.rb:15:in `require'

It looks like we need to declare active_record as a dependency for development to get testing to work. Should we be requiring the entire Rails frame work to run a complete test suite, or individual gems as needed (such as active_record)?

SteveAquino avatar May 31 '12 18:05 SteveAquino

Including rails or active_model in Gemfile won't do the trick. Getting this error:

/home/steve/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing': uninitialized constant WepayRails::Rails (NameError)
from /home/steve/Desktop/wepay-rails/lib/wepay-rails.rb:19:in `<module:WepayRails>'

It looks like the line declaring an initializer for the gem is calling an instance of Rails::Engine, which tells me that running tests will require setting up a Ruby on Rails environment to even load the WepayRails module for testing. I don't exactly know what this means... Do we rails new wepay-rails-test and use that for testing? It doesn't seem to make sense that we would need to include a sample Rails app in the gem's file directory just to run tests. As far as I can tell, this initializer is the only place in the gem that specifically calls the Rails environment. Since this is a Rails specific gem, I also don't think it makes sense to have to check for Rails at runtime, so how do we set up tests for this?

SteveAquino avatar May 31 '12 19:05 SteveAquino

Adding require 'rails/all' in test/helper.rb seems to have done the trick. I'm not closing this comment yet because I'm still not certain this is the proper way to test this gem. I would love to hear what others have experienced in the past as far as testing gems with Rails specific dependencies.

SteveAquino avatar May 31 '12 19:05 SteveAquino

I wonder if:

if Rails.env == 'test' require 'rails/all' end

would be sufficient??

adamthedeveloper avatar May 31 '12 23:05 adamthedeveloper

Ok I've got tests working by requiring 'rails/all' in test/helper.rb which keeps us from having to mess with the actual core files. Will try to get some tests and the latest update pushed out today.

SteveAquino avatar Jun 01 '12 16:06 SteveAquino

AHHH - awesome! Great work -

adamthedeveloper avatar Jun 02 '12 00:06 adamthedeveloper

Added some preliminary tests that just make sure the gem loads properly with config settings. More tests still needed..

SteveAquino avatar Jun 04 '12 05:06 SteveAquino

Our tests are now being run after every push on travis. You can quickly see the state of the last build at the top of our README.rdoc file (aka - the wepay-rails github page).

I'll be adding tests soon too.

Thanks, am

adamthedeveloper avatar Jun 06 '12 05:06 adamthedeveloper

Yes it looks like there's an error with Ruby 1.8 support; I used the new hash syntax instead of the old rocket style {key: value} instead of {:key => value} in test/helper.rb . I've just addressed this an pushing out now as we speak.

SteveAquino avatar Jun 06 '12 06:06 SteveAquino