Geminstaller C0 Coverage Information - RCov

spec/unit/valid_platform_selector_spec.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/unit/valid_platform_selector_spec.rb 105 86
5.71%
3.49%

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 if GemInstaller::RubyGemsVersionChecker.matches?('<=0.9.4')
5 # valid_platform_selector is not used for RubyGems >= 0.9.5
6 describe "a ValidPlatformSelector with prefer_binary_platform == true and no gem_platform passed" do
7   before(:each) do
8     common_setup_valid_platform_selector(true)
9   end
10 
11   it "should select @ruby_platform platform first, and default platform (ruby) last" do
12     should_select_correct_valid_platforms("i686-darwin8.7.1", nil, ['686-darwin', 'ruby'])
13     should_select_correct_valid_platforms("powerpc-darwin", nil, ['powerpc', 'ruby'])
14     should_select_correct_valid_platforms("i386-mswin32", nil, ['i386-mswin32', 'mswin32', 'ruby'])
15     should_select_correct_valid_platforms("i686-linux", nil, ['686-linux', 'ruby'])
16   end
17 end
18 
19 describe "a ValidPlatformSelector with prefer_binary_platform == true and a gem_platform passed" do
20   it "should select gem_platform first, @ruby_platform platform second, and default platform (ruby) last" do
21     common_setup_valid_platform_selector(true)
22     should_select_correct_valid_platforms("i686-darwin8.7.1", "gem-platform", ['gem-platform', '686-darwin', 'ruby'])
23   end
24 
25   it "should select correct platforms for various gem platforms" do
26     common_setup_valid_platform_selector(true)
27     should_select_correct_valid_platforms("i386-mswin32", "mswin32", ['i386-mswin32', 'mswin32', 'ruby'])
28   end
29 
30   it "should not duplicate dependent gem platform if it is already in the list (or if it is ruby, which will always be in the list)" do
31     common_setup_valid_platform_selector(true)
32     should_select_correct_valid_platforms("solaris", "solaris", ['solaris', 'ruby'])
33     should_select_correct_valid_platforms("solaris", "ruby", ['solaris', 'ruby'])
34   end
35 
36   it "should output a message indicating what platforms it selected" do
37     @valid_platform_selector = GemInstaller::ValidPlatformSelector.new
38     options = {:prefer_binary_platform => true}
39     @valid_platform_selector.options = options
40     @mock_output_filter = mock('Mock Output Filter')
41     @valid_platform_selector.output_filter = @mock_output_filter
42     expected_message = /Selecting .* @ruby_platform='.*', gem_platform=.*ruby.*, valid_platforms=.*solaris.*ruby/m
43     @mock_output_filter.should_receive(:geminstaller_output).once.with(:debug, expected_message)    
44     should_select_correct_valid_platforms("solaris", "ruby", ['solaris', 'ruby'])
45   end
46 end
47 
48 describe "a ValidPlatformSelector with prefer_binary_platform == false and no gem_platform passed" do
49   before(:each) do
50     common_setup_valid_platform_selector(false)
51   end
52 
53   it "should select default platform (ruby) first, and @ruby_platform platform last" do
54     should_select_correct_valid_platforms("i686-darwin8.7.1", nil, ['ruby', '686-darwin'])
55   end
56 end
57 
58 describe "a ValidPlatformSelector with prefer_binary_platform == false and a gem_platform passed" do
59   before(:each) do
60     common_setup_valid_platform_selector(false)
61   end
62 
63   it "should select gem_platform first, default platform (ruby) next, and @ruby_platform platform last" do
64     should_select_correct_valid_platforms("i686-darwin8.7.1", "gem-platform", ['gem-platform', 'ruby', '686-darwin'])
65   end
66 end
67 
68 describe "a ValidPlatformSelector with Gem::Platform::CURRENT platform passed" do
69   before(:each) do
70     common_setup_valid_platform_selector(false)
71   end
72 
73   it "should select only @ruby_platform platform" do
74     should_select_correct_valid_platforms("ruby_platform", Gem::Platform::CURRENT, ['ruby_platform'])
75   end
76 end
77 
78 describe "a ValidPlatformSelector with exact_platform_match = true" do
79   before(:each) do
80     common_setup_valid_platform_selector(false)
81   end
82 
83   it "should select only gem platform platform" do
84     valid_platforms = @valid_platform_selector.select("gem_platform", true)
85     valid_platforms.should == ['gem_platform']
86   end
87 end
88 
89 def common_setup_valid_platform_selector(prefer_binary_platform)
90   @valid_platform_selector = GemInstaller::ValidPlatformSelector.new
91   options = {:prefer_binary_platform => prefer_binary_platform}
92   @valid_platform_selector.options = options
93   @mock_output_filter = mock('Mock Output Filter')
94   @valid_platform_selector.output_filter = @mock_output_filter
95   @mock_output_filter.should_receive(:geminstaller_output).any_number_of_times.with(anything(),anything())    
96 end
97 
98 def should_select_correct_valid_platforms(ruby_platform, gem_platform, expected_valid_platforms)
99   @valid_platform_selector.ruby_platform = ruby_platform
100   valid_platforms = @valid_platform_selector.select(gem_platform)
101   valid_platforms.should == expected_valid_platforms
102 end
103 end
104 
105 

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