Geminstaller C0 Coverage Information - RCov

spec/functional/config_builder_spec.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/functional/config_builder_spec.rb 179 152
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 GemInstaller::ConfigBuilder, "with no config file path set and no default config files existing" do
5   before(:each) do
6     config_builder_spec_fixture
7     @config_builder = GemInstaller::ConfigBuilder.new(['not_there.yml'])
8   end
9 
10   it "raises exception" do
11     proc{ @config_builder.build_config }.should raise_error(GemInstaller::MissingFileError)
12   end
13 end
14 
15 describe GemInstaller::ConfigBuilder, "with no config file path set and run from dir containing geminstaller.yml" do
16   before(:each) do
17     Dir.chdir("#{dir}/../..") do
18       File.should be_exists("./geminstaller.yml")
19       config_builder_spec_fixture
20       @config_builder.build_config
21     end
22   end
23 
24   it "should assign paths array to config_file_paths_array instance variable" do
25     @config_builder.config_file_paths_array.should==(['geminstaller.yml','config/geminstaller.yml','ci/geminstaller.yml'])
26   end
27 end
28 
29 describe GemInstaller::ConfigBuilder, "with a single config file path" do
30   before(:each) do
31     @test_config_file_paths = File.expand_path("#{dir}/test_geminstaller_config.yml")
32     config_builder_spec_common_setup
33   end
34 
35   it "should successfully assemble a config object with default overrides" do
36     @config.gems[0].name.should==("testgem1")
37     @config.gems[0].check_for_upgrade.should==(true)
38     @config.gems[0].fix_dependencies.should==(false)
39     @config.gems[1].check_for_upgrade.should==(false)
40     @config.gems[1].fix_dependencies.should==(false)
41   end
42 
43   it "should assign paths array to config_file_paths_array instance variable" do
44     @config_builder.config_file_paths_array.should==([@test_config_file_paths])
45   end
46 end
47 
48 describe GemInstaller::ConfigBuilder, "with a non-alphabetical ordering of gems in config file" do
49   it "retains order of gems from original file" do
50     @test_config_file_paths = File.expand_path("#{dir}/test_geminstaller_config_2.yml")
51     config_builder_spec_common_setup
52     @config_builder.build_config
53     @config.gems[0].name.should==("testgem1")
54     @config.gems[1].name.should==("testgem3")
55     @config.gems[2].name.should==("testgem2")
56   end
57 end
58 
59 describe GemInstaller::ConfigBuilder, "with a config containing no gems" do
60   before(:each) do
61     @test_config_file_paths = File.expand_path("#{dir}/empty_geminstaller_config.yml")
62     config_builder_spec_common_setup
63   end
64 
65   it "should not raise an error" do
66     @config.gems.size.should == 0
67   end
68 end
69 
70 describe GemInstaller::ConfigBuilder, "with a config containing a path evaluated via erb" do
71   it "should evaluate working directory to path of config file" do
72     @test_config_file_paths = File.expand_path("#{dir}/../fixture/evaluate_path_geminstaller_config.yml")
73     @test_config_file_dir = File.dirname(@test_config_file_paths)
74     config_builder_spec_common_setup
75     install_options = @config.gems[0].install_options
76     install_options[0].should == @test_config_file_dir
77     install_options[1].should == @test_config_file_dir
78   end
79 end
80 
81 describe GemInstaller::ConfigBuilder, "with a config containing an include_config call" do
82   it "should include proper config file" do
83     @test_config_file_paths = File.expand_path("#{dir}/../fixture/including_geminstaller_config.yml")
84     @test_config_file_dir = File.dirname(@test_config_file_paths)
85     @included_config_file_dir1 = File.expand_path("#{dir}/../fixture/subdir1")
86     @included_config_file_dir2 = File.expand_path("#{dir}/../fixture/subdir2")
87     config_builder_spec_common_setup
88     install_options1 = @config.gems[0].install_options
89     install_options1[0].should == @included_config_file_dir1
90     install_options1[1].should == @included_config_file_dir1
91     install_options2 = @config.gems[1].install_options
92     install_options2[0].should == @included_config_file_dir2
93     install_options2[1].should == @included_config_file_dir2
94   end
95 end
96 
97 describe GemInstaller::ConfigBuilder, "with multiple config file paths" do
98   before(:each) do
99     @test_config_file_paths = 
100       File.expand_path("#{dir}/test_geminstaller_config.yml") + "," + 
101       File.expand_path("#{dir}/test_geminstaller_config_2.yml")
102     config_builder_spec_common_setup
103   end
104   
105   it "should successfully assemble a config object" do
106     testgem1_v11 = @config.gems.detect {|g| g.name == 'testgem1' && g.version == 'v1.1'}
107     testgem1_v11.check_for_upgrade.should==(true)
108     testgem1_v11.fix_dependencies.should==(false)
109     
110     testgem1_v20 = @config.gems.detect {|g| g.name == 'testgem1' && g.version == 'v2.0'}
111     testgem1_v20.should_not be_nil
112   end
113 
114   it "should take defaults from previous files if they are not overridden" do
115     @config.gems[0].install_options.should==(['-y'])
116   end
117 
118   it "should allow subsequent files to override defaults" do
119     testgem2 = @config.gems.detect {|g| g.name == 'testgem2'}
120     testgem2.version.should==("v1.2")
121     testgem2.check_for_upgrade.should==(false)
122   end
123   
124   it "should allow subsequent files to override a gem"do
125     testgem2 = @config.gems.detect {|g| g.name == 'testgem2'}
126     testgem2.install_options.should==(["--backtrace"])
127   end
128 
129   it "should allow subsequent files to specify new gems"do
130     testgem3 = @config.gems.detect {|g| g.name == 'testgem3'}
131     testgem3.version.should==("v3.0")
132     testgem3.check_for_upgrade.should==(true)
133   end
134 end
135 
136 describe GemInstaller::ConfigBuilder, "with multiple config file paths and no default entries in the override file" do
137   before(:each) do
138     @test_config_file_paths = 
139       File.expand_path("#{dir}/test_geminstaller_config.yml") + "," + 
140       File.expand_path("#{dir}/test_geminstaller_config_3.yml")
141     config_builder_spec_common_setup
142   end
143   
144   it "should successfully assemble a config object" do
145     #TODO: finish this spec
146   end
147 end
148 
149 describe GemInstaller::ConfigBuilder, "with an empty config file" do
150   before(:each) do
151     @test_config_file_paths = File.expand_path("#{dir}/test_empty_file.yml")
152     config_builder_spec_common_setup
153   end
154   
155   it "should return a default config" do
156     @config.gems.should == []
157   end
158 end
159 
160 describe GemInstaller::ConfigBuilder, "with a config containing a prerelease gem" do
161   it "does not blow up" do
162     @test_config_file_paths = File.expand_path("#{dir}/../fixture/prerelease_geminstaller_config.yml")
163     @test_config_file_dir = File.dirname(@test_config_file_paths)
164     config_builder_spec_common_setup
165     version = @config.gems[0].version
166     version.should == '1.0.beta'
167   end
168 end
169 
170 def config_builder_spec_fixture
171   registry = GemInstaller::Registry.new
172   @config_builder = registry.config_builder
173   @config_builder.config_file_paths = @test_config_file_paths if @test_config_file_paths
174 end
175 
176 def config_builder_spec_common_setup
177   config_builder_spec_fixture
178   @config = @config_builder.build_config
179 end

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