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

Make appraisal task easier to run; run it under travis #445

Merged
merged 3 commits into from
Dec 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
script: "cp spec/database.yml.sample spec/database.yml && bundle install && bundle exec rake"
rvm:
- 1.9.3
- 2.0.0
env:
- DB=sqlite3
- DB=mysql
- DB=postgresql
gemfile:
- gemfiles/rails_3.2.gemfile
- gemfiles/rails_4.0.gemfile
cache: bundler
script: bundle exec rake
before_install:
- gem install bundler
bundler_args: '--without local_development'
matrix:
fast_finish: true
8 changes: 4 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
appraise "rails-3" do
gem "rails", "3.2.13"
appraise "rails-3.2" do
gem "rails", "~> 3.2"
end

appraise "rails-4" do
gem "rails", "4.0.0.beta1"
appraise "rails-4.0" do
gem "rails", "~> 4.0"
end
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ source 'https://rubygems.org'

gemspec

gem 'appraisal'
group :local_development do
gem 'guard'
gem 'guard-rspec'
gem 'appraisal'
gem 'rake'
end

22 changes: 20 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
require 'rubygems'
require 'bundler/setup'
require 'appraisal'
begin
require 'bundler/setup'
rescue LoadError
STDERR.puts "Bundler not loaded"
end

desc 'Copy sample spec database.yml over if not exists'
task :copy_db_config do
cp 'spec/database.yml.sample', 'spec/database.yml'
end

task :spec => [:copy_db_config]

desc 'Default: run specs'
task :default => :spec

begin
require 'appraisal'
desc 'Run tests across gemfiles specified in Appraisals'
task :appraise => ['appraisal:cleanup', 'appraisal:install', 'appraisal']
rescue LoadError
puts "appraisal tasks not available"
end

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
Expand Down
10 changes: 5 additions & 5 deletions acts-as-taggable-on.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Gem::Specification.new do |gem|

gem.add_runtime_dependency 'rails', ['>= 3', '< 5']

gem.add_development_dependency 'rspec-rails', '2.13.0' # 2.13.1 is broken
gem.add_development_dependency 'rspec', '~> 2.6'
gem.add_development_dependency 'ammeter'
gem.add_development_dependency 'sqlite3'
gem.add_development_dependency 'mysql2', '~> 0.3.7'
gem.add_development_dependency 'pg'
gem.add_development_dependency 'guard'
gem.add_development_dependency 'guard-rspec'

gem.add_development_dependency 'rspec-rails', '2.13.0' # 2.13.1 is broken
gem.add_development_dependency 'rspec', '~> 2.6'
gem.add_development_dependency 'ammeter'

end
3 changes: 1 addition & 2 deletions gemfiles/rails_3.gemfile → gemfiles/rails_3.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

source "https://rubygems.org"

gem "appraisal"
gem "rails", "3.2.13"
gem "rails", "~> 3.2"

gemspec :path=>"../"
3 changes: 1 addition & 2 deletions gemfiles/rails_4.gemfile → gemfiles/rails_4.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

source "https://rubygems.org"

gem "appraisal"
gem "rails", :github => 'rails/rails'
gem "rails", "~> 4.0"

gemspec :path=>"../"
33 changes: 8 additions & 25 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'logger'

begin
require "rubygems"
require "bundler"

if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.5")
raise RuntimeError, "Your bundler version is too old." +
"Run `gem install bundler` to upgrade."
end

# Set up load paths for all bundled gems
Bundler.setup
rescue Bundler::GemNotFound
raise RuntimeError, "Bundler couldn't find some gems." +
"Did you run \`bundle install\`?"
end

Bundler.require
require File.expand_path('../../lib/acts-as-taggable-on', __FILE__)
require 'ammeter/init'

Expand All @@ -39,39 +22,39 @@ def freq

if File.exists?(database_yml)
active_record_configuration = YAML.load_file(database_yml)

ActiveRecord::Base.configurations = active_record_configuration
config = ActiveRecord::Base.configurations[db_name]

begin
ActiveRecord::Base.establish_connection(db_name)
ActiveRecord::Base.connection
rescue
case db_name
when /mysql/
when /mysql/
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
ActiveRecord::Base.connection.create_database(config['database'], {:charset => 'utf8', :collation => 'utf8_unicode_ci'})
when 'postgresql'
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => 'utf8'))
end

ActiveRecord::Base.establish_connection(config)
end

logger = ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
ActiveRecord::Base.default_timezone = :utc

begin
old_logger_level, logger.level = logger.level, ::Logger::ERROR
ActiveRecord::Migration.verbose = false

load(File.dirname(__FILE__) + '/schema.rb')
load(File.dirname(__FILE__) + '/models.rb')
ensure
logger.level = old_logger_level
end

else
raise "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
end
Expand Down