Module: Screenplay
- Extended by:
- Screenplay
- Included in:
- Screenplay
- Defined in:
- lib/screenplay.rb,
lib/screenplay/cast.rb,
lib/screenplay/actor.rb,
lib/screenplay/scenario.rb,
lib/screenplay/scenarios.rb,
lib/screenplay/actors/api.rb,
lib/screenplay/actors/data.rb,
lib/screenplay/actors/test.rb,
lib/screenplay/actors/cache.rb,
lib/screenplay/actors/prompt.rb,
lib/screenplay/configuration.rb
Defined Under Namespace
Modules: Cast, Configuration, Scenarios Classes: Actor, ApiActor, CacheActor, DataActor, MethodNotImplemented, PromptActor, Scenario, ScenarioFailedException, TestActor, TestFailedException, UnknownActorException, UnknownInputKeyException, UnknownTestException, UnsupportedTypeTestException, WrongResponseCodeException
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/screenplay.rb', line 14 def @options end |
Instance Method Details
#each_scene ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/screenplay.rb', line 57 def each_scene Scenarios.each { | scenario | input = {} index = 1 scenario.each { | actor_name, params | input = yield scenario, actor_name, params, input, index index += 1 } } end |
#play(options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/screenplay.rb', line 22 def play( = {}) @options = @options[:quiet] ||= false @options[:human_friendly] ||= false @options[:show_output] = @options[:show_output] && !@options[:quiet] raise 'ERROR: Couldn\'t find any scenarios to play.' if Scenarios.size == 0 # First check if we know all needed actors each_scene { | scenario_name, actor_name | raise UnknownActorException.new(scenario_name, actor_name) if Cast.get(actor_name).nil? } each_scene { | scenario, actor_name, params, input, index | puts "##### #{scenario.name} - #{actor_name}: #####" if !@options[:quiet] && @options[:show_output] params ||= {} begin output = Cast.get(actor_name).play(params, input) rescue Exception => e raise ScenarioFailedException.new(scenario, index, actor_name, e) end output.symbolize_keys! unless (@options[:quiet]) if (@options[:show_output]) puts 'output = ' + (@options[:human_friendly] ? JSON.pretty_generate(output) : output).to_s puts '' else STDOUT << '.' end end output } puts '' unless @options[:quiet] end |