Geminstaller C0 Coverage Information - RCov

spec/functional/gem_interaction_handler_spec.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/functional/gem_interaction_handler_spec.rb 85 73
4.71%
4.11%

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 # gem_interaction_handler is not used for RubyGems >= 0.9.5
6 describe "a GemInteractionHandler instance with a non-multiplatform dependent gem and non-multiplatform dependency gem" do
7   before(:each) do
8     gem_interaction_handler_spec_setup_common(sample_dependent_gem, sample_gem)    
9   end
10 
11   it "should raise UnauthorizedDependencyPromptError from handle_ask_yes_no if question is a dependency prompt" do
12     @gem_interaction_handler.dependent_gem = @dependent_gem
13     question = GemInstaller::GemInteractionHandler::DEPENDENCY_PROMPT
14     begin
15       @gem_interaction_handler.handle_ask_yes_no(question)
16     rescue GemInstaller::UnauthorizedDependencyPromptError => error
17       expected_error_message = /RubyGems is prompting to install a required dependency/m
18       error.message.should match(expected_error_message)
19     end
20   end
21 
22   it "should call noninteractive_chooser for dependent gem if handle_choose_from_list is passed an install-formatted list for the dependent gem" do
23     @gem_interaction_handler.dependent_gem = @dependent_gem
24     list = ["#{@dependent_gem.name} #{@dependent_gem.version} (#{@dependent_gem.platform})"]
25     list << 'Cancel'
26     should_choose_properly(list, 0)
27   end
28 
29   it "should choose properly if handle_choose_from_list is passed an install-formatted list for a non-dependent gem" do
30     @gem_interaction_handler.dependent_gem = @dependent_gem
31     list = ["#{@dependency_gem.name} #{@dependency_gem.version} (#{@dependency_gem.platform})"]
32     should_choose_properly(list, 0)
33   end
34 end
35 
36 describe "a GemInteractionHandler instance with a non-multiplatform dependency gem and multiplatform dependent gem" do
37   before(:each) do
38     gem_interaction_handler_spec_setup_common(sample_dependent_depends_on_multiplatform_gem, sample_dependent_multiplatform_gem)    
39     @valid_platform_selector = @registry.valid_platform_selector
40     @valid_platform_selector.ruby_platform = "i386-mswin32"
41   end
42 
43   it "should choose multiplatform dependency gem before ruby platform" do
44     @gem_interaction_handler.dependent_gem = @dependent_gem
45     list = ["#{@dependency_gem.name} #{@dependency_gem.version} (#{GemInstaller::RubyGem.default_platform})"]
46     list << "#{@dependency_gem.name} #{@dependency_gem.version} (#{@dependency_gem.platform})"
47     list << 'Cancel'
48     should_choose_properly(list, 1)
49   end
50 
51   it "should choose ruby platform if no matching valid binary platform is found" do
52     @gem_interaction_handler.dependent_gem = @dependent_gem
53     list = ["#{@dependency_gem.name} #{@dependency_gem.version} (nonmatching-binary-platform)"]
54     list << "#{@dependency_gem.name} #{@dependency_gem.version} (#{GemInstaller::RubyGem.default_platform})"
55     list << 'Cancel'
56     should_choose_properly(list, 1)
57   end
58 
59   it "should choose dependent gem platform if it is specified and the list is for the dependent gem, even if other matches exist" do
60     @dependent_gem.platform = "i386-mswin32"
61     @gem_interaction_handler.dependent_gem = @dependent_gem
62     list = ["#{@dependent_gem.name} #{@dependent_gem.version} (#{GemInstaller::RubyGem.default_platform})"]
63     list << "#{@dependent_gem.name} #{@dependent_gem.version} (i386-mswin32)"
64     list << "#{@dependent_gem.name} #{@dependent_gem.version} (#{@dependent_gem.platform})"
65     list << 'Cancel'
66     should_choose_properly(list, 1)
67   end
68 
69 end
70 
71 def should_choose_properly(list, expected_item_index)
72   question = "Select which gem to install for your platform (i686-darwin8.7.1)"
73   item, index = @gem_interaction_handler.handle_choose_from_list(question, list)
74   item.should==(list[expected_item_index])
75   index.should==(expected_item_index)
76 end
77 
78 def gem_interaction_handler_spec_setup_common(dependent_gem, dependency_gem)
79   GemInstaller::OverrideDefaultSource.override_default_gem_source
80   @registry = GemInstaller::create_registry
81   @gem_interaction_handler = @registry.gem_interaction_handler
82   @dependent_gem = dependent_gem
83   @dependency_gem = dependency_gem
84 end
85 end

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