Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests are needed. Any volunteers? #4

Open
adamthedeveloper opened this issue Nov 29, 2011 · 9 comments
Open

Tests are needed. Any volunteers? #4

adamthedeveloper opened this issue Nov 29, 2011 · 9 comments

Comments

@adamthedeveloper
Copy link
Owner

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Owner Author

I wonder if:

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

would be sufficient??

@SteveAquino
Copy link
Collaborator

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
Copy link
Owner Author

AHHH - awesome! Great work -

@SteveAquino
Copy link
Collaborator

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

@adamthedeveloper
Copy link
Owner Author

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
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants