Skip to content

Commit

Permalink
switch to appraisal and bump
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Jan 26, 2013
1 parent fc77255 commit b10c3bc
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 27 deletions.
5 changes: 5 additions & 0 deletions Appraisals
@@ -0,0 +1,5 @@
["2.3", "3.0", "3.1", "3.2"].each do |version|
appraise "activerecord_#{version}" do
gem "activerecord", "~> #{version}.0"
end
end
4 changes: 3 additions & 1 deletion Gemfile
@@ -1,7 +1,9 @@
source :rubygems
gemspec

gem 'activerecord', ENV['AR']
gem 'appraisal'
gem 'activerecord'
gem 'sqlite3'
gem 'rake'
gem 'rspec', '~>2'
gem 'bump'
6 changes: 6 additions & 0 deletions Gemfile.lock
Expand Up @@ -18,9 +18,13 @@ GEM
tzinfo (~> 0.3.27)
activesupport (3.1.0.rc4)
multi_json (~> 1.0)
appraisal (0.5.1)
bundler
rake
arel (2.1.1)
bcrypt-ruby (2.1.4)
builder (3.0.0)
bump (0.3.9)
diff-lcs (1.1.3)
i18n (0.6.0)
multi_json (1.0.3)
Expand All @@ -41,7 +45,9 @@ PLATFORMS

DEPENDENCIES
activerecord
appraisal
bitfields!
bump
rake
rspec (~> 2)
sqlite3
28 changes: 5 additions & 23 deletions Rakefile
@@ -1,29 +1,11 @@
require 'bundler/gem_tasks'
require "bundler/gem_tasks"
require "bump/tasks"
require "appraisal"

task :spec do
sh "rspec spec"
sh "rspec spec/"
end

task :default do
sh "AR=2.3.14 && (bundle check || bundle install) && bundle exec rake spec"
sh "AR=3.0.12 && (bundle check || bundle install) && bundle exec rake spec"
sh "AR=3.1.4 && (bundle check || bundle install) && bundle exec rake spec"
sh "AR=3.2.3 && (bundle check || bundle install) && bundle exec rake spec"
end

# extracted from https://github.com/grosser/project_template
rule /^version:bump:.*/ do |t|
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = ['major', 'minor','patch'].index(t.name.split(':').last)
file = 'lib/bitfields/version.rb'

version_file = File.read(file)
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
version_parts[index] = version_parts[index].to_i + 1
version_parts[2] = 0 if index < 2 # remove patch for minor
version_parts[1] = 0 if index < 1 # remove minor for major
new_version = version_parts * '.'
File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }

sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
sh "bundle exec rake appraisal:install && bundle exec rake appraisal spec"
end
12 changes: 12 additions & 0 deletions gemfiles/activerecord_2.3.gemfile
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source :rubygems

gem "appraisal"
gem "sqlite3"
gem "rake"
gem "rspec", "~>2"
gem "bump"
gem "activerecord", "~> 2.3.0"

gemspec :path=>"../"
38 changes: 38 additions & 0 deletions gemfiles/activerecord_2.3.gemfile.lock
@@ -0,0 +1,38 @@
PATH
remote: /Users/mgrosser/code/tools/bitfields
specs:
bitfields (0.4.1)

GEM
remote: http://rubygems.org/
specs:
activerecord (2.3.15)
activesupport (= 2.3.15)
activesupport (2.3.15)
appraisal (0.5.1)
bundler
rake
bump (0.3.9)
diff-lcs (1.1.3)
rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.1)
sqlite3 (1.3.7)

PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 2.3.0)
appraisal
bitfields!
bump
rake
rspec (~> 2)
sqlite3
12 changes: 12 additions & 0 deletions gemfiles/activerecord_3.0.gemfile
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source :rubygems

gem "appraisal"
gem "sqlite3"
gem "rake"
gem "rspec", "~>2"
gem "bump"
gem "activerecord", "~> 3.0.0"

gemspec :path=>"../"
49 changes: 49 additions & 0 deletions gemfiles/activerecord_3.0.gemfile.lock
@@ -0,0 +1,49 @@
PATH
remote: /Users/mgrosser/code/tools/bitfields
specs:
bitfields (0.4.1)

GEM
remote: http://rubygems.org/
specs:
activemodel (3.0.19)
activesupport (= 3.0.19)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.19)
activemodel (= 3.0.19)
activesupport (= 3.0.19)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activesupport (3.0.19)
appraisal (0.5.1)
bundler
rake
arel (2.0.10)
builder (2.1.2)
bump (0.3.9)
diff-lcs (1.1.3)
i18n (0.5.0)
rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.1)
sqlite3 (1.3.7)
tzinfo (0.3.35)

PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 3.0.0)
appraisal
bitfields!
bump
rake
rspec (~> 2)
sqlite3
12 changes: 12 additions & 0 deletions gemfiles/activerecord_3.1.gemfile
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source :rubygems

gem "appraisal"
gem "sqlite3"
gem "rake"
gem "rspec", "~>2"
gem "bump"
gem "activerecord", "~> 3.1.0"

gemspec :path=>"../"
51 changes: 51 additions & 0 deletions gemfiles/activerecord_3.1.gemfile.lock
@@ -0,0 +1,51 @@
PATH
remote: /Users/mgrosser/code/tools/bitfields
specs:
bitfields (0.4.1)

GEM
remote: http://rubygems.org/
specs:
activemodel (3.1.8)
activesupport (= 3.1.8)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.8)
activemodel (= 3.1.8)
activesupport (= 3.1.8)
arel (~> 2.2.3)
tzinfo (~> 0.3.29)
activesupport (3.1.8)
multi_json (>= 1.0, < 1.3)
appraisal (0.5.1)
bundler
rake
arel (2.2.3)
builder (3.0.4)
bump (0.3.9)
diff-lcs (1.1.3)
i18n (0.6.1)
multi_json (1.2.0)
rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.1)
sqlite3 (1.3.7)
tzinfo (0.3.35)

PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 3.1.0)
appraisal
bitfields!
bump
rake
rspec (~> 2)
sqlite3
12 changes: 12 additions & 0 deletions gemfiles/activerecord_3.2.gemfile
@@ -0,0 +1,12 @@
# This file was generated by Appraisal

source :rubygems

gem "appraisal"
gem "sqlite3"
gem "rake"
gem "rspec", "~>2"
gem "bump"
gem "activerecord", "~> 3.2.0"

gemspec :path=>"../"
51 changes: 51 additions & 0 deletions gemfiles/activerecord_3.2.gemfile.lock
@@ -0,0 +1,51 @@
PATH
remote: /Users/mgrosser/code/tools/bitfields
specs:
bitfields (0.4.1)

GEM
remote: http://rubygems.org/
specs:
activemodel (3.2.11)
activesupport (= 3.2.11)
builder (~> 3.0.0)
activerecord (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activesupport (3.2.11)
i18n (~> 0.6)
multi_json (~> 1.0)
appraisal (0.5.1)
bundler
rake
arel (3.0.2)
builder (3.0.4)
bump (0.3.9)
diff-lcs (1.1.3)
i18n (0.6.1)
multi_json (1.5.0)
rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.1)
sqlite3 (1.3.7)
tzinfo (0.3.35)

PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 3.2.0)
appraisal
bitfields!
bump
rake
rspec (~> 2)
sqlite3
16 changes: 13 additions & 3 deletions spec/bitfields_spec.rb
Expand Up @@ -89,6 +89,14 @@ class InitializedUser < User
User.delete_all
end

def pending_if(condition, &block)
if condition
pending(&block)
else
yield
end
end

describe :bitfields do
it "parses them correctly" do
User.bitfields.should == {:bits => {:seller => 1, :insane => 2, :stupid => 4}}
Expand Down Expand Up @@ -406,12 +414,14 @@ class InitializedUser < User

describe 'initializers' do
it "sets defaults" do
InitializedUser.new.seller.should == true
InitializedUser.new.insane.should == false
pending_if(ActiveRecord::VERSION::MAJOR == 2) do
InitializedUser.new.seller.should == true
InitializedUser.new.insane.should == false
end
end

it "can overwrite defaults in new" do
pending do
pending_if(ActiveRecord::VERSION::MAJOR != 2) do
InitializedUser.new(:seller => false).seller.should == false
InitializedUser.new(:insane => true).insane.should == true
end
Expand Down

0 comments on commit b10c3bc

Please sign in to comment.