Geminstaller C0 Coverage Information - RCov

spec/helper/spec_utils.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/helper/spec_utils.rb 222 174
89.19%
86.78%

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 module GemInstaller
2   module SpecUtils  
3     def self.included(base)
4       base.extend(ClassMethods)
5     end
6 
7     module ClassMethods
8       def test_gems
9         [sample_gem, sample_dependent_gem, sample_dependent_depends_on_multiplatform_gem,
10           sample_multiplatform_gem_ruby, sample_multiplatform_gem,
11           sample_dependent_multilevel_gem, sample_dependent_multiplatform_gem]
12       end
13     
14       def ruby_cmd
15         "ruby -I #{rubygems_lib_dir}#{File::PATH_SEPARATOR}#{rubygems_bin_dir}#{File::PATH_SEPARATOR}#{geminstaller_lib_dir}"
16       end
17       
18       def gem_cmd
19         "#{ruby_cmd} #{rubygems_bin_dir}/gem"
20       end
21       
22       def geminstaller_root_dir
23         File.expand_path(File.dirname(__FILE__) + "/../..")
24       end
25 
26       def geminstaller_lib_dir
27         "#{geminstaller_root_dir}/lib"
28       end
29 
30       def geminstaller_bin_dir
31         "#{geminstaller_root_dir}/bin"
32       end
33 
34       def geminstaller_executable
35         "#{geminstaller_bin_dir}/geminstaller"
36       end
37 
38       def test_gem_home_dir
39         dir_name = "test_gem_home"
40         File.expand_path(File.dirname(__FILE__) + "/../tmp/#{dir_name}")
41       end
42 
43       def siteruby_dir
44         "#{test_gem_home_dir}/site_ruby"
45       end
46   
47       def siterubyver_dir
48         "#{siteruby_dir}/1.8"
49       end
50 
51       def rubygems_dist
52         if RUBY_PLATFORM =~ /mswin/ && ENV['RUBYGEMS_VERSION']
53           raise "ERROR: On Windows, the GemInstaller tests do not support overriding RUBYGEMS_VERSION.   Manually install the version of RubyGems you wish to test"
54         end
55         ENV['RUBYGEMS_VERSION'] || 'trunk'
56       end
57 
58       def rubygems_dist_dir
59         File.expand_path(File.dirname(__FILE__) + "/../fixture/rubygems_dist/rubygems-#{rubygems_dist}")
60       end
61   
62       def rubygems_lib_dir
63         "#{rubygems_dist_dir}/lib"
64       end
65   
66       def rubygems_bin_dir
67         "#{rubygems_dist_dir}/bin"
68       end
69   
70       def test_rubygems_config_file
71         file_name = "test_gem.rc"
72         File.expand_path(File.dirname(__FILE__) + "/../tmp/#{file_name}")
73       end
74   
75       def sample_gem_name
76         "stubgem"
77       end
78 
79       def sample_gem_version
80         "1.0.0"
81       end
82 
83       def sample_dependent_gem_name
84         "dependent-stubgem"
85       end
86 
87       def sample_dependent_multiplatform_gem_name
88         "dependent-stubgem-multiplatform"
89       end
90 
91       def sample_dependent_depends_on_multiplatform_gem_name
92         "dependent-stubgem-depends-on-multiplatform"
93       end
94 
95       def sample_dependent_gem_version
96         "1.0.0"
97       end
98 
99       def sample_dependent_multilevel_gem_name
100         "dependent-stubgem-multilevel"
101       end
102 
103       def sample_multiplatform_gem_name
104         "stubgem-multiplatform"
105       end
106 
107       def sample_multiplatform_gem_version_low
108         "1.0.0"
109       end
110   
111       def sample_multiplatform_gem_version
112         "1.0.1"
113       end
114   
115       def embedded_gem_server_port
116         9909
117       end
118 
119       def embedded_gem_server_url
120         "http://127.0.0.1:#{embedded_gem_server_port}"
121       end
122   
123       def install_options_for_testing
124         # TODO: fix tests so no-ri no-rdoc works...
125         # ['--no-ri', '--no-rdoc'] + options_for_testing
126         options_for_testing
127       end
128       
129       def options_for_testing
130         ['--backtrace','--config-file', test_rubygems_config_file]
131       end
132     
133       def uninstall_options_for_testing
134         ['--backtrace', '--all', '--ignore-dependencies', '--executables', '--config-file', test_rubygems_config_file]
135       end
136     
137       def sample_gem(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
138         GemInstaller::RubyGem.new(sample_gem_name, :version => sample_gem_version, :install_options => install_options, :uninstall_options => uninstall_options)
139       end
140   
141       def sample_dependent_gem(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
142         GemInstaller::RubyGem.new(sample_dependent_gem_name, :version => sample_dependent_gem_version, :install_options => install_options, :uninstall_options => uninstall_options)
143       end
144   
145       def sample_dependent_multilevel_gem(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
146         GemInstaller::RubyGem.new(sample_dependent_multilevel_gem_name, :version => sample_dependent_gem_version, :install_options => install_options, :uninstall_options => uninstall_options)
147       end
148   
149       def sample_dependent_depends_on_multiplatform_gem(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
150         GemInstaller::RubyGem.new(sample_dependent_depends_on_multiplatform_gem_name, :version => sample_dependent_gem_version, :install_options => install_options, :uninstall_options => uninstall_options)
151       end
152   
153       def sample_multiplatform_gem(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
154         GemInstaller::RubyGem.new(sample_multiplatform_gem_name, :version => sample_multiplatform_gem_version, :platform => 'mswin32', :install_options => install_options, :uninstall_options => uninstall_options)
155       end
156   
157       def sample_multiplatform_gem_lower_version(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
158         GemInstaller::RubyGem.new(sample_multiplatform_gem_name, :version => sample_multiplatform_gem_version_low, :platform => 'mswin32', :install_options => install_options, :uninstall_options => uninstall_options)
159       end
160 
161       def sample_multiplatform_gem_ruby(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
162         gem = sample_multiplatform_gem(install_options, uninstall_options)
163         gem.platform = 'ruby'
164         gem
165       end
166 
167       def sample_dependent_multiplatform_gem(install_options=install_options_for_testing, uninstall_options=uninstall_options_for_testing)
168         GemInstaller::RubyGem.new(sample_dependent_multiplatform_gem_name, :version => sample_multiplatform_gem_version_low, :platform => 'mswin32', :install_options => install_options, :uninstall_options => uninstall_options)
169       end
170 
171       def remove_geminstaller_from_require_array
172         require_array_copy = $".dup
173         require_array_copy.each do |require_array_entry|
174           $".delete(require_array_entry) if require_array_entry =~ /geminstaller/
175         end
176       end
177   
178       def proc_should_raise_with_message(message_regex, &block)
179         error = nil
180         lambda {
181           begin
182             block.call
183           rescue GemInstaller::GemInstallerError => error
184             raise error
185           end
186           }.should raise_error(GemInstaller::GemInstallerError)
187           error.message.should match(message_regex)
188       end
189       
190       def install_gem(gem)
191         install_result = @gem_command_manager.install_gem(gem)
192         begin
193           @gem_spec_manager.is_gem_installed?(gem).should==(true)
194         rescue Spec::Expectations::ExpectationNotMetError => e
195           p install_result
196           raise e
197         end
198       end
199       
200     end
201   end
202 end
203 
204 class MockStderr
205   attr_reader :err
206   def write(out)
207   end
208   
209   def print(err)
210     @err = err
211   end
212 end
213 
214 class MockStdout
215   attr_reader :out
216   def write(out)
217   end
218   
219   def print(out)
220     @out = out
221   end
222 end

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