Geminstaller C0 Coverage Information - RCov

spec/unit/rogue_gem_finder_spec.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/unit/rogue_gem_finder_spec.rb 72 54
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 RogueGemFinder instance with mock dependencies" do
5   before(:each) do
6     @rogue_gem_finder = GemInstaller::RogueGemFinder.new
7     @mock_gem_spec_manager = mock("Mock GemSpecManager")
8     @mock_output_proxy = mock("Mock OutputProxy")
9     @rogue_gem_finder.gem_spec_manager = @mock_gem_spec_manager
10     @rogue_gem_finder.output_proxy = @mock_output_proxy
11 
12     @rogue_gem_name = 'rogue'
13     @rogue_gem = GemInstaller::RubyGem.new(@rogue_gem_name, :version => '1.0.0')
14     @legit_gem = GemInstaller::RubyGem.new('legit', :version => '1.0.0')
15   end
16 
17   it "should print rogue gems" do
18     @mock_gem_spec_manager.should_receive(:all_local_gems).and_return([@legit_gem, @rogue_gem])
19     @mock_gem_spec_manager.should_receive(:local_matching_gems).and_return([])
20 
21     valid_yaml = /---.*gems: .- name: rogue.  version: 1.0.0/m
22     @mock_output_proxy.should_receive(:sysout).with(valid_yaml)
23     
24     config_file_paths = []
25     output = @rogue_gem_finder.print_rogue_gems([@legit_gem], config_file_paths)
26     
27     boilerplate = /# .*GemInstaller.*/m
28     output.should match(boilerplate)
29   end
30 
31   it "should print message if gem is a preinstalled gem" do
32     @mock_gem_spec_manager.should_receive(:all_local_gems).and_return([@rogue_gem])
33     @mock_gem_spec_manager.should_receive(:local_matching_gems).and_return([])
34 
35     preinstalled_comment = "# preinstalled comment"
36     preinstalled_message_yaml_fragment = /- name: rogue #{preinstalled_comment}/m
37     @mock_output_proxy.should_receive(:sysout).with(preinstalled_message_yaml_fragment)
38     
39     config_file_paths = []
40     @rogue_gem_finder.preinstalled_gem_names = [@rogue_gem_name]
41     @rogue_gem_finder.preinstalled_comment = preinstalled_comment
42     output = @rogue_gem_finder.print_rogue_gems([@legit_gem], config_file_paths)
43     
44     boilerplate = /# .*GemInstaller.*/m
45     output.should match(boilerplate)
46   end
47 
48   it "should print message if passed an existing config with gems already specified" do
49     @mock_gem_spec_manager.should_receive(:all_local_gems).and_return([@rogue_gem])
50     @mock_gem_spec_manager.should_receive(:local_matching_gems).and_return([])
51 
52     @mock_output_proxy.should_receive(:sysout).with(anything())
53 
54     config_file_paths = ['my_config.yaml']
55     output = @rogue_gem_finder.print_rogue_gems([@legit_gem], config_file_paths)
56     
57     boilerplate = /# .*already specified.*/m
58     output.should match(boilerplate)
59   end
60 
61   it "should print message if passed an existing config with np gems already specified" do
62     @mock_gem_spec_manager.should_receive(:all_local_gems).and_return([@rogue_gem])
63 
64     @mock_output_proxy.should_receive(:sysout).with(anything())
65 
66     config_file_paths = ['my_config.yaml']
67     output = @rogue_gem_finder.print_rogue_gems([], config_file_paths)
68     
69     boilerplate = /# .*already specified.*/m
70     output.should match(boilerplate)
71   end
72 end

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