Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'spec-activerecord' of github.com:winton/gem_template

Conflicts:
	Rakefile
	gem_template.gemspec
	lib/gem_template.rb
	lib/mover/gems.rb
	spec/Rakefile
	spec/spec_helper.rb
  • Loading branch information...
commit 03bbbfbcf16d501038704d8a1a77a690c9bd5682 2 parents 2d6115f + c9ebbd4
Winton Welsh authored
2  LICENSE
... ... @@ -1,4 +1,4 @@
1   -Copyright (c) 2010 Winton Welsh
  1 +Copyright (c) 2010
2 2
3 3 Permission is hereby granted, free of charge, to any person obtaining a copy of
4 4 this software and associated documentation files (the "Software"), to deal in
85 Rakefile
... ... @@ -1,9 +1,8 @@
1 1 require File.dirname(__FILE__) + '/lib/mover/gems'
2 2
3   -Mover::Gems.require(:rake)
  3 +Mover::Gems.activate %w(rake rspec)
4 4
5 5 require 'rake'
6   -require 'rake/gempackagetask'
7 6 require 'spec/rake/spectask'
8 7
9 8 def gemspec
@@ -13,13 +12,6 @@ def gemspec
13 12 end
14 13 end
15 14
16   -if defined?(Rake::GemPackageTask)
17   - Rake::GemPackageTask.new(gemspec) do |pkg|
18   - pkg.gem_spec = gemspec
19   - end
20   - task :gem => :gemspec
21   -end
22   -
23 15 if defined?(Spec::Rake::SpecTask)
24 16 desc "Run specs"
25 17 Spec::Rake::SpecTask.new do |t|
@@ -28,33 +20,60 @@ if defined?(Spec::Rake::SpecTask)
28 20 t.warning = true
29 21 end
30 22 task :spec
  23 + task :default => :spec
  24 +end
  25 +
  26 +desc "Build gem(s)"
  27 +task :gem do
  28 + old_gemset = ENV['GEMSET']
  29 + root = File.expand_path('../', __FILE__)
  30 + pkg = "#{root}/pkg"
  31 + system "rm -Rf #{pkg}"
  32 + Mover::Gems.gemset_names.each do |gemset|
  33 + ENV['GEMSET'] = gemset.to_s
  34 + system "cd #{root} && gem build mover.gemspec"
  35 + system "mkdir -p #{pkg} && mv *.gem pkg"
  36 + end
  37 + ENV['GEMSET'] = old_gemset
  38 +end
  39 +
  40 +namespace :gem do
  41 + desc "Install gem(s)"
  42 + task :install do
  43 + Rake::Task['gem'].invoke
  44 + Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
  45 + system "gem install #{pkg} --no-ri --no-rdoc"
  46 + end
  47 + end
  48 +
  49 + desc "Push gem(s)"
  50 + task :push do
  51 + Rake::Task['gem'].invoke
  52 + Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
  53 + system "gem push #{pkg}"
  54 + end
  55 + end
31 56 end
32 57
33 58 namespace :gems do
34   - desc "Install gems (DEV=1|0 DOCS=1|0 SUDO=1|0)"
  59 + desc "Install gem dependencies (DEV=0 DOCS=0 GEMSPEC=default SUDO=0)"
35 60 task :install do
36   - file = File.dirname(__FILE__) + '/gems'
37   - sudo = (ENV['SUDO'] ||= '0').to_i
38   - docs = (ENV['DOCS'] ||= '0').to_i
39   - sudo = sudo == 1 ? 'sudo' : ''
40   - docs = docs == 1 ? '' : '--no-ri --no-rdoc'
41   - gems = []
  61 + dev = ENV['DEV'] == '1'
  62 + docs = ENV['DOCS'] == '1' ? '' : '--no-ri --no-rdoc'
  63 + gemset = ENV['GEMSET']
  64 + sudo = ENV['SUDO'] == '1' ? 'sudo' : ''
42 65
43   - if File.exists?(file)
44   - File.open(file, 'r') do |f|
45   - gems = f.readlines.collect do |line|
46   - line.split(' ')
47   - end
48   - end
  66 + Mover::Gems.gemset = gemset if gemset
  67 +
  68 + if dev
  69 + gems = Mover::Gems.gemspec.development_dependencies
49 70 else
50   - gems = Mover::Gems::TYPES[:gemspec]
51   - gems = Mover::Gems::TYPES[:gemspec_dev] if ENV['DEV'] == '1'
52   - gems.collect! do |g|
53   - [ g.to_s, Mover::Gems::VERSIONS[g] ]
54   - end
  71 + gems = Mover::Gems.gemspec.dependencies
55 72 end
56 73
57   - gems.each do |(name, version)|
  74 + gems.each do |name|
  75 + name = name.to_s
  76 + version = Mover::Gems.versions[name]
58 77 if Gem.source_index.find_name(name, version).empty?
59 78 version = version ? "-v #{version}" : ''
60 79 system "#{sudo} gem install #{name} #{version} #{docs}"
@@ -65,15 +84,7 @@ namespace :gems do
65 84 end
66 85 end
67 86
68   -desc "Install gem locally"
69   -task :install => :package do
70   - sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
71   -end
72   -
73 87 desc "Validate the gemspec"
74 88 task :gemspec do
75 89 gemspec.validate
76   -end
77   -
78   -task :package => :gemspec
79   -task :default => :spec
  90 +end
5 config/gemsets.yml
... ... @@ -0,0 +1,5 @@
  1 +mover:
  2 + rake: >=0.8.7
  3 + rspec: ~>1.0
  4 + default:
  5 + active_wrapper: =0.4.3
13 config/gemspec.yml
... ... @@ -0,0 +1,13 @@
  1 +name: mover
  2 +version: 0.3.5
  3 +authors:
  4 + - Winton Welsh
  5 +email: mail@wintoni.us
  6 +homepage: http://github.com/winton/mover
  7 +summary: Move ActiveRecord records across tables like it ain't no thang
  8 +description: Move ActiveRecord records across tables like it ain't no thang
  9 +dependencies: null
  10 +development_dependencies:
  11 + - active_wrapper
  12 + - rake
  13 + - rspec
4 lib/mover.rb
... ... @@ -1,11 +1,7 @@
1 1 require File.dirname(__FILE__) + '/mover/gems'
2 2
3   -Mover::Gems.require(:lib)
4   -
5 3 $:.unshift File.dirname(__FILE__)
6 4
7   -require 'mover/version'
8   -
9 5 module Mover
10 6
11 7 def self.included(base)
164 lib/mover/gems.rb
... ... @@ -1,41 +1,151 @@
1 1 unless defined?(Mover::Gems)
2 2
3   - require 'rubygems'
  3 + require 'yaml'
4 4
5 5 module Mover
6   - class Gems
7   -
8   - VERSIONS = {
9   - :active_wrapper => '=0.3.4',
10   - :rake => '=0.8.7',
11   - :rspec => '=1.3.1'
12   - }
13   -
14   - TYPES = {
15   - :gemspec => [],
16   - :gemspec_dev => [ :active_wrapper, :rspec ],
17   - :lib => [],
18   - :rake => [ :rake, :rspec ],
19   - :spec => [ :active_wrapper, :rspec ],
20   - :spec_rake => [ :active_wrapper ]
21   - }
22   -
  6 + module Gems
23 7 class <<self
24 8
25   - def lockfile
26   - file = File.expand_path('../../../gems', __FILE__)
27   - unless File.exists?(file)
28   - File.open(file, 'w') do |f|
29   - Gem.loaded_specs.each do |key, value|
30   - f.puts "#{key} #{value.version.version}"
  9 + attr_accessor :config
  10 + attr_reader :gemset, :gemsets, :versions
  11 +
  12 + class SimpleStruct
  13 + attr_reader :hash
  14 +
  15 + def initialize(hash)
  16 + @hash = hash
  17 + @hash.each do |key, value|
  18 + self.class.send(:define_method, key) { @hash[key] }
  19 + self.class.send(:define_method, "#{key}=") { |v| @hash[key] = v }
  20 + end
  21 + end
  22 + end
  23 +
  24 + Gems.config = SimpleStruct.new(
  25 + :gemsets => [ "#{File.expand_path('../../../', __FILE__)}/config/gemsets.yml" ],
  26 + :gemspec => "#{File.expand_path('../../../', __FILE__)}/config/gemspec.yml",
  27 + :warn => true
  28 + )
  29 +
  30 + def activate(*gems)
  31 + begin
  32 + require 'rubygems' unless defined?(::Gem)
  33 + rescue LoadError
  34 + puts "rubygems library could not be required" if @config.warn
  35 + end
  36 +
  37 + self.gemset ||= gemset_from_loaded_specs
  38 +
  39 + gems.flatten.collect(&:to_sym).each do |name|
  40 + version = @versions[name]
  41 + vendor = File.expand_path("../../../vendor/#{name}/lib", __FILE__)
  42 + if File.exists?(vendor)
  43 + $:.unshift vendor
  44 + elsif defined?(gem)
  45 + gem name.to_s, version
  46 + else
  47 + puts "#{name} #{"(#{version})" if version} failed to activate" if @config.warn
  48 + end
  49 + end
  50 + end
  51 +
  52 + def dependencies
  53 + dependency_filter(@gemspec.dependencies, @gemset)
  54 + end
  55 +
  56 + def development_dependencies
  57 + dependency_filter(@gemspec.development_dependencies, @gemset)
  58 + end
  59 +
  60 + def gemset=(gemset)
  61 + if gemset
  62 + @gemset = gemset.to_sym
  63 +
  64 + @gemsets = @config.gemsets.reverse.collect { |config|
  65 + if config.is_a?(::String)
  66 + YAML::load(File.read(config)) rescue {}
  67 + elsif config.is_a?(::Hash)
  68 + config
  69 + end
  70 + }.inject({}) do |hash, config|
  71 + deep_merge(hash, symbolize_keys(config))
  72 + end
  73 +
  74 + @versions = (@gemsets[gemspec.name.to_sym] || {}).inject({}) do |hash, (key, value)|
  75 + if !value.is_a?(::Hash) && value
  76 + hash[key] = value
  77 + elsif key == @gemset
  78 + (value || {}).each { |k, v| hash[k] = v }
31 79 end
  80 + hash
32 81 end
  82 + else
  83 + @gemset = nil
  84 + @gemsets = nil
  85 + @versions = nil
  86 + end
  87 + end
  88 +
  89 + def gemset_names
  90 + (
  91 + [ :default ] +
  92 + @gemsets[gemspec.name.to_sym].inject([]) { |array, (key, value)|
  93 + array.push(key) if value.is_a?(::Hash) || value.nil?
  94 + array
  95 + }
  96 + ).uniq
  97 + end
  98 +
  99 + def gemspec(reload=false)
  100 + if @gemspec && !reload
  101 + @gemspec
  102 + else
  103 + data = YAML::load(File.read(@config.gemspec)) rescue {}
  104 + @gemspec = SimpleStruct.new(data)
  105 + end
  106 + end
  107 +
  108 + private
  109 +
  110 + def deep_merge(first, second)
  111 + merger = lambda do |key, v1, v2|
  112 + Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
33 113 end
  114 + first.merge(second, &merger)
34 115 end
35 116
36   - def require(type=nil)
37   - (TYPES[type] || TYPES.values.flatten.compact).each do |name|
38   - gem name.to_s, VERSIONS[name]
  117 + def dependency_filter(dependencies, match)
  118 + (dependencies || []).inject([]) { |array, value|
  119 + if value.is_a?(::Hash)
  120 + array += value[match.to_s] if value[match.to_s]
  121 + else
  122 + array << value
  123 + end
  124 + array
  125 + }.uniq.collect(&:to_sym)
  126 + end
  127 +
  128 + def gemset_from_loaded_specs
  129 + if defined?(Gem)
  130 + Gem.loaded_specs.each do |name, spec|
  131 + if name == gemspec.name
  132 + return :default
  133 + elsif name[0..gemspec.name.length] == "#{gemspec.name}-"
  134 + return name[gemspec.name.length+1..-1].to_sym
  135 + end
  136 + end
  137 + :default
  138 + else
  139 + :none
  140 + end
  141 + end
  142 +
  143 + def symbolize_keys(hash)
  144 + return {} unless hash.is_a?(::Hash)
  145 + hash.inject({}) do |options, (key, value)|
  146 + value = symbolize_keys(value) if value.is_a?(::Hash)
  147 + options[(key.to_sym rescue key) || key] = value
  148 + options
39 149 end
40 150 end
41 151 end
3  lib/mover/version.rb
... ... @@ -1,3 +0,0 @@
1   -module Mover
2   - VERSION = "0.3.5" unless defined?(::Mover::VERSION)
3   -end
39 mover.gemspec
... ... @@ -1,29 +1,32 @@
1 1 # -*- encoding: utf-8 -*-
2   -lib = File.expand_path('../lib/', __FILE__)
  2 +root = File.expand_path('../', __FILE__)
  3 +lib = "#{root}/lib"
3 4 $:.unshift lib unless $:.include?(lib)
4   -
  5 +
5 6 require 'mover/gems'
6   -require 'mover/version'
  7 +Mover::Gems.gemset ||= ENV['GEMSET'] || :default
7 8
8 9 Gem::Specification.new do |s|
9   - s.name = "mover"
10   - s.version = Mover::VERSION
11   - s.platform = Gem::Platform::RUBY
12   - s.authors = ["Winton Welsh"]
13   - s.email = ["mail@wintoni.us"]
14   - s.homepage = "http://github.com/winton/mover"
15   - s.summary = "Move ActiveRecord records across tables like it ain't no thang"
16   - s.description = "Move ActiveRecord records across tables like it ain't no thang"
  10 + Mover::Gems.gemspec.hash.each do |key, value|
  11 + if key == 'name' && Mover::Gems.gemset != :default
  12 + s.name = "#{value}-#{Mover::Gems.gemset}"
  13 + elsif key == 'summary' && Mover::Gems.gemset == :solo
  14 + s.summary = value + " (no dependencies)"
  15 + elsif !%w(dependencies development_dependencies).include?(key)
  16 + s.send "#{key}=", value
  17 + end
  18 + end
17 19
18   - Mover::Gems::TYPES[:gemspec].each do |g|
19   - s.add_dependency g.to_s, Mover::Gems::VERSIONS[g]
  20 + Mover::Gems.dependencies.each do |g|
  21 + s.add_dependency g.to_s, Mover::Gems.versions[g]
20 22 end
21 23
22   - Mover::Gems::TYPES[:gemspec_dev].each do |g|
23   - s.add_development_dependency g.to_s, Mover::Gems::VERSIONS[g]
  24 + Mover::Gems.development_dependencies.each do |g|
  25 + s.add_development_dependency g.to_s, Mover::Gems.versions[g]
24 26 end
25 27
26   - s.files = Dir.glob("{bin,lib}/**/*") + %w(LICENSE README.md)
27   - s.executables = Dir.glob("{bin}/*").collect { |f| File.basename(f) }
28   - s.require_path = 'lib'
  28 + s.executables = `cd #{root} && git ls-files -- {bin}/*`.split("\n").collect { |f| File.basename(f) }
  29 + s.files = `cd #{root} && git ls-files`.split("\n")
  30 + s.require_paths = %w(lib)
  31 + s.test_files = `cd #{root} && git ls-files -- {features,test,spec}/*`.split("\n")
29 32 end
2  spec/Rakefile
... ... @@ -1,5 +1,5 @@
1 1 require File.expand_path(File.dirname(__FILE__) + '/../lib/mover/gems')
2   -Mover::Gems.require(:spec_rake)
  2 +Mover::Gems.activate(:active_wrapper)
3 3
4 4 require 'active_wrapper/tasks'
5 5
9 spec/fixtures/gemsets.yml
... ... @@ -0,0 +1,9 @@
  1 +name:
  2 + rake: =0.8.7
  3 + default:
  4 + mysql: =2.8.1
  5 + rspec: =1.3.1
  6 + rspec2:
  7 + mysql2: =0.2.6
  8 + rspec: =2.3.0
  9 + solo: null
15 spec/fixtures/gemspec.yml
... ... @@ -0,0 +1,15 @@
  1 +name: name
  2 +version: 0.1.0
  3 +authors:
  4 + - Author
  5 +email: email@email.com
  6 +homepage: http://github.com/author/name
  7 +summary: Summary
  8 +description: Description
  9 +dependencies:
  10 + - rake
  11 + - default:
  12 + - mysql
  13 + - rspec2:
  14 + - mysql2
  15 +development_dependencies: null
249 spec/mover/gems_spec.rb
... ... @@ -0,0 +1,249 @@
  1 +require 'spec_helper'
  2 +
  3 +describe Mover::Gems do
  4 +
  5 + before(:each) do
  6 + @old_config = Mover::Gems.config
  7 +
  8 + Mover::Gems.config.gemspec = "#{$root}/spec/fixtures/gemspec.yml"
  9 + Mover::Gems.config.gemsets = [
  10 + "#{$root}/spec/fixtures/gemsets.yml"
  11 + ]
  12 + Mover::Gems.config.warn = true
  13 +
  14 + Mover::Gems.gemspec true
  15 + Mover::Gems.gemset = nil
  16 + end
  17 +
  18 + after(:each) do
  19 + Mover::Gems.config = @old_config
  20 + end
  21 +
  22 + describe :activate do
  23 + it "should activate gems" do
  24 + Mover::Gems.stub!(:gem)
  25 + Mover::Gems.should_receive(:gem).with('rspec', '=1.3.1')
  26 + Mover::Gems.should_receive(:gem).with('rake', '=0.8.7')
  27 + Mover::Gems.activate :rspec, 'rake'
  28 + end
  29 + end
  30 +
  31 + describe :gemset= do
  32 + before(:each) do
  33 + Mover::Gems.config.gemsets = [
  34 + {
  35 + :name => {
  36 + :rake => '>0.8.6',
  37 + :default => {
  38 + :externals => '=1.0.2'
  39 + }
  40 + }
  41 + },
  42 + "#{$root}/spec/fixtures/gemsets.yml"
  43 + ]
  44 + end
  45 +
  46 + describe :default do
  47 + before(:each) do
  48 + Mover::Gems.gemset = :default
  49 + end
  50 +
  51 + it "should set @gemset" do
  52 + Mover::Gems.gemset.should == :default
  53 + end
  54 +
  55 + it "should set @gemsets" do
  56 + Mover::Gems.gemsets.should == {
  57 + :name => {
  58 + :rake => ">0.8.6",
  59 + :default => {
  60 + :externals => '=1.0.2',
  61 + :mysql => "=2.8.1",
  62 + :rspec => "=1.3.1"
  63 + },
  64 + :rspec2 => {
  65 + :mysql2 => "=0.2.6",
  66 + :rspec => "=2.3.0"
  67 + },
  68 + :solo => nil
  69 + }
  70 + }
  71 + end
  72 +
  73 + it "should set Gems.versions" do
  74 + Mover::Gems.versions.should == {
  75 + :externals => "=1.0.2",
  76 + :mysql => "=2.8.1",
  77 + :rake => ">0.8.6",
  78 + :rspec => "=1.3.1"
  79 + }
  80 + end
  81 +
  82 + it "should return proper values for Gems.dependencies" do
  83 + Mover::Gems.dependencies.should == [ :rake, :mysql ]
  84 + Mover::Gems.development_dependencies.should == []
  85 + end
  86 +
  87 + it "should return proper values for Gems.gemset_names" do
  88 + Mover::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
  89 + end
  90 + end
  91 +
  92 + describe :rspec2 do
  93 + before(:each) do
  94 + Mover::Gems.gemset = "rspec2"
  95 + end
  96 +
  97 + it "should set @gemset" do
  98 + Mover::Gems.gemset.should == :rspec2
  99 + end
  100 +
  101 + it "should set @gemsets" do
  102 + Mover::Gems.gemsets.should == {
  103 + :name => {
  104 + :rake => ">0.8.6",
  105 + :default => {
  106 + :externals => '=1.0.2',
  107 + :mysql => "=2.8.1",
  108 + :rspec => "=1.3.1"
  109 + },
  110 + :rspec2 => {
  111 + :mysql2=>"=0.2.6",
  112 + :rspec => "=2.3.0"
  113 + },
  114 + :solo => nil
  115 + }
  116 + }
  117 + end
  118 +
  119 + it "should set Gems.versions" do
  120 + Mover::Gems.versions.should == {
  121 + :mysql2 => "=0.2.6",
  122 + :rake => ">0.8.6",
  123 + :rspec => "=2.3.0"
  124 + }
  125 + end
  126 +
  127 + it "should return proper values for Gems.dependencies" do
  128 + Mover::Gems.dependencies.should == [ :rake, :mysql2 ]
  129 + Mover::Gems.development_dependencies.should == []
  130 + end
  131 +
  132 + it "should return proper values for Gems.gemset_names" do
  133 + Mover::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
  134 + end
  135 + end
  136 +
  137 + describe :solo do
  138 + before(:each) do
  139 + Mover::Gems.gemset = :solo
  140 + end
  141 +
  142 + it "should set @gemset" do
  143 + Mover::Gems.gemset.should == :solo
  144 + end
  145 +
  146 + it "should set @gemsets" do
  147 + Mover::Gems.gemsets.should == {
  148 + :name => {
  149 + :rake => ">0.8.6",
  150 + :default => {
  151 + :externals => '=1.0.2',
  152 + :mysql => "=2.8.1",
  153 + :rspec => "=1.3.1"
  154 + },
  155 + :rspec2 => {
  156 + :mysql2=>"=0.2.6",
  157 + :rspec => "=2.3.0"
  158 + },
  159 + :solo => nil
  160 + }
  161 + }
  162 + end
  163 +
  164 + it "should set Gems.versions" do
  165 + Mover::Gems.versions.should == {:rake=>">0.8.6"}
  166 + end
  167 +
  168 + it "should return proper values for Gems.dependencies" do
  169 + Mover::Gems.dependencies.should == [:rake]
  170 + Mover::Gems.development_dependencies.should == []
  171 + end
  172 +
  173 + it "should return proper values for Gems.gemset_names" do
  174 + Mover::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
  175 + end
  176 + end
  177 +
  178 + describe :nil do
  179 + before(:each) do
  180 + Mover::Gems.gemset = nil
  181 + end
  182 +
  183 + it "should set everything to nil" do
  184 + Mover::Gems.gemset.should == nil
  185 + Mover::Gems.gemsets.should == nil
  186 + Mover::Gems.versions.should == nil
  187 + end
  188 + end
  189 + end
  190 +
  191 + describe :gemset_from_loaded_specs do
  192 + before(:each) do
  193 + Gem.stub!(:loaded_specs)
  194 + end
  195 +
  196 + it "should return the correct gemset for name gem" do
  197 + Gem.should_receive(:loaded_specs).and_return({ "name" => nil })
  198 + Mover::Gems.send(:gemset_from_loaded_specs).should == :default
  199 + end
  200 +
  201 + it "should return the correct gemset for name-rspec gem" do
  202 + Gem.should_receive(:loaded_specs).and_return({ "name-rspec2" => nil })
  203 + Mover::Gems.send(:gemset_from_loaded_specs).should == :rspec2
  204 + end
  205 + end
  206 +
  207 + describe :reload_gemspec do
  208 + it "should populate @gemspec" do
  209 + Mover::Gems.gemspec.hash.should == {
  210 + "name" => "name",
  211 + "version" => "0.1.0",
  212 + "authors" => ["Author"],
  213 + "email" => "email@email.com",
  214 + "homepage" => "http://github.com/author/name",
  215 + "summary" => "Summary",
  216 + "description" => "Description",
  217 + "dependencies" => [
  218 + "rake",
  219 + { "default" => [ "mysql" ] },
  220 + { "rspec2" => [ "mysql2" ] }
  221 + ],
  222 + "development_dependencies" => nil
  223 + }
  224 + end
  225 +
  226 + it "should create methods from keys of @gemspec" do
  227 + Mover::Gems.gemspec.name.should == "name"
  228 + Mover::Gems.gemspec.version.should == "0.1.0"
  229 + Mover::Gems.gemspec.authors.should == ["Author"]
  230 + Mover::Gems.gemspec.email.should == "email@email.com"
  231 + Mover::Gems.gemspec.homepage.should == "http://github.com/author/name"
  232 + Mover::Gems.gemspec.summary.should == "Summary"
  233 + Mover::Gems.gemspec.description.should == "Description"
  234 + Mover::Gems.gemspec.dependencies.should == [
  235 + "rake",
  236 + { "default" => ["mysql"] },
  237 + { "rspec2" => [ "mysql2" ] }
  238 + ]
  239 + Mover::Gems.gemspec.development_dependencies.should == nil
  240 + end
  241 +
  242 + it "should produce a valid gemspec" do
  243 + Mover::Gems.gemset = :default
  244 + gemspec = File.expand_path("../../../mover.gemspec", __FILE__)
  245 + gemspec = eval(File.read(gemspec), binding, gemspec)
  246 + gemspec.validate.should == true
  247 + end
  248 + end
  249 +end
12 spec/spec_helper.rb
... ... @@ -1,13 +1,14 @@
  1 +require 'pp'
  2 +
1 3 $root = File.expand_path('../../', __FILE__)
2 4 require "#{$root}/lib/mover/gems"
3 5
4   -Mover::Gems.require(:spec)
  6 +Mover::Gems.activate %w(active_wrapper rspec)
5 7
6 8 require 'active_wrapper'
7 9 require 'fileutils'
8 10
9 11 require "#{$root}/lib/mover"
10   -require 'pp'
11 12
12 13 require "#{$root}/spec/fixtures/article"
13 14 require "#{$root}/spec/fixtures/article_archive"
@@ -54,11 +55,4 @@ def create_records(klass, values={})
54 55 record.update_attributes(values)
55 56 record
56 57 end
57   -end
58   -
59   -# For use with rspec textmate bundle
60   -def debug(object)
61   - puts "<pre>"
62   - puts object.pretty_inspect.gsub('<', '&lt;').gsub('>', '&gt;')
63   - puts "</pre>"
64 58 end

0 comments on commit 03bbbfb

Please sign in to comment.
Something went wrong with that request. Please try again.