C0 code coverage information

Generated on Sun Oct 26 11:18:15 -0500 2008 with rcov 0.8.1.2


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.
Name Total lines Lines of code Total coverage Code coverage
spec/aquarium/utils/options_utils_spec.rb 223 201
100.0% 
100.0% 
  1 
  2 require File.dirname(__FILE__) + '/../spec_helper'
  3 require 'aquarium/utils'
  4 
  5 include Aquarium::Utils
  6 
  7 module Aquarium
  8   class OptionsUtilsUser
  9     include OptionsUtils
 10     def initialize hash = {}
 11       init_specification hash, {}, []
 12     end
 13   end
 14 end
 15   
 16 describe OptionsUtils, "with no 'universal' options specified" do
 17   it "should use the default logger." do
 18     object = Aquarium::OptionsUtilsUser.new
 19     object.logger.should == DefaultLogger.logger
 20   end
 21 
 22   it "should set noop to false." do
 23     object = Aquarium::OptionsUtilsUser.new
 24     object.noop.should be_false
 25   end
 26 end
 27 
 28 describe OptionsUtils, ":logger option" do
 29   it "should set the object's logger to the specified logger." do
 30     logger = Logger.new STDOUT
 31     object = Aquarium::OptionsUtilsUser.new :logger => logger
 32     object.logger.should == logger    
 33   end
 34 end
 35 
 36 describe OptionsUtils, ":severity option" do
 37   it "should set the level on the object's logger to the :severity value." do
 38     logger = Logger.new STDOUT
 39     object = Aquarium::OptionsUtilsUser.new :logger => logger, :severity => Logger::Severity::WARN
 40     object.logger.level.should == Logger::Severity::WARN    
 41   end
 42   
 43   it "should cause the creation of a unique logger if one was not specified." do
 44     object = Aquarium::OptionsUtilsUser.new :severity => Logger::Severity::WARN
 45     object.logger.should_not eql(DefaultLogger.logger)
 46   end
 47 end
 48 
 49 describe OptionsUtils, ":logger_stream option" do
 50   it "should set the output stream on the object's logger to the :logger_stream value." do
 51     stringio = StringIO.new
 52     object = Aquarium::OptionsUtilsUser.new :logger_stream => stringio
 53     object.logger << "message"
 54     stringio.string.should eql("message")
 55   end
 56   
 57   it "should cause the creation of a unique logger if one was not specified." do
 58     stringio = StringIO.new
 59     object = Aquarium::OptionsUtilsUser.new :logger_stream => stringio
 60     object.logger.should_not eql(DefaultLogger.logger)
 61   end
 62 end
 63 
 64 describe OptionsUtils, ":logger_stream option" do
 65   it "should set the output stream on the object's logger to the :logger_stream value." do
 66     logger = Logger.new STDOUT
 67     object = Aquarium::OptionsUtilsUser.new :logger => logger, :severity => Logger::Severity::WARN
 68     object.logger.level.should == Logger::Severity::WARN    
 69   end
 70   
 71   it "should cause the creation of a unique logger if one was not specified." do
 72     object = Aquarium::OptionsUtilsUser.new :severity => Logger::Severity::WARN
 73     object.logger.should_not eql(DefaultLogger.logger)
 74   end
 75 end
 76 
 77 describe OptionsUtils, "#logger" do
 78   it "should return the logger specified with the :logger => ... option." do
 79     logger = Logger.new STDOUT
 80     object = Aquarium::OptionsUtilsUser.new :logger => logger
 81     object.logger.should == logger    
 82   end
 83 
 84   it "should return the default logger if no :logger => ... option was specified." do
 85     logger = Logger.new STDOUT
 86     object = Aquarium::OptionsUtilsUser.new 
 87     object.logger.should == DefaultLogger.logger
 88   end
 89 end
 90 
 91 describe OptionsUtils, "#logger=" do
 92   it "should set a new logger." do
 93     logger1 = Logger.new STDOUT
 94     logger2 = Logger.new STDERR
 95     object = Aquarium::OptionsUtilsUser.new :logger => logger1
 96     object.logger = logger2
 97     object.logger.should == logger2    
 98   end
 99 end
100 
101 describe OptionsUtils, "#noop" do
102   it "should return false if :noop was not specified." do
103     object = Aquarium::OptionsUtilsUser.new 
104     object.noop.should be_false
105   end
106 
107   it "should return the value specified with :noop." do
108     object = Aquarium::OptionsUtilsUser.new :noop => true
109     object.noop.should be_true
110   end
111 end
112 
113 describe OptionsUtils, "#noop=" do
114   it "should set the noop value." do
115     object = Aquarium::OptionsUtilsUser.new :noop => true
116     object.noop = false
117     object.noop.should be_false
118   end
119 end
120 
121 module Aquarium
122   class OptionsUtilsExample
123     include OptionsUtils
124     CANONICAL_OPTIONS = {
125       "foos" => %w[foo foo1 foo2],
126       "bars" => %w[bar bar1 bar2]
127     }
128     def initialize options = {}
129       init_specification options, CANONICAL_OPTIONS
130     end
131   end
132   
133   class OptionsUtilsExampleWithCanonicalOptionsAccessors < OptionsUtilsExample
134     canonical_option_accessor CANONICAL_OPTIONS
135   end
136   class OptionsUtilsExampleWithAccessors < OptionsUtilsExample
137     canonical_option_accessor :foos, :bars
138   end
139   class OptionsUtilsExampleWithReaders < OptionsUtilsExample
140     canonical_option_reader :foos, :bars
141   end
142   class OptionsUtilsExampleWithWriters < OptionsUtilsExample
143     canonical_option_writer :foos, :bars
144   end
145   class OptionsUtilsExampleWithAdditionalAllowedOptions
146     include OptionsUtils
147     CANONICAL_OPTIONS = {
148       "foos" => %w[foo foo1 foo2],
149       "bars" => %w[bar bar1 bar2]
150     }
151     canonical_option_writer :foos, :bars
152     def initialize options = {}
153       init_specification options, CANONICAL_OPTIONS, [:baz, :bbb]
154     end
155   end
156 end
157 
158 describe OptionsUtils, ".canonical_option_accessor" do
159   it "should create a reader and writer method for each option" do
160     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos")
161     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars")
162     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos=")
163     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars=")
164   end
165   it "should accept individual options" do
166     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos")
167     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars")
168     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos=")
169     Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars=")
170   end
171   it "should accept the CANONICAL_OPTIONS as an argument" do
172     Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("foos")
173     Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("bars")
174     Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("foos=")
175     Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("bars=")
176   end
177 end
178 describe OptionsUtils, ".canonical_option_reader" do
179   it "creates a reader method for each option" do
180     Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should include("foos")
181     Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should include("bars")
182     Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should_not include("foos=")
183     Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should_not include("bars=")
184   end
185   it "should create readers that return set values" do
186     object = Aquarium::OptionsUtilsExampleWithReaders.new
187     object.foos.class.should == Set
188   end
189 end
190 describe OptionsUtils, ".canonical_option_writer" do
191   it "creates a writer method for each option" do
192     Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should_not include("foos")
193     Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should_not include("bars")
194     Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should include("foos=")
195     Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should include("bars=")
196   end
197   it "should create writers that convert the input values to sets, if they aren't already sets" do
198     object = Aquarium::OptionsUtilsExampleWithAccessors.new
199     object.foos = "bar"
200     object.foos.class.should == Set
201   end
202   it "should create writers that leave the input sets unchanged" do
203     expected = Set.new([:b1, :b2])
204     object = Aquarium::OptionsUtilsExampleWithAccessors.new
205     object.foos = expected
206     object.foos.should == expected
207   end
208 end
209 
210 describe OptionsUtils, "and options handling" do
211   it "should raise if an unknown option is specified" do
212     lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :unknown => true}.should raise_error(Aquarium::Utils::InvalidOptions)
213   end
214   it "should not raise if a known canonical option is specified" do
215     lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :foos => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
216   end
217   it "should not raise if a known canonical option synonym is specified" do
218     lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :foo1 => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
219   end
220   it "should not raise if an known additional allowed option is specified" do
221     lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :baz => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
222   end
223 end

Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.

Valid XHTML 1.0! Valid CSS!