Class: CodeDrivenDevelopment::TestComponent::Context
- Inherits:
-
Object
- Object
- CodeDrivenDevelopment::TestComponent::Context
- Defined in:
- lib/code_driven_development/test_component/context.rb
Instance Attribute Summary collapse
-
#befores ⇒ Object
readonly
Returns the value of attribute befores.
-
#description ⇒ Object
Returns the value of attribute description.
-
#doubles ⇒ Object
readonly
Returns the value of attribute doubles.
-
#lets ⇒ Object
readonly
Returns the value of attribute lets.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Instance Method Summary collapse
- #<<(child) ⇒ Object
- #indented_output(io) ⇒ Object
-
#initialize(description = nil, befores = [], tests = [], lets = [], subject = nil) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(description = nil, befores = [], tests = [], lets = [], subject = nil) ⇒ Context
Returns a new instance of Context.
4 5 6 |
# File 'lib/code_driven_development/test_component/context.rb', line 4 def initialize(description = nil, befores = [], tests = [], lets = [], subject = nil) @description, @befores, @tests, @lets, @subject, @doubles = description, befores, tests, lets, subject, [] end |
Instance Attribute Details
#befores ⇒ Object (readonly)
Returns the value of attribute befores.
8 9 10 |
# File 'lib/code_driven_development/test_component/context.rb', line 8 def befores @befores end |
#description ⇒ Object
Returns the value of attribute description.
9 10 11 |
# File 'lib/code_driven_development/test_component/context.rb', line 9 def description @description end |
#doubles ⇒ Object (readonly)
Returns the value of attribute doubles.
8 9 10 |
# File 'lib/code_driven_development/test_component/context.rb', line 8 def doubles @doubles end |
#lets ⇒ Object (readonly)
Returns the value of attribute lets.
8 9 10 |
# File 'lib/code_driven_development/test_component/context.rb', line 8 def lets @lets end |
#subject ⇒ Object
Returns the value of attribute subject.
9 10 11 |
# File 'lib/code_driven_development/test_component/context.rb', line 9 def subject @subject end |
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
8 9 10 |
# File 'lib/code_driven_development/test_component/context.rb', line 8 def tests @tests end |
Instance Method Details
#<<(child) ⇒ Object
11 12 13 |
# File 'lib/code_driven_development/test_component/context.rb', line 11 def << child @tests << child end |
#indented_output(io) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/code_driven_development/test_component/context.rb', line 15 def indented_output io io << "describe #@description do" io.indented do lets.each do |let| let.indented_output(io) end doubles.each do |double| double.indented_output(io) end if subject io << "subject { #{subject} }" end if befores.any? io << "before do" io.indented do befores.each { |before| io << before } end io << "end" end tests.each { |test| test.indented_output(io) } end io << "end" end |