Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Multiple Rails versions in specs, update Travis, add JRuby to specs #83

Merged
merged 1 commit into from

2 participants

@petergoldstein
  1. Updated the specs so they can run against Rails 3.1.x, 3.2.x, and 4.0.x
  2. Update Travis CI config to start Redis service
  3. Update Travis CI to run specs against all supported Rails minor versions
  4. Changes to gemspec to allow use of JRuby in specs
  5. Add JRuby to Travis
  6. Add lockfiles to .gitignore
@davidcelis davidcelis commented on the diff
test/dummy/config/environments/development.rb
@@ -22,8 +20,10 @@
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
- # Raise exception on mass assignment protection for Active Record models
- config.active_record.mass_assignment_sanitizer = :strict
+ if (::ActiveRecord::VERSION::MAJOR == 3) && (::ActiveRecord::VERSION::MINOR == 2)
@davidcelis Owner

Should this be ::ActiveRecord::VERSION::MINOR <= 2? Mass-assignment was a thing all throughout Rails 3.x

No, the mass assignment configuration changed with version 3.2.x. You can see it in the release notes here - http://guides.rubyonrails.org/3_2_release_notes.html . Making the change you suggest causes Rails 3.1 specs to fail.

@davidcelis Owner

Ah of course. 3.2 was when the defaults and configuration changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@davidcelis
Owner

Hey thanks for submitting this! Glad to see that the tests pass across multiple Rails versions and under JRuby. My only other general comments are that I don't think the main Gemfile.lock should be gitignored, as that's what's used for local development, and I'd request that the other Gemfiles live under the test/ directory since they're used primarily for testing (i.e. test/gemfiles/rails_32.gemfile). Thanks again!

@petergoldstein

Thanks for the quick reply. I can make the changes you suggest, but a couple of comments:

  1. I'm not sure why you'd want to include the Gemfile.lock for a library in the git repo - basically it's almost certain to be out of date or include a preference for certain configurations (Rails 3.2.x vs. Rails 4.0.x). This isn't a deployed app, so there's no benefit in a checked-in Gemfile.lock

  2. The gemfiles directory has become sort of a de-facto standard location for these sort of Gemfiles. Standard installation with appraisal, etc. tends to put them there. Moreover, they're not really test only - ideally you would use them in development to develop against different, potentially incompatible Rails versions.

Anyway, let me know if you still want to make the changes you suggested and I'll put them in the PR. Thanks.

@davidcelis
Owner
  1. Fair enough.
  2. I see that's the convention used by thoughtbot/appraisal, though couldn't really find any other instances of it. Either way, your argument here makes sense too.

Merging! Thanks for taking the time to submit this :sparkles:patch:sparkles:.

@davidcelis davidcelis merged commit f2357dd into davidcelis:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 30, 2013
  1. @petergoldstein

    Add spec runs for multiple Rails minor versions. Update .travis.yml t…

    petergoldstein authored
    …o reflect this, add redis-server to services
This page is out of date. Refresh to see the latest.
View
4 .gitignore
@@ -2,6 +2,10 @@
.bundle
vendor/bundle
+# Lockfiles
+gemfiles/*.lock
+Gemfile.lock
+
# logging
*.log
View
15 .travis.yml
@@ -1,6 +1,19 @@
+language: ruby
+services:
+ - redis-server
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
-script: bundle exec rake test
+ - jruby-19mode
+gemfile:
+ - gemfiles/rails_31.gemfile
+ - gemfiles/rails_32.gemfile
+ - gemfiles/rails_40.gemfile
+matrix:
+ exclude:
+ - rvm: 1.8.7
+ gemfile: gemfiles/rails_40.gemfile
+ - rvm: 1.9.2
+ gemfile: gemfiles/rails_40.gemfile
View
3  Gemfile
@@ -1,2 +1,5 @@
source 'https://rubygems.org/'
gemspec
+
+gem 'sqlite3', :platform => :ruby
+gem 'activerecord-jdbcsqlite3-adapter', :platforms=>:jruby
View
108 Gemfile.lock
@@ -1,108 +0,0 @@
-PATH
- remote: .
- specs:
- recommendable (2.1.2)
- activesupport (>= 3.0.0)
- hooks (>= 0.2.1)
- redis (>= 2.2.0)
-
-GEM
- remote: https://rubygems.org/
- specs:
- actionmailer (3.2.13)
- actionpack (= 3.2.13)
- mail (~> 2.5.3)
- actionpack (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.4)
- rack (~> 1.4.5)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.2.1)
- activemodel (3.2.13)
- activesupport (= 3.2.13)
- builder (~> 3.0.0)
- activerecord (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activeresource (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- activesupport (3.2.13)
- i18n (= 0.6.1)
- multi_json (~> 1.0)
- arel (3.0.2)
- builder (3.0.4)
- database_cleaner (0.9.1)
- erubis (2.7.0)
- hike (1.2.1)
- hooks (0.2.2)
- i18n (0.6.1)
- journey (1.0.4)
- json (1.7.7)
- mail (2.5.3)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.21)
- miniskirt (1.2.1)
- activesupport
- minitest (4.6.2)
- multi_json (1.7.1)
- polyglot (0.3.3)
- rack (1.4.5)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-ssl (1.3.3)
- rack
- rack-test (0.6.2)
- rack (>= 1.0)
- rails (3.2.13)
- actionmailer (= 3.2.13)
- actionpack (= 3.2.13)
- activerecord (= 3.2.13)
- activeresource (= 3.2.13)
- activesupport (= 3.2.13)
- bundler (~> 1.0)
- railties (= 3.2.13)
- railties (3.2.13)
- actionpack (= 3.2.13)
- activesupport (= 3.2.13)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (>= 0.14.6, < 2.0)
- rake (10.0.3)
- rdoc (3.12.2)
- json (~> 1.4)
- redis (3.0.3)
- sprockets (2.2.2)
- hike (~> 1.2)
- multi_json (~> 1.0)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.7)
- thor (0.17.0)
- tilt (1.3.6)
- treetop (1.4.12)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.37)
- yard (0.8.5.2)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- database_cleaner
- miniskirt
- minitest
- rails (>= 3.1.0)
- recommendable!
- sqlite3
- yard
View
7 gemfiles/rails_31.gemfile
@@ -0,0 +1,7 @@
+source 'https://rubygems.org/'
+gemspec :path => '../'
+
+gem 'rails', '~> 3.1.12'
+
+gem 'sqlite3', :platform => :ruby
+gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
View
7 gemfiles/rails_32.gemfile
@@ -0,0 +1,7 @@
+source 'https://rubygems.org/'
+gemspec :path => '../'
+
+gem 'rails', '~> 3.2.15'
+
+gem 'sqlite3', :platform => :ruby
+gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
View
7 gemfiles/rails_40.gemfile
@@ -0,0 +1,7 @@
+source 'https://rubygems.org/'
+gemspec :path => '../'
+
+gem 'rails', '~> 4.0.1'
+
+gem 'sqlite3', :platform => :ruby
+gem 'activerecord-jdbcsqlite3-adapter', :platforms=>:jruby
View
3  recommendable.gemspec
@@ -24,10 +24,9 @@ EOF
s.add_dependency 'redis', '>= 2.2.0'
s.add_dependency 'hooks', '>= 0.2.1'
- s.add_development_dependency 'minitest'
+ s.add_development_dependency 'minitest', '~> 4.2'
s.add_development_dependency 'miniskirt'
s.add_development_dependency 'yard'
s.add_development_dependency 'rails', '>= 3.1.0'
- s.add_development_dependency 'sqlite3'
s.add_development_dependency 'database_cleaner'
end
View
2  test/dummy/app/models/book.rb
@@ -1,3 +1,3 @@
class Book < ActiveRecord::Base
- attr_accessible :author, :title
+ attr_accessible :author, :title if ::ActiveRecord::VERSION::MAJOR < 4
end
View
2  test/dummy/app/models/movie.rb
@@ -1,3 +1,3 @@
class Movie < ActiveRecord::Base
- attr_accessible :title, :year
+ attr_accessible :title, :year if ::ActiveRecord::VERSION::MAJOR < 4
end
View
2  test/dummy/app/models/rock.rb
@@ -1,3 +1,3 @@
class Rock < ActiveRecord::Base
- attr_accessible :name
+ attr_accessible :name if ::ActiveRecord::VERSION::MAJOR < 4
end
View
2  test/dummy/app/models/user.rb
@@ -1,4 +1,4 @@
class User < ActiveRecord::Base
- attr_accessible :email
+ attr_accessible :email if ::ActiveRecord::VERSION::MAJOR < 4
recommends :movies, :books
end
View
2  test/dummy/config/application.rb
@@ -51,7 +51,7 @@ class Application < Rails::Application
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
- config.active_record.whitelist_attributes = true
+ config.active_record.whitelist_attributes = true if ::ActiveRecord::VERSION::MAJOR < 4
# Enable the asset pipeline
config.assets.enabled = true
View
10 test/dummy/config/environments/development.rb
@@ -5,9 +5,7 @@
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
-
- # Log error messages when you accidentally call methods on nil.
- config.whiny_nils = true
+ config.eager_load = false
# Show full error reports and disable caching
config.consider_all_requests_local = true
@@ -22,8 +20,10 @@
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
- # Raise exception on mass assignment protection for Active Record models
- config.active_record.mass_assignment_sanitizer = :strict
+ if (::ActiveRecord::VERSION::MAJOR == 3) && (::ActiveRecord::VERSION::MINOR == 2)
@davidcelis Owner

Should this be ::ActiveRecord::VERSION::MINOR <= 2? Mass-assignment was a thing all throughout Rails 3.x

No, the mass assignment configuration changed with version 3.2.x. You can see it in the release notes here - http://guides.rubyonrails.org/3_2_release_notes.html . Making the change you suggest causes Rails 3.1 specs to fail.

@davidcelis Owner

Ah of course. 3.2 was when the defaults and configuration changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ # Raise exception on mass assignment protection for Active Record models
+ config.active_record.mass_assignment_sanitizer = :strict
+ end
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
View
10 test/dummy/config/environments/test.rb
@@ -6,14 +6,12 @@
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
+ config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
- # Log error messages when you accidentally call methods on nil
- config.whiny_nils = true
-
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
@@ -29,8 +27,10 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
- # Raise exception on mass assignment protection for Active Record models
- config.active_record.mass_assignment_sanitizer = :strict
+ if (::ActiveRecord::VERSION::MAJOR == 3) && (::ActiveRecord::VERSION::MINOR == 2)
+ # Raise exception on mass assignment protection for Active Record models
+ config.active_record.mass_assignment_sanitizer = :strict
+ end
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
View
3  test/test_helper.rb
@@ -1,11 +1,10 @@
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../dummy/config/environment.rb', __FILE__)
-require 'rails/test_help'
+require 'minitest/autorun'
require 'minitest/unit'
require 'minitest/pride'
-require 'minitest/autorun'
require 'database_cleaner'
Something went wrong with that request. Please try again.