rails_gem_install 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,7 +10,8 @@ begin
10
10
  gem.email = "scottwb@gmail.com"
11
11
  gem.homepage = "http://github.com/scottwb/rails_gem_install"
12
12
  gem.authors = ["Scott W. Bradley"]
13
- gem.add_development_dependency "shoulda", ">= 0"
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "rcov", ">= 0.9.8"
14
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
16
  end
16
17
  Jeweler::GemcutterTasks.new
@@ -18,29 +19,21 @@ rescue LoadError
18
19
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
20
  end
20
21
 
21
- require 'rake/testtask'
22
- Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/test_*.rb'
25
- test.verbose = true
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
26
  end
27
27
 
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
39
32
  end
40
33
 
41
- task :test => :check_dependencies
34
+ task :spec => :check_dependencies
42
35
 
43
- task :default => :test
36
+ task :default => :spec
44
37
 
45
38
  require 'rake/rdoctask'
46
39
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -28,9 +28,25 @@ class RailsGemInstaller
28
28
  # Parses out any dependency gems listed that are not yet satisified.
29
29
  def parse_deps(input)
30
30
  matches = input.scan(/\s+-\s+\[ \]\s+(\S+)\s+(\S+\s+[0-9.]+)/) || []
31
- matches.map do |match|
31
+
32
+ gemspecs = matches.map do |match|
32
33
  {:name => match[0], :version => match[1]}
33
34
  end
35
+
36
+ # NOTE: These gemspecs are gems that are not yet loaded. We don't know if
37
+ # they are installed or not, so we don't know for sure if the
38
+ # dependency will be met at runtime. So, we'll execute a gem command
39
+ # to check to see if these are installed and ignore the ones that
40
+ # already are.
41
+ gemspecs.delete_if do |gemspec|
42
+ cmd = "gem list #{gemspec[:name]} -i -l"
43
+ if gemspec[:version]
44
+ cmd << " -v '#{gemspec[:version]}'"
45
+ end
46
+ `#{cmd}` =~ /true/
47
+ end
48
+
49
+ return gemspecs
34
50
  end
35
51
 
36
52
  # Gets the set of required gems that need to be installed.
@@ -0,0 +1,103 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe RailsGemInstaller do
4
+ describe "#parse_required" do
5
+ context "when there is a missing required gem" do
6
+ it "should return an array of just that gem with no version" do
7
+ gemspecs = subject.parse_required("no such file to load -- gdata\n")
8
+ gemspecs.should have(1).gemspec
9
+ gemspecs.first.should have(1).member
10
+ gemspecs.first.should have_key(:name)
11
+ gemspecs.first.should_not have_key(:version)
12
+ gemspecs.first[:name].should == 'gdata'
13
+ end
14
+ end
15
+
16
+ context "when there are no missing required gems" do
17
+ it "should returns an empty array" do
18
+ gemspecs = subject.parse_required("\n")
19
+ gemspecs.should be_empty
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "#parse_missing" do
25
+ context "when there are missing gems that specify version numbers" do
26
+ it "should return an array of gemspec hashes including name and version" do
27
+ pending "This is currently known to be broken."
28
+ gemspecs = subject.parse_missing <<EOT
29
+ Missing these required gems:
30
+ sanitize = 1.2.1
31
+
32
+ You're running:
33
+ ruby 1.8.7.174 at blah blah blah
34
+ EOT
35
+ gemspecs.should have(1).gemspec
36
+ gemspecs.first.should have(2).members
37
+ gemspecs.first[:name].should == 'sanitize'
38
+ gemspecs.first[:version].should == '= 1.2.1'
39
+ end
40
+ end
41
+
42
+ context "when there are missing gems that do not specify version numbers" do
43
+ it "should return an array of gemspec hashes including just the name" do
44
+ pending "This is currently known to be broken."
45
+ gemspecs = subject.parse_missing <<EOT
46
+ Missing these required gems:
47
+ sanitize
48
+
49
+ You're running:
50
+ ruby 1.8.7.174 at blah blah blah
51
+ EOT
52
+ gemspecs.should have(1).gemspec
53
+ gemspecs.first.should have(1).member
54
+ gemspecs.first[:name].should == 'sanitize'
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "#parse_deps" do
60
+ context "when there are uninstalled dependencies of a specific version" do
61
+ it "should return an array of gemspec hashes including name and version" do
62
+ gemspecs = subject.parse_deps <<EOT
63
+ - [I] rmagick
64
+ - [I] gdata
65
+ - [I] responders ~> 0.4.6
66
+ - [I] sanitize = 1.2.1
67
+ - [ ] nokogiri ~> 1.4.1
68
+ - [I] panztel-actionwebservice = 2.3.5
69
+ - [R] actionpack = 2.3.5
70
+ - [R] activerecord = 2.3.5
71
+ - [I] fastthread
72
+ - [I] jammit = 0.4.4
73
+ EOT
74
+ gemspecs.should have(1).gemspec
75
+ gemspecs.first.should have(2).members
76
+ gemspecs.first[:name].should == 'nokogiri'
77
+ gemspecs.first[:version].should == '~> 1.4.1'
78
+ end
79
+ end
80
+
81
+ context "when there are uninstalled dependencies that do not specify a version" do
82
+ it "should return an array of gemspec hashes including just the name" do
83
+ pending "This is currently known to be broken."
84
+ gemspecs = subject.parse_deps <<EOT
85
+ - [I] rmagick
86
+ - [ ] gdata
87
+ - [I] responders ~> 0.4.6
88
+ - [I] sanitize = 1.2.1
89
+ - [I] nokogiri ~> 1.4.1
90
+ - [I] panztel-actionwebservice = 2.3.5
91
+ - [R] actionpack = 2.3.5
92
+ - [R] activerecord = 2.3.5
93
+ - [I] fastthread
94
+ - [I] jammit = 0.4.4
95
+ EOT
96
+ gemspecs.should have(1).gemspec
97
+ gemspecs.first.should have(1).member
98
+ gemspecs.first[:name].should == 'gdata'
99
+ end
100
+ end
101
+ end
102
+
103
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
@@ -1,10 +1,9 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
3
  require 'rails_gem_install'
4
+ require 'spec'
5
+ require 'spec/autorun'
8
6
 
9
- class Test::Unit::TestCase
7
+ Spec::Runner.configure do |config|
8
+
10
9
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 2
9
- version: 0.3.2
8
+ - 3
9
+ version: 0.3.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott W. Bradley
@@ -14,21 +14,37 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-19 00:00:00 -07:00
17
+ date: 2010-12-07 00:00:00 -08:00
18
18
  default_executable: rails_gem_install
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: shoulda
21
+ name: rspec
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  segments:
28
- - 0
29
- version: "0"
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
30
32
  type: :development
31
33
  version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rcov
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 9
44
+ - 8
45
+ version: 0.9.8
46
+ type: :development
47
+ version_requirements: *id002
32
48
  description: "Installs gem dependencies for a Rails 2 project where `rake gems:install` fails. I.e.: breaks the circular dependencies of requiring Rails and anything your vendored gems/plugins require in order to install these requirements."
33
49
  email: scottwb@gmail.com
34
50
  executables:
@@ -50,8 +66,9 @@ files:
50
66
  - lib/rails_gem_install.rb
51
67
  - lib/rails_gem_install/rails.rb
52
68
  - lib/rails_gem_install/rails_gem_installer.rb
53
- - test/helper.rb
54
- - test/test_rails_gem_install.rb
69
+ - spec/rails_gem_installer_spec.rb
70
+ - spec/spec.opts
71
+ - spec/spec_helper.rb
55
72
  has_rdoc: true
56
73
  homepage: http://github.com/scottwb/rails_gem_install
57
74
  licenses: []
@@ -83,5 +100,5 @@ signing_key:
83
100
  specification_version: 3
84
101
  summary: Installs gem dependencies for a Rails 2 project.
85
102
  test_files:
86
- - test/helper.rb
87
- - test/test_rails_gem_install.rb
103
+ - spec/rails_gem_installer_spec.rb
104
+ - spec/spec_helper.rb
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestRailsGemInstall < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- #flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end