screenplay 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/screenplay +6 -1
- data/lib/screenplay.rb +9 -3
- data/lib/screenplay/actor.rb +2 -2
- data/lib/screenplay/actors/api.rb +6 -5
- data/lib/screenplay/actors/cache.rb +3 -3
- data/lib/screenplay/actors/test.rb +4 -4
- data/lib/screenplay/cast.rb +1 -1
- data/lib/screenplay/datatype-extensions.rb +2 -0
- data/lib/screenplay/scenario.rb +9 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44f52b1b8d4f20187a8b6b5cb50694b252ebca2e
|
|
4
|
+
data.tar.gz: 1235e198871f25c604b7916121aa04b7ff30b6f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dc4d49f25e01384ac4880d6dd1be2cd6b82e2b842b59e85885fb8e8369c5be5698e2493fc7d53c590beea0544063f7428dd6e1cb2439ad69b70d7d1e3c4bf62
|
|
7
|
+
data.tar.gz: 02d6d947663b07aa93e6e83bf5b7e4d462234673a624e1d99a309bb8251b3f97fa14db8e84028c50e06ce964214d07780c25601a5e0475a51ac365657babe856
|
data/bin/screenplay
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
+
$:.unshift(Dir.pwd)
|
|
3
4
|
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
|
4
5
|
|
|
5
6
|
require 'screenplay'
|
|
@@ -22,7 +23,8 @@ $ARGV_PARSER = OptionParser.new { | opts |
|
|
|
22
23
|
opts.on('-a DIR', '--actors DIR', 'Directory where custom actors can be found. By default in the ./actors directory near the config file.') { | d | $SCREENPLAY_ACTORS_DIR = d }
|
|
23
24
|
opts.on('-s DIR', '--scenarios DIR', 'Directory where the scenarios can be found. By default in the ./scenarios director near the config file.') { | d | $SCREENPLAY_SCENARIOS_DIR = d }
|
|
24
25
|
opts.on('-d', '--debug', 'Shows full stack trace on when failed. Especially usefull when developing new actors or other information.') { $SCREENPLAY_OPTIONS[:debug] = true }
|
|
25
|
-
opts.on('-q', '--quiet', 'Doesn\'t show the output of the scenes.') { $SCREENPLAY_OPTIONS[:quiet] = true }
|
|
26
|
+
opts.on('-q', '--quiet', 'Doesn\'t show dots or the output of the scenes.') { $SCREENPLAY_OPTIONS[:quiet] = true }
|
|
27
|
+
opts.on('-o', '--show-output', 'Show the output of the scenes instead of dots.') { $SCREENPLAY_OPTIONS[:show_output] = true }
|
|
26
28
|
opts.on('-h', '--human-friendly', 'Formats outputted JSON.') { $SCREENPLAY_OPTIONS[:human_friendly] = true }
|
|
27
29
|
opts.separator('')
|
|
28
30
|
}
|
|
@@ -36,6 +38,9 @@ def play
|
|
|
36
38
|
Screenplay.prepare
|
|
37
39
|
begin
|
|
38
40
|
Screenplay.play($SCREENPLAY_OPTIONS)
|
|
41
|
+
rescue Screenplay::ScenarioFailedException => e
|
|
42
|
+
raise e.inner_exception if $SCREENPLAY_OPTIONS[:debug]
|
|
43
|
+
abort(e.message)
|
|
39
44
|
rescue Exception => e
|
|
40
45
|
raise if $SCREENPLAY_OPTIONS[:debug]
|
|
41
46
|
abort(e.message)
|
data/lib/screenplay.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Screenplay
|
|
|
21
21
|
options[:quiet] ||= false
|
|
22
22
|
options[:human_friendly] ||= false
|
|
23
23
|
|
|
24
|
-
raise
|
|
24
|
+
raise 'ERROR: Couldn\'t find any scenarios to play.' if Scenarios.size == 0
|
|
25
25
|
|
|
26
26
|
# First check if we know all needed actors
|
|
27
27
|
each_scene { | scenario_name, actor_name |
|
|
@@ -29,20 +29,26 @@ module Screenplay
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
each_scene { | scenario, actor_name, params, input, index |
|
|
32
|
-
puts "##### #{scenario.name} - #{actor_name}: #####"
|
|
32
|
+
puts "##### #{scenario.name} - #{actor_name}: #####" if !options[:quiet] && options[:show_output]
|
|
33
|
+
params ||= {}
|
|
33
34
|
begin
|
|
34
35
|
output = Cast.get(actor_name).play(params, input)
|
|
35
36
|
rescue Exception => e
|
|
36
|
-
raise ScenarioFailedException.new(scenario, index, actor_name, e
|
|
37
|
+
raise ScenarioFailedException.new(scenario, index, actor_name, e)
|
|
37
38
|
end
|
|
38
39
|
output.symbolize_keys!
|
|
39
40
|
unless (options[:quiet])
|
|
41
|
+
if (options[:show_output])
|
|
40
42
|
output_str = options[:human_friendly] ? JSON.pretty_generate(output) : output.to_s
|
|
41
43
|
puts "output = #{output_str}"
|
|
42
44
|
puts ''
|
|
45
|
+
else
|
|
46
|
+
STDOUT << '.'
|
|
47
|
+
end
|
|
43
48
|
end
|
|
44
49
|
output
|
|
45
50
|
}
|
|
51
|
+
puts '' unless (options[:quiet])
|
|
46
52
|
end
|
|
47
53
|
|
|
48
54
|
def each_scene
|
data/lib/screenplay/actor.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'screenplay/configuration'
|
|
|
3
3
|
|
|
4
4
|
module Screenplay
|
|
5
5
|
|
|
6
|
-
class MethodNotImplemented <
|
|
6
|
+
class MethodNotImplemented < StandardError
|
|
7
7
|
|
|
8
8
|
def initialize(name)
|
|
9
9
|
super("Method #{name} is not implemented.")
|
|
@@ -12,7 +12,7 @@ module Screenplay
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class UnknownActorException <
|
|
15
|
+
class UnknownActorException < StandardError
|
|
16
16
|
|
|
17
17
|
def initialize(scenario, name)
|
|
18
18
|
super("The scenario #{scenario} uses unknown actor #{name}.")
|
|
@@ -3,9 +3,9 @@ require File.join(File.dirname(__FILE__), '..', 'actor')
|
|
|
3
3
|
|
|
4
4
|
module Screenplay
|
|
5
5
|
|
|
6
|
-
class WrongResponseCodeException <
|
|
7
|
-
def initialize(expected, actual)
|
|
8
|
-
super("Expected HTTP response code #{expected}, but received #{actual}.")
|
|
6
|
+
class WrongResponseCodeException < StandardError
|
|
7
|
+
def initialize(expected, actual, body)
|
|
8
|
+
super("Expected HTTP response code #{expected}, but received #{actual}. Response body was: #{body}")
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -21,7 +21,7 @@ module Screenplay
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def play(params, input)
|
|
24
|
-
raise
|
|
24
|
+
raise 'Missing configuration api.url' if @url == '/'
|
|
25
25
|
path = params[:path]
|
|
26
26
|
method = params[:method].downcase.to_sym rescue :get
|
|
27
27
|
expects = (params[:expect] || 200).to_i
|
|
@@ -44,11 +44,12 @@ module Screenplay
|
|
|
44
44
|
payload: data
|
|
45
45
|
})
|
|
46
46
|
rescue => e
|
|
47
|
+
raise e if e.response.nil?
|
|
47
48
|
response = e.response
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
if response.code != expects
|
|
51
|
-
raise WrongResponseCodeException.new(expects, response.code)
|
|
52
|
+
raise WrongResponseCodeException.new(expects, response.code, response.body.to_s)
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
unless response.nil?
|
|
@@ -15,11 +15,11 @@ module Screenplay
|
|
|
15
15
|
if action == :clear
|
|
16
16
|
@cache.clear
|
|
17
17
|
elsif action == :set
|
|
18
|
-
values.each { |
|
|
19
|
-
@cache[cache_key.to_sym] = (input_key == '$input'.to_sym) ? input : input[input_key]
|
|
18
|
+
values.each { | cache_key, input_key |
|
|
19
|
+
@cache[cache_key.to_sym] = (input_key == '$input'.to_sym) ? input : input[input_key.to_sym]
|
|
20
20
|
}
|
|
21
21
|
elsif (action == :merge || action == :get)
|
|
22
|
-
values.each { |
|
|
22
|
+
values.each { | input_key, cache_key |
|
|
23
23
|
output[input_key.to_sym] = @cache[cache_key.to_sym]
|
|
24
24
|
}
|
|
25
25
|
end
|
|
@@ -2,25 +2,25 @@ require File.join(File.dirname(__FILE__), '..', 'actor')
|
|
|
2
2
|
|
|
3
3
|
module Screenplay
|
|
4
4
|
|
|
5
|
-
class TestFailedException <
|
|
5
|
+
class TestFailedException < StandardError
|
|
6
6
|
def initialize(test, a, b)
|
|
7
7
|
super("#{test} on #{a.to_s} failed. Expected: #{b.to_s}.")
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
class UnknownTestException <
|
|
11
|
+
class UnknownTestException < StandardError
|
|
12
12
|
def initialize(test)
|
|
13
13
|
super("Unknown test #{test}")
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
class UnsupportedTypeTestException <
|
|
17
|
+
class UnsupportedTypeTestException < StandardError
|
|
18
18
|
def initialize(test, a)
|
|
19
19
|
super("Unsupported data type for test #{test}: #{a.to_s}")
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
class UnknownInputKeyException <
|
|
23
|
+
class UnknownInputKeyException < StandardError
|
|
24
24
|
def initialize(test, key)
|
|
25
25
|
super("Couldn't find #{key} in the input for test #{test}.")
|
|
26
26
|
end
|
data/lib/screenplay/cast.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Screenplay
|
|
|
9
9
|
include Enumerable
|
|
10
10
|
|
|
11
11
|
def register(actor)
|
|
12
|
-
raise
|
|
12
|
+
raise "Actor #{actor.name} is already registered." if @actors.include?(actor.name)
|
|
13
13
|
@actors.push(actor)
|
|
14
14
|
@actors.sort_by!{ | actor | actor.name }
|
|
15
15
|
end
|
|
@@ -38,6 +38,7 @@ class Hash
|
|
|
38
38
|
end
|
|
39
39
|
self[key.to_sym].symbolize_keys! if (recursive && (self[key.to_sym].is_a?(Hash) || self[key.to_sym].is_a?(Array)))
|
|
40
40
|
}
|
|
41
|
+
return self
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
# Changes all keys to strings. If the value is an array or hash, it will do this recursively.
|
|
@@ -49,6 +50,7 @@ class Hash
|
|
|
49
50
|
self[(key.to_s rescue key) || key] = val
|
|
50
51
|
end
|
|
51
52
|
end
|
|
53
|
+
return self
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
end
|
data/lib/screenplay/scenario.rb
CHANGED
|
@@ -2,9 +2,12 @@ require 'yaml'
|
|
|
2
2
|
|
|
3
3
|
module Screenplay
|
|
4
4
|
|
|
5
|
-
class ScenarioFailedException <
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
class ScenarioFailedException < StandardError
|
|
6
|
+
attr_reader :inner_exception
|
|
7
|
+
|
|
8
|
+
def initialize(scenario, index, actor_name, exception)
|
|
9
|
+
@inner_exception = exception
|
|
10
|
+
super("FAILED: Scenario #{scenario.name}, scene #{index} of #{scenario.size}, actor #{actor_name}: #{exception.message}")
|
|
8
11
|
end
|
|
9
12
|
end
|
|
10
13
|
|
|
@@ -22,8 +25,10 @@ module Screenplay
|
|
|
22
25
|
|
|
23
26
|
def each
|
|
24
27
|
@actions.each { | action |
|
|
28
|
+
next if action.nil?
|
|
29
|
+
action = { action => {} } if action.is_a?(String)
|
|
25
30
|
actor = action.keys[0]
|
|
26
|
-
data = action[actor]
|
|
31
|
+
data = action[actor] || {}
|
|
27
32
|
yield actor, data
|
|
28
33
|
}
|
|
29
34
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: screenplay
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Taco Jan Osinga
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|