Geminstaller C0 Coverage Information - RCov

spec/functional/autogem_spec.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/functional/autogem_spec.rb 108 88
100.00%
100.00%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 dir = File.dirname(__FILE__)
2 require File.expand_path("#{dir}/../helper/spec_helper")
3 
4 describe "an AutoGem instance" do
5   before(:each) do
6     GemInstaller::TestGemHome.use
7     @registry = GemInstaller::create_registry
8     @autogem = @registry.autogem
9     # install all the sample gems
10     GemInstaller.install(["--config=#{dir}/live_geminstaller_config_all_sample_gems.yml"])
11     # Clear out loaded specs in rubygems, otherwise the gem call won't do anything
12     Gem.instance_eval { @loaded_specs.clear if @loaded_specs }
13   end
14 
15   it "should add a specified gem to the load path" do
16     delete_existing_path_entries(sample_gem)
17     added_gems = @autogem.autogem([sample_gem])
18     added_gems[0].should ==(sample_gem)
19     path_should_include_entries(sample_gem)
20   end
21   
22   it "should raise a custom exception if autoload is attempted for missing gem version" do
23     missing_gem = sample_gem
24     missing_version = '0.13.13'
25     missing_gem.version = missing_version
26     expected_message= /Error: GemInstaller attempted to load gem '#{sample_gem_name}', version '#{missing_version}', but that version is not installed.  Use GemInstaller to install the gem.  Original Gem::LoadError was: 'RubyGem version error: #{sample_gem_name}\(#{sample_gem_version} not = #{missing_version}\)'/
27     lambda { @autogem.autogem([missing_gem]) }.should raise_error(GemInstaller::GemInstallerError, expected_message)
28   end
29   
30   it "should not add a specified gem to the load path if the no_autogem property is set" do
31     @sample_gem_with_no_autogem = sample_gem
32     @sample_gem_with_no_autogem.no_autogem = true
33     delete_existing_path_entries(@sample_gem_with_no_autogem)
34     added_gems = @autogem.autogem([@sample_gem_with_no_autogem])
35     added_gems.size.should == 0
36     load_path_entries(@sample_gem_with_no_autogem).each do |entry|
37       $:.should_not include(entry)
38     end
39   end
40   
41   it "should add same specified gem to the load path again in a separate spec (verifies that Gem.loaded specs and load path are cleaned up between specs)" do
42     delete_existing_path_entries(sample_gem)
43     added_gems = @autogem.autogem([sample_gem])
44     added_gems[0].should ==(sample_gem)
45     path_should_include_entries(sample_gem)
46   end
47 
48   it "should add a dependent gem and it's dependency to the load path" do
49     delete_existing_path_entries(sample_dependent_gem)
50     delete_existing_path_entries(sample_gem)
51     
52     added_gems = @autogem.autogem([sample_dependent_gem])
53     added_gem_names = []
54     added_gems.each do |added_gem|
55       added_gem_names << added_gem.name
56     end
57     added_gem_names.should include(sample_dependent_gem.name)
58     # RubyGems automatically added sample_gem to the path (as verified below), but
59     # it's not in our array of gems we processed.
60     
61     path_should_include_entries(sample_dependent_gem)
62     path_should_include_entries(sample_gem)
63   end
64 
65   it "should add all gems in a multilevel dependency chain to the load path" do
66     delete_existing_path_entries(sample_dependent_multilevel_gem)
67     delete_existing_path_entries(sample_dependent_gem)
68     delete_existing_path_entries(sample_gem)
69     
70     added_gems = @autogem.autogem([sample_dependent_multilevel_gem])
71     added_gem_names = []
72     added_gems.each do |added_gem|
73       added_gem_names << added_gem.name
74     end
75     added_gem_names.should include(sample_dependent_multilevel_gem.name)
76     
77     path_should_include_entries(sample_dependent_multilevel_gem)
78     path_should_include_entries(sample_dependent_gem)
79     path_should_include_entries(sample_gem)
80   end
81 
82   def path_should_include_entries(gem)
83     load_path_entries(gem).each do |entry|
84       $:.should include(entry)
85     end
86   end
87 
88   def delete_existing_path_entries(gem)
89     load_path_entries(gem).each do |entry|
90       $:.delete(entry)
91       $:.should_not include(entry)
92     end
93   end
94 
95   def load_path_entries(gem)
96     name = gem.name
97     version = gem.version
98     [load_path_entry(name,version,"lib"),load_path_entry(name,version,"bin")]
99   end
100 
101   def load_path_entry(name,version,subdir)
102     "#{test_gem_home_dir}/gems/#{name}-#{version}/#{subdir}"
103   end
104 
105   after(:each) do
106     GemInstaller::TestGemHome.uninstall_all_test_gems
107   end
108 end

Generated on Mon May 10 23:40:29 -0700 2010 with rcov 0.9.8