Class: Marso::ScenarioContext
- Defined in:
- lib/marso/domain/scenario/scenario.rb
Instance Attribute Summary collapse
-
#after_run ⇒ Object
readonly
Returns the value of attribute after_run.
-
#before_run ⇒ Object
readonly
Returns the value of attribute before_run.
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#feature_id ⇒ Object
readonly
Returns the value of attribute feature_id.
-
#get_scenario ⇒ Object
readonly
Returns the value of attribute get_scenario.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#story_id ⇒ Object
readonly
Returns the value of attribute story_id.
Instance Method Summary collapse
- #indented_colorized_text ⇒ Object
-
#initialize(description, ctx) ⇒ ScenarioContext
constructor
A new instance of ScenarioContext.
- #puts_scenario ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(description, ctx) ⇒ ScenarioContext
Returns a new instance of ScenarioContext.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/marso/domain/scenario/scenario.rb', line 12 def initialize(description, ctx) validate_arguments(description, ctx) @description = description.clone @ctx=ctx.clone @description[:id] = SecureRandom.hex(3) if description[:id].nil? @description[:status] = :none if description[:status].nil? @id = @description[:id] @before_run = @description[:before_run] @get_scenario = @description[:get_scenario] @after_run = @description[:after_run] @status = @description[:status] @story_id = ctx[:story_id] @feature_id = ctx[:feature_id] end |
Instance Attribute Details
#after_run ⇒ Object (readonly)
Returns the value of attribute after_run.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def after_run @after_run end |
#before_run ⇒ Object (readonly)
Returns the value of attribute before_run.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def before_run @before_run end |
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def ctx @ctx end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def description @description end |
#feature_id ⇒ Object (readonly)
Returns the value of attribute feature_id.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def feature_id @feature_id end |
#get_scenario ⇒ Object (readonly)
Returns the value of attribute get_scenario.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def get_scenario @get_scenario end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def id @id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def status @status end |
#story_id ⇒ Object (readonly)
Returns the value of attribute story_id.
9 10 11 |
# File 'lib/marso/domain/scenario/scenario.rb', line 9 def story_id @story_id end |
Instance Method Details
#indented_colorized_text ⇒ Object
49 50 51 52 |
# File 'lib/marso/domain/scenario/scenario.rb', line 49 def indented_colorized_text s = @get_scenario.call(@id, @ctx) s.indented_colorized_text end |
#puts_scenario ⇒ Object
44 45 46 47 |
# File 'lib/marso/domain/scenario/scenario.rb', line 44 def puts_scenario s = @get_scenario.call(@id, @ctx) s.puts_description end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/marso/domain/scenario/scenario.rb', line 31 def run @before_run.call(@description[:id], @ctx) unless @before_run.nil? s = @get_scenario.call(@id, @ctx) runned_scenario = s.run @after_run.call(@id, @ctx) unless @after_run.nil? updated_description = @description.clone updated_description[:get_scenario] = proc { runned_scenario } updated_description[:status] = runned_scenario.status return ScenarioContext.new(updated_description, @ctx) end |