openrain-scenarios 0.2.2 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/scenarios/scenario.rb +20 -0
- data/lib/scenarios/tasks.rb +8 -6
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/scenarios/scenario.rb
CHANGED
@@ -26,6 +26,20 @@ class Scenario
|
|
26
26
|
end
|
27
27
|
alias to_s name
|
28
28
|
|
29
|
+
# returns a formatted string, showing information
|
30
|
+
# about this current scenario
|
31
|
+
def info
|
32
|
+
str = <<INFO
|
33
|
+
Scenario: #{ name }
|
34
|
+
Summary: #{ summary }
|
35
|
+
Description: #{ description_without_summary }
|
36
|
+
INFO
|
37
|
+
variables.each do |key, value|
|
38
|
+
str << "#{ key }: #{ value.inspect }\n"
|
39
|
+
end
|
40
|
+
str
|
41
|
+
end
|
42
|
+
|
29
43
|
# if the first line of the scenario's source code
|
30
44
|
# is a comment, we use it as the scenario's summary
|
31
45
|
#
|
@@ -63,6 +77,12 @@ class Scenario
|
|
63
77
|
header.gsub(/^#* ?/, '').gsub(/^---.*/m, '').strip # gets rid of comment hashes and yaml
|
64
78
|
end
|
65
79
|
|
80
|
+
def description_without_summary
|
81
|
+
parts = description.split("\n")
|
82
|
+
parts.shift
|
83
|
+
parts.join("\n")
|
84
|
+
end
|
85
|
+
|
66
86
|
# evaluates the code of the scenario
|
67
87
|
def load
|
68
88
|
self.class.load self # pass the loading off to the class
|
data/lib/scenarios/tasks.rb
CHANGED
@@ -12,7 +12,7 @@ task :scenarios do
|
|
12
12
|
puts "there are no scenarios. add some to one of the Scenario.load_paths: #{ Scenario.load_paths.inspect }"
|
13
13
|
else
|
14
14
|
Scenario.all.each do |scenario|
|
15
|
-
puts "#{ scenario.name }: #{ scenario.
|
15
|
+
puts "#{ scenario.name }: #{ scenario.summary }"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -24,10 +24,7 @@ namespace :scenarios do
|
|
24
24
|
puts "called scenarios:load" if Scenario.verbose
|
25
25
|
if ENV['NAME']
|
26
26
|
names = ENV['NAME'].split(',')
|
27
|
-
|
28
|
-
puts "Scenario.load #{scenario_name}"
|
29
|
-
Scenario.load scenario_name
|
30
|
-
end
|
27
|
+
Scenario.load *names
|
31
28
|
else
|
32
29
|
puts "you need to pass NAME=scenario_name to load a scenario"
|
33
30
|
end
|
@@ -38,7 +35,12 @@ namespace :scenarios do
|
|
38
35
|
if ENV['NAME']
|
39
36
|
names = ENV['NAME'].split(',')
|
40
37
|
names.each do |scenario_name|
|
41
|
-
|
38
|
+
if scenario = Scenario[scenario_name]
|
39
|
+
puts scenario.info
|
40
|
+
puts ('-' * 40)
|
41
|
+
else
|
42
|
+
puts "Scenario not found: #{ scenario_name }"
|
43
|
+
end
|
42
44
|
end
|
43
45
|
else
|
44
46
|
puts "you need to pass NAME=scenario_name to load a scenario"
|