rutema 1.1.3 → 1.2.0
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.
- data/.gemtest +0 -0
- data/History.txt +5 -0
- data/Manifest.txt +28 -23
- data/README.md +91 -0
- data/README.txt +2 -10
- data/Rakefile +6 -9
- data/bin/rutema +9 -0
- data/bin/rutemax +2 -0
- data/lib/rutema/configuration.rb +7 -8
- data/lib/rutema/elements/minimal.rb +45 -0
- data/lib/rutema/gems.rb +3 -3
- data/lib/rutema/models/activerecord.rb +164 -0
- data/lib/rutema/models/base.rb +5 -0
- data/lib/rutema/{specification.rb → objectmodel.rb} +4 -10
- data/lib/rutema/parsers/base.rb +29 -0
- data/lib/rutema/parsers/xml.rb +186 -0
- data/lib/rutema/reporters/activerecord.rb +9 -18
- data/lib/rutema/{reporter.rb → reporters/base.rb} +3 -7
- data/lib/rutema/reporters/email.rb +2 -5
- data/lib/rutema/reporters/text.rb +2 -2
- data/lib/rutema/reporters/yaml.rb +1 -2
- data/lib/rutema/runners/default.rb +157 -0
- data/lib/rutema/runners/step.rb +23 -0
- data/lib/rutema/system.rb +15 -420
- data/test/distro_test/config/full.rutema +2 -0
- data/test/distro_test/specs/check.spec +8 -0
- data/test/distro_test/specs/duplicate_name.spec +8 -0
- data/test/distro_test/specs/fail.spec +9 -0
- data/test/distro_test/specs/setup.spec +8 -0
- data/test/distro_test/specs/teardown.spec +8 -0
- data/test/rutema.rutema +1 -1
- data/test/rutema.spec +5 -5
- data/test/test_activerecord.rb +0 -0
- data/test/test_configuration.rb +7 -9
- data/test/test_couchdb.rb +14 -0
- data/test/{test_specification.rb → test_objectmodel.rb} +8 -11
- data/test/test_parsers.rb +136 -0
- data/test/test_rake.rb +2 -3
- data/test/{test_reporter.rb → test_reporters.rb} +0 -0
- data/test/test_runners.rb +72 -0
- data/test/test_system.rb +3 -166
- metadata +57 -62
- data/bin/rutema_upgrader +0 -81
- data/distro_test.sh +0 -6
- data/lib/rutema/model.rb +0 -231
- data/lib/rutema/reporters/couchdb.rb +0 -62
- data/lib/rutema/reporters/standard_reporters.rb +0 -7
- data/selftest.sh +0 -2
- data/test/data/sample09.db +0 -0
- data/test/migration.spec +0 -9
- data/test/test_model.rb +0 -62
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vassilis Rizopoulos
|
@@ -15,8 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2011-04-01 00:00:00 +03:00
|
19
|
+
default_executable: rutema
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: patir
|
@@ -74,12 +74,12 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - "="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
77
|
+
hash: 13
|
78
78
|
segments:
|
79
|
-
- 2
|
80
79
|
- 3
|
81
|
-
-
|
82
|
-
|
80
|
+
- 0
|
81
|
+
- 5
|
82
|
+
version: 3.0.5
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: *id004
|
85
85
|
- !ruby/object:Gem::Dependency
|
@@ -114,25 +114,10 @@ dependencies:
|
|
114
114
|
version: 1.1.1
|
115
115
|
type: :runtime
|
116
116
|
version_requirements: *id006
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: couchrest
|
119
|
-
prerelease: false
|
120
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - "="
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 65
|
126
|
-
segments:
|
127
|
-
- 0
|
128
|
-
- 37
|
129
|
-
version: "0.37"
|
130
|
-
type: :runtime
|
131
|
-
version_requirements: *id007
|
132
117
|
- !ruby/object:Gem::Dependency
|
133
118
|
name: hoe
|
134
119
|
prerelease: false
|
135
|
-
requirement: &
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
136
121
|
none: false
|
137
122
|
requirements:
|
138
123
|
- - ">="
|
@@ -140,30 +125,29 @@ dependencies:
|
|
140
125
|
hash: 47
|
141
126
|
segments:
|
142
127
|
- 2
|
143
|
-
-
|
144
|
-
-
|
145
|
-
version: 2.
|
128
|
+
- 9
|
129
|
+
- 2
|
130
|
+
version: 2.9.2
|
146
131
|
type: :development
|
147
|
-
version_requirements: *
|
132
|
+
version_requirements: *id007
|
148
133
|
description: |-
|
149
|
-
|
134
|
+
## DESCRIPTION:
|
150
135
|
rutema is a test execution tool with a twist.
|
151
136
|
It allows you to combine test tools while it takes care of logging, reporting, archiving of results and formalizes execution of automated and manual tests.
|
152
137
|
It's purpose is to make testing in heterogeneous environments easier.
|
153
138
|
|
154
139
|
For more information look at http://patir.rubyforge.org/rutema
|
155
140
|
|
156
|
-
|
141
|
+
## FEATURES/PROBLEMS:
|
157
142
|
* Unified test execution environment for automated and manual tests
|
158
143
|
* Extensible reports and notifications in various formats (email, rss, pdf, html etc.)
|
159
|
-
* Web frontend and command line report generation tools for browsing the test results database (with rutemaweb)
|
160
144
|
* Comprehensive history of test execution
|
161
145
|
* A well defined way to create a project specific test specification format
|
162
146
|
|
163
|
-
|
147
|
+
## SYNOPSIS:
|
164
148
|
See http://patir.rubyforge.org/rutema/distro_test.html for an introductory example.
|
165
149
|
|
166
|
-
|
150
|
+
## REQUIREMENTS:
|
167
151
|
* patir (http://patir.rubyforge.org)
|
168
152
|
* mailfactory (http://rubyforge.org/projects/mailfactory/)
|
169
153
|
* activerecord (http://ar.rubyonrails.com/)
|
@@ -174,7 +158,7 @@ description: |-
|
|
174
158
|
email: riva@braveworld.net
|
175
159
|
executables:
|
176
160
|
- rutemax
|
177
|
-
-
|
161
|
+
- rutema
|
178
162
|
extensions: []
|
179
163
|
|
180
164
|
extra_rdoc_files:
|
@@ -183,53 +167,62 @@ extra_rdoc_files:
|
|
183
167
|
- Manifest.txt
|
184
168
|
- README.txt
|
185
169
|
files:
|
170
|
+
- bin/rutema
|
171
|
+
- bin/rutemax
|
186
172
|
- COPYING.txt
|
187
173
|
- History.txt
|
188
|
-
- Manifest.txt
|
189
|
-
- README.txt
|
190
|
-
- Rakefile
|
191
|
-
- bin/rutemax
|
192
|
-
- bin/rutema_upgrader
|
193
|
-
- distro_test.sh
|
194
174
|
- lib/rutema/configuration.rb
|
175
|
+
- lib/rutema/elements/minimal.rb
|
195
176
|
- lib/rutema/gems.rb
|
196
|
-
- lib/rutema/
|
177
|
+
- lib/rutema/models/activerecord.rb
|
178
|
+
- lib/rutema/models/base.rb
|
179
|
+
- lib/rutema/objectmodel.rb
|
180
|
+
- lib/rutema/parsers/base.rb
|
181
|
+
- lib/rutema/parsers/xml.rb
|
197
182
|
- lib/rutema/rake.rb
|
198
|
-
- lib/rutema/reporter.rb
|
199
183
|
- lib/rutema/reporters/activerecord.rb
|
184
|
+
- lib/rutema/reporters/base.rb
|
200
185
|
- lib/rutema/reporters/email.rb
|
201
|
-
- lib/rutema/reporters/standard_reporters.rb
|
202
186
|
- lib/rutema/reporters/text.rb
|
203
187
|
- lib/rutema/reporters/yaml.rb
|
204
|
-
- lib/rutema/
|
205
|
-
- lib/rutema/
|
188
|
+
- lib/rutema/runners/default.rb
|
189
|
+
- lib/rutema/runners/step.rb
|
206
190
|
- lib/rutema/system.rb
|
207
|
-
-
|
208
|
-
-
|
191
|
+
- Manifest.txt
|
192
|
+
- Rakefile
|
193
|
+
- README.md
|
194
|
+
- README.txt
|
209
195
|
- test/distro_test/config/database.rutema
|
210
196
|
- test/distro_test/config/full.rutema
|
211
197
|
- test/distro_test/config/minimal.rutema
|
198
|
+
- test/distro_test/specs/check.spec
|
199
|
+
- test/distro_test/specs/duplicate_name.spec
|
200
|
+
- test/distro_test/specs/fail.spec
|
201
|
+
- test/distro_test/specs/include.scenario
|
202
|
+
- test/distro_test/specs/no_title.spec
|
203
|
+
- test/distro_test/specs/sample.spec
|
204
|
+
- test/distro_test/specs/setup.spec
|
212
205
|
- test/distro_test/specs/T001.spec
|
213
206
|
- test/distro_test/specs/T002.spec
|
214
207
|
- test/distro_test/specs/T003.spec
|
215
208
|
- test/distro_test/specs/T004.spec
|
216
209
|
- test/distro_test/specs/T005.spec
|
217
210
|
- test/distro_test/specs/T006.spec
|
218
|
-
- test/distro_test/specs/
|
219
|
-
- test/distro_test/specs/no_title.spec
|
220
|
-
- test/distro_test/specs/sample.spec
|
211
|
+
- test/distro_test/specs/teardown.spec
|
221
212
|
- test/rutema.rutema
|
222
213
|
- test/rutema.spec
|
223
|
-
- test/
|
214
|
+
- test/test_activerecord.rb
|
224
215
|
- test/test_configuration.rb
|
225
|
-
- test/
|
226
|
-
- test/
|
227
|
-
- test/
|
216
|
+
- test/test_objectmodel.rb
|
217
|
+
- test/test_parsers.rb
|
218
|
+
- test/test_reporters.rb
|
219
|
+
- test/test_runners.rb
|
228
220
|
- test/test_system.rb
|
229
221
|
- test/test_couchdb.rb
|
230
222
|
- test/test_rake.rb
|
223
|
+
- .gemtest
|
231
224
|
has_rdoc: true
|
232
|
-
homepage:
|
225
|
+
homepage: http://patir.rubyforge.org/rutema
|
233
226
|
licenses: []
|
234
227
|
|
235
228
|
post_install_message:
|
@@ -259,15 +252,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
252
|
requirements: []
|
260
253
|
|
261
254
|
rubyforge_project: patir
|
262
|
-
rubygems_version: 1.
|
255
|
+
rubygems_version: 1.5.0
|
263
256
|
signing_key:
|
264
257
|
specification_version: 3
|
265
258
|
summary: rutema is a test execution and management framework for heterogeneous testing environments
|
266
259
|
test_files:
|
260
|
+
- test/test_activerecord.rb
|
267
261
|
- test/test_configuration.rb
|
268
262
|
- test/test_couchdb.rb
|
269
|
-
- test/
|
263
|
+
- test/test_objectmodel.rb
|
264
|
+
- test/test_parsers.rb
|
270
265
|
- test/test_rake.rb
|
271
|
-
- test/
|
272
|
-
- test/
|
266
|
+
- test/test_reporters.rb
|
267
|
+
- test/test_runners.rb
|
273
268
|
- test/test_system.rb
|
data/bin/rutema_upgrader
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008-2010 Vassilis Rizopoulos. All rights reserved.
|
2
|
-
require 'rutema/system'
|
3
|
-
require 'patir/base'
|
4
|
-
|
5
|
-
#Parses the command line arguments
|
6
|
-
def parse_command_line args
|
7
|
-
args.options do |opt|
|
8
|
-
opt.on("Usage:")
|
9
|
-
opt.on("rutema_upgrader [options] config_file")
|
10
|
-
opt.on("Options:")
|
11
|
-
opt.on("--debug", "-d","Turns on debug messages") { $DEBUG=true }
|
12
|
-
opt.on("-v", "--version","Displays the version") { $stdout.puts("v#{Version::STRING}");exit 0 }
|
13
|
-
opt.on("--help", "-h", "-?", "This text") { $stdout.puts opt; exit 0 }
|
14
|
-
opt.parse!
|
15
|
-
#and now the rest
|
16
|
-
if args.empty?
|
17
|
-
$stdout.puts opt
|
18
|
-
exit 0
|
19
|
-
else
|
20
|
-
return args.shift
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
logger=Patir.setup_logger
|
25
|
-
config_file=parse_command_line(ARGV)
|
26
|
-
begin
|
27
|
-
raise "No configuration file defined!" if !config_file
|
28
|
-
configuration=Rutema::RutemaXConfigurator.new(config_file,logger).configuration
|
29
|
-
Dir.chdir(File.dirname(config_file)) do
|
30
|
-
coordinator=Rutema::Coordinator.new(configuration,logger)
|
31
|
-
specs=coordinator.parse_all_specifications
|
32
|
-
specifications=Hash.new
|
33
|
-
specs.each do |s|
|
34
|
-
specifications[s.name]=[s.title,s.description]
|
35
|
-
end
|
36
|
-
database=nil
|
37
|
-
configuration.reporters.each do |rep|
|
38
|
-
if rep[:class]==Rutema::ActiveRecordReporter
|
39
|
-
database=rep[:db][:database]
|
40
|
-
break
|
41
|
-
end
|
42
|
-
end
|
43
|
-
if database && File.exists?(database)
|
44
|
-
logger.info("Found database file #{database}")
|
45
|
-
Rutema.connect_to_ar(database,logger,false)
|
46
|
-
begin
|
47
|
-
test_scenario=Rutema::Model::Scenario.find(:first)
|
48
|
-
rescue
|
49
|
-
logger.debug($!)
|
50
|
-
logger.fatal("Problem accessing the database: #{$!.message}")
|
51
|
-
exit 1
|
52
|
-
end
|
53
|
-
if test_scenario.respond_to?(:title) && test_scenario.respond_to?(:description)
|
54
|
-
logger.info("Schema appears updated")
|
55
|
-
else
|
56
|
-
logger.info("Updating schema")
|
57
|
-
Rutema::Model::UpgradeV9toV10.up
|
58
|
-
end
|
59
|
-
logger.info("Setting title and description values")
|
60
|
-
Rutema::Model::Scenario.find(:all).each do |sc|
|
61
|
-
if specifications[sc.name]
|
62
|
-
logger.info("Setting columns for #{sc.name}:#{sc.id}")
|
63
|
-
sc.title=specifications[sc.name][0]
|
64
|
-
sc.description=specifications[sc.name][1]
|
65
|
-
sc.save
|
66
|
-
end
|
67
|
-
end
|
68
|
-
else
|
69
|
-
logger.fatal("Database '#{database}' does not exist")
|
70
|
-
exit 1
|
71
|
-
end
|
72
|
-
end
|
73
|
-
rescue Patir::ConfigurationException
|
74
|
-
logger.debug($!)
|
75
|
-
logger.fatal("Configuration error '#{$!.message}'")
|
76
|
-
exit 1
|
77
|
-
rescue
|
78
|
-
logger.debug($!)
|
79
|
-
logger.fatal("#{$!.message}")
|
80
|
-
exit 1
|
81
|
-
end
|
data/distro_test.sh
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
ruby -rubygems -I lib/ bin/rutemax -c test/distro_test/config/minimal.rutema
|
3
|
-
ruby -rubygems -I lib/ bin/rutemax -c test/distro_test/config/database.rutema
|
4
|
-
ruby -rubygems -I lib/ bin/rutemax -c test/distro_test/config/full.rutema --check
|
5
|
-
ruby -rubygems -I lib/ bin/rutemax -c test/distro_test/config/full.rutema
|
6
|
-
#rutemax -c test/distro_test/config/minimal.rutema --step
|
data/lib/rutema/model.rb
DELETED
@@ -1,231 +0,0 @@
|
|
1
|
-
# Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__),"..")
|
3
|
-
require 'active_record'
|
4
|
-
require 'ruport/acts_as_reportable'
|
5
|
-
require 'patir/base'
|
6
|
-
require 'couchrest'
|
7
|
-
#this fixes the AR Logger hack that annoys me sooooo much
|
8
|
-
class Logger
|
9
|
-
private
|
10
|
-
def format_message(severity, datetime, progname, msg)
|
11
|
-
(@formatter || @default_formatter).call(severity, datetime, progname, msg)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
module Rutema
|
15
|
-
module ActiveRecord
|
16
|
-
#Exception occuring when connecting to a database
|
17
|
-
class ConnectionError<RuntimeError
|
18
|
-
end
|
19
|
-
#This is the ActiveRecord model for Rutema:
|
20
|
-
#
|
21
|
-
#A Run has n instances of executed scenarios - which in turn have n instances of executed steps -
|
22
|
-
#and n instances of parse errors.
|
23
|
-
module Model
|
24
|
-
#This is the schema for the AR database used to store test results
|
25
|
-
#
|
26
|
-
#We store the RutemaConfiguration#context for every run so that reports for past runs can be recreated without running the actual tests again.
|
27
|
-
class Schema< ::ActiveRecord::Migration
|
28
|
-
def self.up
|
29
|
-
create_table :runs do |t|
|
30
|
-
t.column :context, :string
|
31
|
-
end
|
32
|
-
|
33
|
-
create_table :scenarios do |t|
|
34
|
-
t.column :name, :string, :null=>false
|
35
|
-
t.column :run_id,:integer, :null=>false
|
36
|
-
t.column :attended,:bool, :null=>false
|
37
|
-
t.column :status, :string,:null=>false
|
38
|
-
t.column :number,:integer
|
39
|
-
t.column :start_time, :datetime,:null=>false
|
40
|
-
t.column :stop_time, :datetime
|
41
|
-
t.column :version, :string
|
42
|
-
t.column :title, :string
|
43
|
-
t.column :description, :string
|
44
|
-
end
|
45
|
-
|
46
|
-
create_table :steps do |t|
|
47
|
-
t.column :scenario_id,:integer, :null=>false
|
48
|
-
t.column :name, :string
|
49
|
-
t.column :number, :integer,:null=>false
|
50
|
-
t.column :status, :string,:null=>false
|
51
|
-
t.column :output, :text
|
52
|
-
t.column :error, :text
|
53
|
-
t.column :duration, :decimal
|
54
|
-
end
|
55
|
-
|
56
|
-
create_table :parse_errors do |t|
|
57
|
-
t.column :filename, :string,:null=>false
|
58
|
-
t.column :error, :string
|
59
|
-
t.column :run_id,:integer, :null=>false
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class Run< ::ActiveRecord::Base
|
65
|
-
has_many :scenarios
|
66
|
-
has_many :parse_errors
|
67
|
-
serialize :context
|
68
|
-
acts_as_reportable
|
69
|
-
end
|
70
|
-
|
71
|
-
class Scenario< ::ActiveRecord::Base
|
72
|
-
belongs_to :run
|
73
|
-
has_many :steps
|
74
|
-
acts_as_reportable
|
75
|
-
end
|
76
|
-
|
77
|
-
class Step< ::ActiveRecord::Base
|
78
|
-
belongs_to :scenario
|
79
|
-
acts_as_reportable
|
80
|
-
end
|
81
|
-
|
82
|
-
class ParseError< ::ActiveRecord::Base
|
83
|
-
belongs_to :run
|
84
|
-
acts_as_reportable
|
85
|
-
end
|
86
|
-
|
87
|
-
class UpgradeV9toV10< ::ActiveRecord::Migration
|
88
|
-
def self.up
|
89
|
-
puts("Adding new columns")
|
90
|
-
add_column(:scenarios, :title, :string,{:default=>"title"})
|
91
|
-
add_column(:scenarios, :description, :string,{:default=>"description"})
|
92
|
-
puts("Updating existing scenario entries")
|
93
|
-
Rutema::Model::Scenario.find(:all).each do |sc|
|
94
|
-
puts "Updating scenario #{sc.id}"
|
95
|
-
sc.title="#{name}"
|
96
|
-
sc.description="#{name}"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
#Exports the contents of the database/model as a yaml dump
|
103
|
-
class Export
|
104
|
-
def initialize params
|
105
|
-
@logger = params[:logger]
|
106
|
-
@logger ||= Patir.setup_logger
|
107
|
-
@result_set_size = params[:result_set_size]
|
108
|
-
@result_set_size ||= 1000
|
109
|
-
@currently_on_no=0
|
110
|
-
database_configuration = params[:db]
|
111
|
-
raise "No database configuration defined, missing :db configuration key." unless database_configuration
|
112
|
-
ActiveRecord.connect(database_configuration,@logger)
|
113
|
-
end
|
114
|
-
|
115
|
-
def next
|
116
|
-
@logger.info("Found #{Model::Run.count} runs") if @currently_on_no==0
|
117
|
-
@logger.info("Exporting from #{@currently_on_no} to #{@currently_on_no+@result_set_size}")
|
118
|
-
export(@result_set_size)
|
119
|
-
end
|
120
|
-
|
121
|
-
def all
|
122
|
-
@logger.info("Found #{Model::Run.count} runs")
|
123
|
-
export(nil)
|
124
|
-
end
|
125
|
-
private
|
126
|
-
def export offset=nil
|
127
|
-
if offset
|
128
|
-
runs=Model::Run.find(:all,:order=>"id ASC",:limit=>@result_set_size,:offset=>@currently_on_no)
|
129
|
-
@currently_on_no+=offset
|
130
|
-
else
|
131
|
-
runs=Model::Run.find(:all)
|
132
|
-
end
|
133
|
-
return nil if runs.empty?
|
134
|
-
export=[]
|
135
|
-
runs.each do |run|
|
136
|
-
e={:parse_errors=>[],:scenarios=>[],:context=>run.context}
|
137
|
-
run.parse_errors.each { |pe| e[:parse_errors]<<{:filename=>pe.filename, :error=>pe.error} }
|
138
|
-
run.scenarios.each { |sc| e[:scenarios]<<export_scenario(sc) }
|
139
|
-
export<<e
|
140
|
-
@logger.debug("Exported #{run.id}")
|
141
|
-
end
|
142
|
-
return export
|
143
|
-
end
|
144
|
-
|
145
|
-
def export_scenario sc
|
146
|
-
scenario={:name=>sc[:name],
|
147
|
-
:attended=>sc[:attended],
|
148
|
-
:status=>sc[:status],
|
149
|
-
:number=>sc[:number],
|
150
|
-
:start_time=>sc[:start_time],
|
151
|
-
:stop_time=>sc[:stop_time],
|
152
|
-
:version=>sc[:version],
|
153
|
-
:title=>sc[:title],
|
154
|
-
:description=>sc[:description],
|
155
|
-
:steps=>[]
|
156
|
-
}
|
157
|
-
sc.steps.each do |step|
|
158
|
-
st={:name=>step[:name],
|
159
|
-
:number=>step[:number],
|
160
|
-
:status=>step[:status],
|
161
|
-
:output=>step[:output],
|
162
|
-
:error=>step[:error],
|
163
|
-
:duration=>step[:duration]
|
164
|
-
}
|
165
|
-
scenario[:steps]<<st
|
166
|
-
end
|
167
|
-
return scenario
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
#Establishes an ActiveRecord connection
|
172
|
-
def self.connect cfg,logger
|
173
|
-
conn=cnct(cfg,logger)
|
174
|
-
Model::Schema.migrate(:up) if perform_migration?(cfg)
|
175
|
-
end
|
176
|
-
|
177
|
-
private
|
178
|
-
#Establishes an active record connection using the cfg hash
|
179
|
-
#There is only a rudimentary check to ensure the integrity of cfg
|
180
|
-
def self.cnct cfg,logger
|
181
|
-
if cfg[:adapter] && cfg[:database]
|
182
|
-
logger.debug("Connecting to #{cfg[:database]}")
|
183
|
-
return ::ActiveRecord::Base.establish_connection(cfg)
|
184
|
-
else
|
185
|
-
raise ConnectionError,"Erroneous database configuration. Missing :adapter and/or :database"
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def self.perform_migration? cfg
|
190
|
-
return true if cfg[:migrate]
|
191
|
-
#special case for sqlite3
|
192
|
-
if cfg[:adapter]=="sqlite3" && !File.exists?(cfg[:database])
|
193
|
-
return true
|
194
|
-
end
|
195
|
-
return false
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
module CouchDB
|
201
|
-
def self.connect cfg,logger
|
202
|
-
if cfg[:url] && cfg[:database]
|
203
|
-
if cfg[:user] && cfg[:password]
|
204
|
-
end
|
205
|
-
return CouchRest.database!("#{cfg[:url]}/#{cfg[:database]}")
|
206
|
-
|
207
|
-
else
|
208
|
-
raise ConnectionError,"Erroneous database configuration. Missing :url and/or :database"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
module Model
|
212
|
-
class Run <CouchRest::ExtendedDocument
|
213
|
-
unique_id :slug
|
214
|
-
|
215
|
-
timestamps!
|
216
|
-
|
217
|
-
view_by :slug, :descending=>true
|
218
|
-
|
219
|
-
property :slug, :read_only => true
|
220
|
-
property :context
|
221
|
-
property :scenarios
|
222
|
-
property :parse_errors
|
223
|
-
|
224
|
-
set_callback :save, :before, :generate_slug_from_payload
|
225
|
-
def generate_slug_from_payload
|
226
|
-
self['slug']=Digest::SHA1.hexdigest("#{self['context']},#{self['scenarios']}")
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|