Skip to content

Commit

Permalink
Prepare for Rails 4:
Browse files Browse the repository at this point in the history
loosen AR version dependencies;
implement gemfiles testing pattern;
improve readme;
add rake task for running tests against all supported AR versions;
update travis.yml;
require library being tested last in test_helper;
  • Loading branch information
pboling committed Jun 4, 2014
1 parent 2ed2142 commit bf45e16
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ test/version_tmp
tmp
bin/
.rbenv-version*
.ruby-version
.ruby-gemset
gemfiles/*.lock

spec/dummy/config/database.yml
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
rvm:
- 1.9.3
- 2.0.0
- jruby-19mode
- 2.1.2

gemfile:
- gemfiles/Gemfile.activerecord-4.0.x
- gemfiles/Gemfile.activerecord-4.1.x

env: DATABASE_URL=postgres://postgres@localhost/postgres_ext_test

before_script:
- psql -c 'create database postgres_ext_test;' -U postgres -h localhost
- rake db:migrate
- bundle exec rake db:migrate

notifications:
email:
- git@danmcclain.net
hipchat:
rooms:
secure: gebjx8Q/jmnNmf6l+SyQHHJjGn9RfA6s4e8sIoRBVt9pomkOCBvHq7++AjpVlqkXcvV6rK2L90rAEPKMP0QUS04vRtRY6LvwmjiQHFo99/gktG6LO+5/QGvy9zbK4PxWe35Yr1F98Gs0mQ+y/ZbU6u8rJsI7DM1iPq2ULzo/QUw=
addons:
postgresql: '9.3'
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ be adding more datatypes as we come across them.

To work on postgres\_ext locally, follow these steps:

1. Run `bundle install`, this will install all the development
1. Run `bundle install`, this will install (almost) all the development
dependencies
2. Run `rake setup`, this will set up the `.env` file necessary to run
2. Run `gem install byebug` (not a declared dependency to not break CI)
3. Run `bundle exec rake setup`, this will set up the `.env` file necessary to run
the tests and set up the database
3. Run `rake db:create`, this will create the test database
4. Run `rake db:migrate`, this will set up the database tables required
4. Run `bundle exec rake db:create`, this will create the test database
5. Run `bundle exec rake db:migrate`, this will set up the database tables required
by the test
6. Run `BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.0.x' bundle install --quiet` to create the Gemfile.lock for 4.0.
7. Run `BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.1.x' bundle install --quiet` to create the Gemfile.lock for 4.1.
8. Run `bundle exec rake test:all` to run tests against all supported versions of Active Record

## Authors

Expand Down
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ end

task :default => :test

namespace :test do
desc 'Test against all supported ActiveRecord versions'
task :all do
# Currently only supports Active Record v4.0
%w(4.0.x 4.1.x).each do |version|
sh "BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-#{version}' bundle install --quiet"
sh "BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-#{version}' bundle exec rake test"
end
end
end

task :setup do
if File.exist?('.env')
puts 'This will overwrite your existing .env file'
Expand Down
5 changes: 5 additions & 0 deletions gemfiles/Gemfile.activerecord-4.0.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gemspec :path => '..'

gem "activerecord", "~>4.0.0"
5 changes: 5 additions & 0 deletions gemfiles/Gemfile.activerecord-4.1.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gemspec :path => '..'

gem "activerecord", "~>4.1.0"
4 changes: 2 additions & 2 deletions postgres_ext.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = PostgresExt::VERSION

gem.add_dependency 'activerecord', '~> 4.0.0'
gem.add_dependency 'arel', '~> 4.0.1'
gem.add_dependency 'activerecord', '>= 4.0.0'
gem.add_dependency 'arel', '>= 4.0.1'
gem.add_dependency 'pg_array_parser', '~> 0.0.9'

gem.add_development_dependency 'rake', '~> 10.1.0'
Expand Down
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'active_record'
require 'minitest/autorun'
require 'bourne'
require 'postgres_ext'
require 'database_cleaner'
unless ENV['CI'] || RUBY_PLATFORM =~ /java/
require 'byebug'
Expand All @@ -10,6 +9,8 @@
require 'dotenv'
Dotenv.load

require 'postgres_ext'

ActiveRecord::Base.establish_connection

class Person < ActiveRecord::Base
Expand Down

0 comments on commit bf45e16

Please sign in to comment.