diff --git a/.travis.yml b/.travis.yml index 958087b36..7385b2713 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -script: "cp spec/database.yml.sample spec/database.yml && bundle install && bundle exec rake" rvm: - 1.9.3 - 2.0.0 @@ -6,4 +5,13 @@ 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 diff --git a/Appraisals b/Appraisals index ad94b6262..e755f3493 100644 --- a/Appraisals +++ b/Appraisals @@ -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 diff --git a/Gemfile b/Gemfile index e37a382a0..6a56e6c1e 100644 --- a/Gemfile +++ b/Gemfile @@ -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 + diff --git a/Rakefile b/Rakefile index 5d0808e21..07e16fb35 100644 --- a/Rakefile +++ b/Rakefile @@ -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" diff --git a/acts-as-taggable-on.gemspec b/acts-as-taggable-on.gemspec index f4240504a..2170861fa 100644 --- a/acts-as-taggable-on.gemspec +++ b/acts-as-taggable-on.gemspec @@ -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 diff --git a/gemfiles/rails_3.gemfile b/gemfiles/rails_3.2.gemfile similarity index 70% rename from gemfiles/rails_3.gemfile rename to gemfiles/rails_3.2.gemfile index 19f525c52..b8cfc4e1e 100644 --- a/gemfiles/rails_3.gemfile +++ b/gemfiles/rails_3.2.gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "appraisal" -gem "rails", "3.2.13" +gem "rails", "~> 3.2" gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails_4.gemfile b/gemfiles/rails_4.0.gemfile similarity index 63% rename from gemfiles/rails_4.gemfile rename to gemfiles/rails_4.0.gemfile index 2bf10158b..2ae682b12 100644 --- a/gemfiles/rails_4.gemfile +++ b/gemfiles/rails_4.0.gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "appraisal" -gem "rails", :github => 'rails/rails' +gem "rails", "~> 4.0" gemspec :path=>"../" \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 493538bb1..0615a8199 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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' @@ -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