Class: Spectre::Specification
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#full_desc ⇒ Object
readonly
Returns the value of attribute full_desc.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(parent, name, desc, tags, data, file, block) ⇒ Specification
constructor
A new instance of Specification.
-
#run(engine, befores, afters, bag) ⇒ Object
Creates a new
RunContextand executes the spec,beforeandafterblocks.
Constructor Details
#initialize(parent, name, desc, tags, data, file, block) ⇒ Specification
Returns a new instance of Specification.
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 |
# File 'lib/spectre.rb', line 1173 def initialize parent, name, desc, , data, file, block @parent = parent @root = parent.root @name = name @desc = desc = @data = data @file = file @block = block @full_desc = "#{@parent.full_desc} #{@desc}" end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def data @data end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def desc @desc end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def file @file end |
#full_desc ⇒ Object (readonly)
Returns the value of attribute full_desc.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def full_desc @full_desc end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def parent @parent end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def root @root end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
1171 1172 1173 |
# File 'lib/spectre.rb', line 1171 def end |
Instance Method Details
#<=>(other) ⇒ Object
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 |
# File 'lib/spectre.rb', line 1185 def <=>(other) # Split on dash: text part and numeric part self_parts = @name.split('-') other_parts = other.name.split('-') text_compare = self_parts[0] <=> other_parts[0] # If the text parts are already different, we can return here return text_compare unless text_compare.zero? self_parts[1].to_i <=> other_parts[1].to_i end |
#run(engine, befores, afters, bag) ⇒ Object
Creates a new RunContext and executes the spec, before and after blocks
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
# File 'lib/spectre.rb', line 1202 def run engine, befores, afters, bag RunContext.new(engine, self, :spec, bag) do |run_context| engine.formatter.scope(@desc, self) do befores.each do |block| engine.formatter.scope('before', :before) do engine.logger.correlate do run_context.execute(@data, &block) end end end run_context.execute(@data, &@block) if run_context.status == :success ensure afters.each do |block| engine.formatter.scope('after', :after) do engine.logger.correlate do run_context.execute(@data, &block) end end end end end end |