adamthedeveloper / wepay-rails

Collect payments from wepay in your rails application.
MIT License
31 stars 24 forks source link

Tests are needed. Any volunteers? #4

Open adamthedeveloper opened 12 years ago

adamthedeveloper commented 12 years ago

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.

SteveAquino commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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.

adamthedeveloper commented 12 years ago

I wonder if:

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

would be sufficient??

SteveAquino commented 12 years ago

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.

adamthedeveloper commented 12 years ago

AHHH - awesome! Great work -

SteveAquino commented 12 years ago

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

adamthedeveloper commented 12 years ago

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

SteveAquino commented 12 years ago

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.