C0 code coverage information
Generated on Sun Oct 26 11:18:06 -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.
1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'aquarium/aspects/default_objects_handler'
3
4 module Aquarium
5 class DefaultObjectsClass
6 include Aquarium::Aspects::DefaultObjectsHandler
7
8 attr_reader :specification
9
10 def initialize hash = {}
11 @specification = hash
12 end
13 end
14 end
15
16 describe Aquarium::Aspects::DefaultObjectsHandler, "#default_objects_given" do
17 it "should return an empty array if the specification contains no :default_object or :default_objects key." do
18 Aquarium::DefaultObjectsClass.new.default_objects_given.should == []
19 end
20
21 it "should return an array of objects that were specified with the :default_object key." do
22 defaults = ["1", "2"]
23 doc = Aquarium::DefaultObjectsClass.new :default_object => defaults
24 doc.default_objects_given.should == defaults
25 end
26
27 it "should return an array of objects that were specified with the :default_objects key." do
28 defaults = ["1", "2"]
29 doc = Aquarium::DefaultObjectsClass.new :default_objects => defaults
30 doc.default_objects_given.should == defaults
31 end
32
33 it "should return an array containing a single object if a single objects was specified with the :default_object key." do
34 default = "1"
35 doc = Aquarium::DefaultObjectsClass.new :default_object => default
36 doc.default_objects_given.should == [default]
37 end
38
39 it "should return an array containing a single object if a single objects was specified with the :default_objects key." do
40 default = "1"
41 doc = Aquarium::DefaultObjectsClass.new :default_objects => default
42 doc.default_objects_given.should == [default]
43 end
44 end
45
46 describe Aquarium::Aspects::DefaultObjectsHandler, "#default_objects_given?" do
47 it "should return false if the specification contains no :default_object or :default_objects key." do
48 Aquarium::DefaultObjectsClass.new.default_objects_given?.should be_false
49 end
50
51 it "should return true if one or more objects were specified with the :default_object key." do
52 defaults = ["1", "2"]
53 doc = Aquarium::DefaultObjectsClass.new :default_object => defaults
54 doc.default_objects_given?.should be_true
55 end
56
57 it "should return true if one or more objects were specified with the :default_objects key." do
58 defaults = ["1", "2"]
59 doc = Aquarium::DefaultObjectsClass.new :default_objects => defaults
60 doc.default_objects_given?.should be_true
61 end
62
63 it "should return true if a single objects was specified with the :default_object key." do
64 default = "1"
65 doc = Aquarium::DefaultObjectsClass.new :default_object => default
66 doc.default_objects_given?.should be_true
67 end
68
69 it "should return true if a single objects was specified with the :default_objects key." do
70 default = "1"
71 doc = Aquarium::DefaultObjectsClass.new :default_objects => default
72 doc.default_objects_given?.should be_true
73 end
74 end
75
76 describe Aquarium::Aspects::DefaultObjectsHandler, "#use_default_objects_if_defined" do
77 it "should not change the specification if no :default_object or :default_objects were defined." do
78 doc = Aquarium::DefaultObjectsClass.new
79 doc.use_default_objects_if_defined
80 doc.specification.should == {}
81 end
82
83 it "should set the :objects in the specification to an array of objects if :default_object was defined with an array of objects." do
84 defaults = ["1", "2"]
85 doc = Aquarium::DefaultObjectsClass.new :default_object => defaults
86 doc.use_default_objects_if_defined
87 doc.specification.should == {:default_object => defaults, :objects => defaults}
88 end
89
90 it "should set the :objects in the specification to an array of objects if :default_objects was defined with an array of objects." do
91 defaults = ["1", "2"]
92 doc = Aquarium::DefaultObjectsClass.new :default_objects => defaults
93 doc.use_default_objects_if_defined
94 doc.specification.should == {:default_objects => defaults, :objects => defaults}
95 end
96
97 it "should set the :objects in the specification to an array with one object if :default_object was defined with one object." do
98 default = "1"
99 doc = Aquarium::DefaultObjectsClass.new :default_object => default
100 doc.use_default_objects_if_defined
101 doc.specification.should == {:default_object => default, :objects => [default]}
102 end
103
104 it "should set the :objects in the specification to an array with one object if :default_objects was defined with one object." do
105 default = "1"
106 doc = Aquarium::DefaultObjectsClass.new :default_objects => default
107 doc.use_default_objects_if_defined
108 doc.specification.should == {:default_objects => default, :objects => [default]}
109 end
110
111 it "should set the :types in the specification to an array of types if :default_object was defined with an array of types." do
112 defaults = [String, Aquarium::DefaultObjectsClass]
113 doc = Aquarium::DefaultObjectsClass.new :default_object => defaults
114 doc.use_default_objects_if_defined
115 doc.specification.should == {:default_object => defaults, :types => defaults}
116 end
117
118 it "should set the :types in the specification to an array of types if :default_objects was defined with an array of types." do
119 defaults = [String, Aquarium::DefaultObjectsClass]
120 doc = Aquarium::DefaultObjectsClass.new :default_objects => defaults
121 doc.use_default_objects_if_defined
122 doc.specification.should == {:default_objects => defaults, :types => defaults}
123 end
124
125 it "should set the :types in the specification to an array with one type if :default_object was defined with one type." do
126 default = String
127 doc = Aquarium::DefaultObjectsClass.new :default_object => default
128 doc.use_default_objects_if_defined
129 doc.specification.should == {:default_object => default, :types => [default]}
130 end
131
132 it "should set the :types in the specification to an array with one type if :default_objects was defined with one type." do
133 default = String
134 doc = Aquarium::DefaultObjectsClass.new :default_objects => default
135 doc.use_default_objects_if_defined
136 doc.specification.should == {:default_objects => default, :types => [default]}
137 end
138
139 it "should set the :objects and :types in the specification to arrays of the corresponding objects and types if :default_objects was defined with objects and types." do
140 defaults = [String, Aquarium::DefaultObjectsClass, "1", "2"]
141 doc = Aquarium::DefaultObjectsClass.new :default_objects => defaults
142 doc.use_default_objects_if_defined
143 doc.specification.should == {:default_objects => defaults, :types => [String, Aquarium::DefaultObjectsClass], :objects => ["1", "2"]}
144 end
145
146 end
147
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.