rutema 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.gemtest +0 -0
  2. data/History.txt +5 -0
  3. data/Manifest.txt +28 -23
  4. data/README.md +91 -0
  5. data/README.txt +2 -10
  6. data/Rakefile +6 -9
  7. data/bin/rutema +9 -0
  8. data/bin/rutemax +2 -0
  9. data/lib/rutema/configuration.rb +7 -8
  10. data/lib/rutema/elements/minimal.rb +45 -0
  11. data/lib/rutema/gems.rb +3 -3
  12. data/lib/rutema/models/activerecord.rb +164 -0
  13. data/lib/rutema/models/base.rb +5 -0
  14. data/lib/rutema/{specification.rb → objectmodel.rb} +4 -10
  15. data/lib/rutema/parsers/base.rb +29 -0
  16. data/lib/rutema/parsers/xml.rb +186 -0
  17. data/lib/rutema/reporters/activerecord.rb +9 -18
  18. data/lib/rutema/{reporter.rb → reporters/base.rb} +3 -7
  19. data/lib/rutema/reporters/email.rb +2 -5
  20. data/lib/rutema/reporters/text.rb +2 -2
  21. data/lib/rutema/reporters/yaml.rb +1 -2
  22. data/lib/rutema/runners/default.rb +157 -0
  23. data/lib/rutema/runners/step.rb +23 -0
  24. data/lib/rutema/system.rb +15 -420
  25. data/test/distro_test/config/full.rutema +2 -0
  26. data/test/distro_test/specs/check.spec +8 -0
  27. data/test/distro_test/specs/duplicate_name.spec +8 -0
  28. data/test/distro_test/specs/fail.spec +9 -0
  29. data/test/distro_test/specs/setup.spec +8 -0
  30. data/test/distro_test/specs/teardown.spec +8 -0
  31. data/test/rutema.rutema +1 -1
  32. data/test/rutema.spec +5 -5
  33. data/test/test_activerecord.rb +0 -0
  34. data/test/test_configuration.rb +7 -9
  35. data/test/test_couchdb.rb +14 -0
  36. data/test/{test_specification.rb → test_objectmodel.rb} +8 -11
  37. data/test/test_parsers.rb +136 -0
  38. data/test/test_rake.rb +2 -3
  39. data/test/{test_reporter.rb → test_reporters.rb} +0 -0
  40. data/test/test_runners.rb +72 -0
  41. data/test/test_system.rb +3 -166
  42. metadata +57 -62
  43. data/bin/rutema_upgrader +0 -81
  44. data/distro_test.sh +0 -6
  45. data/lib/rutema/model.rb +0 -231
  46. data/lib/rutema/reporters/couchdb.rb +0 -62
  47. data/lib/rutema/reporters/standard_reporters.rb +0 -7
  48. data/selftest.sh +0 -2
  49. data/test/data/sample09.db +0 -0
  50. data/test/migration.spec +0 -9
  51. data/test/test_model.rb +0 -62
data/.gemtest ADDED
File without changes
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.2.0 /2011-04-01
2
+ * refactored library structure
3
+ * More unit tests. We're now over the magical 80% coverage point
4
+ * Updated gem dependencies for activerecord to the newest version
5
+ * Deprecated rutemax. The command now is simply rutema (avoids observed confusion). Will remove in 1.3.0
1
6
  == 1.1.3 /2010-12-23
2
7
  * fixed dependency handling of Rutema::RakeTask within the block.
3
8
  == 1.1.2 /2010-12-22
data/Manifest.txt CHANGED
@@ -1,46 +1,51 @@
1
+ bin/rutema
2
+ bin/rutemax
1
3
  COPYING.txt
2
4
  History.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- bin/rutemax
7
- bin/rutema_upgrader
8
- distro_test.sh
9
5
  lib/rutema/configuration.rb
6
+ lib/rutema/elements/minimal.rb
10
7
  lib/rutema/gems.rb
11
- lib/rutema/model.rb
8
+ lib/rutema/models/activerecord.rb
9
+ lib/rutema/models/base.rb
10
+ lib/rutema/objectmodel.rb
11
+ lib/rutema/parsers/base.rb
12
+ lib/rutema/parsers/xml.rb
12
13
  lib/rutema/rake.rb
13
- lib/rutema/reporter.rb
14
14
  lib/rutema/reporters/activerecord.rb
15
+ lib/rutema/reporters/base.rb
15
16
  lib/rutema/reporters/email.rb
16
- lib/rutema/reporters/standard_reporters.rb
17
17
  lib/rutema/reporters/text.rb
18
18
  lib/rutema/reporters/yaml.rb
19
- lib/rutema/reporters/couchdb.rb
20
- lib/rutema/specification.rb
19
+ lib/rutema/runners/default.rb
20
+ lib/rutema/runners/step.rb
21
21
  lib/rutema/system.rb
22
- selftest.sh
23
- test/data/sample09.db
22
+ Manifest.txt
23
+ Rakefile
24
+ README.md
25
+ README.txt
24
26
  test/distro_test/config/database.rutema
25
27
  test/distro_test/config/full.rutema
26
28
  test/distro_test/config/minimal.rutema
29
+ test/distro_test/specs/check.spec
30
+ test/distro_test/specs/duplicate_name.spec
31
+ test/distro_test/specs/fail.spec
32
+ test/distro_test/specs/include.scenario
33
+ test/distro_test/specs/no_title.spec
34
+ test/distro_test/specs/sample.spec
35
+ test/distro_test/specs/setup.spec
27
36
  test/distro_test/specs/T001.spec
28
37
  test/distro_test/specs/T002.spec
29
38
  test/distro_test/specs/T003.spec
30
39
  test/distro_test/specs/T004.spec
31
40
  test/distro_test/specs/T005.spec
32
41
  test/distro_test/specs/T006.spec
33
- test/distro_test/specs/include.scenario
34
- test/distro_test/specs/no_title.spec
35
- test/distro_test/specs/sample.spec
42
+ test/distro_test/specs/teardown.spec
36
43
  test/rutema.rutema
37
44
  test/rutema.spec
38
- test/migration.spec
45
+ test/test_activerecord.rb
39
46
  test/test_configuration.rb
40
- test/test_model.rb
41
- test/test_reporter.rb
42
- test/test_specification.rb
47
+ test/test_objectmodel.rb
48
+ test/test_parsers.rb
49
+ test/test_reporters.rb
50
+ test/test_runners.rb
43
51
  test/test_system.rb
44
- test/test_couchdb.rb
45
- test/test_rake.rb
46
-
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ rutema [http://patir.rubyforge.org/rutema](http://patir.rubyforge.org/rutema)
2
+
3
+ ## DESCRIPTION:
4
+ rutema is a test execution tool with a twist.
5
+ 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.
6
+ It's purpose is to make testing in heterogeneous environments easier.
7
+
8
+ For more information look at http://patir.rubyforge.org/rutema
9
+
10
+ ## FEATURES/PROBLEMS:
11
+ * Unified test execution environment for automated and manual tests
12
+ * Extensible reports and notifications in various formats (email, rss, pdf, html etc.)
13
+ * Comprehensive history of test execution
14
+ * A well defined way to create a project specific test specification format
15
+
16
+ ## SYNOPSIS:
17
+ See http://patir.rubyforge.org/rutema/distro_test.html for an introductory example.
18
+
19
+ ## REQUIREMENTS:
20
+ * patir (http://patir.rubyforge.org)
21
+ * mailfactory (http://rubyforge.org/projects/mailfactory/)
22
+ * activerecord (http://ar.rubyonrails.com/)
23
+ * sqlite3 (http://rubyforge.org/projects/sqlite-ruby/)
24
+ * ruport (http://rubyreports.org/)
25
+ * acts_as_reportable
26
+ * highline
27
+
28
+ ## INSTALL:
29
+ * gem install rutema
30
+
31
+ ## LICENSE:
32
+ (The Ruby License)
33
+
34
+ rutema is copyright (c) 2007 - 2011 Vassilis Rizopoulos
35
+
36
+ You can redistribute it and/or modify it under either the terms of the GPL
37
+ (see COPYING.txt file), or the conditions below:
38
+
39
+ 1. You may make and give away verbatim copies of the source form of the
40
+ software without restriction, provided that you duplicate all of the
41
+ original copyright notices and associated disclaimers.
42
+
43
+ 2. You may modify your copy of the software in any way, provided that
44
+ you do at least ONE of the following:
45
+
46
+ a) place your modifications in the Public Domain or otherwise
47
+ make them Freely Available, such as by posting said
48
+ modifications to Usenet or an equivalent medium, or by allowing
49
+ the author to include your modifications in the software.
50
+
51
+ b) use the modified software only within your corporation or
52
+ organization.
53
+
54
+ c) rename any non-standard executables so the names do not conflict
55
+ with standard executables, which must also be provided.
56
+
57
+ d) make other distribution arrangements with the author.
58
+
59
+ 3. You may distribute the software in object code or executable
60
+ form, provided that you do at least ONE of the following:
61
+
62
+ a) distribute the executables and library files of the software,
63
+ together with instructions (in the manual page or equivalent)
64
+ on where to get the original distribution.
65
+
66
+ b) accompany the distribution with the machine-readable source of
67
+ the software.
68
+
69
+ c) give non-standard executables non-standard names, with
70
+ instructions on where to get the original software distribution.
71
+
72
+ d) make other distribution arrangements with the author.
73
+
74
+ 4. You may modify and include the part of the software into any other
75
+ software (possibly commercial). But some files in the distribution
76
+ are not written by the author, so that they are not under this terms.
77
+
78
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
79
+ files under the ./missing directory. See each file for the copying
80
+ condition.
81
+
82
+ 5. The scripts and library files supplied as input to or produced as
83
+ output from the software do not automatically fall under the
84
+ copyright of the software, but belong to whomever generated them,
85
+ and may be sold commercially, and may be aggregated with this
86
+ software.
87
+
88
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
89
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
90
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
91
+ PURPOSE.
data/README.txt CHANGED
@@ -10,7 +10,6 @@ For more information look at http://patir.rubyforge.org/rutema
10
10
  == FEATURES/PROBLEMS:
11
11
  * Unified test execution environment for automated and manual tests
12
12
  * Extensible reports and notifications in various formats (email, rss, pdf, html etc.)
13
- * Web frontend and command line report generation tools for browsing the test results database (with rutemaweb)
14
13
  * Comprehensive history of test execution
15
14
  * A well defined way to create a project specific test specification format
16
15
 
@@ -32,7 +31,7 @@ See http://patir.rubyforge.org/rutema/distro_test.html for an introductory examp
32
31
  == LICENSE:
33
32
  (The Ruby License)
34
33
 
35
- rutema is copyright (c) 2007 - 2009 Vassilis Rizopoulos
34
+ rutema is copyright (c) 2007 - 2011 Vassilis Rizopoulos
36
35
 
37
36
  You can redistribute it and/or modify it under either the terms of the GPL
38
37
  (see COPYING.txt file), or the conditions below:
@@ -89,11 +88,4 @@ You can redistribute it and/or modify it under either the terms of the GPL
89
88
  6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
90
89
  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
91
90
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
92
- PURPOSE.
93
-
94
- == CREDITS
95
- RutemaWeb uses icons from
96
- Fast Icon (Dirceu Veiga)
97
- Homepage: http://www.fasticon.com
98
- The page design used is an adaptation of RedTie, a design found in www.oswd.org
99
- Homepage: http://www.oswd.org/design/preview/id/3699
91
+ PURPOSE.
data/Rakefile CHANGED
@@ -2,29 +2,26 @@
2
2
  # -*- ruby -*-
3
3
  $:.unshift File.join(File.dirname(__FILE__),"lib")
4
4
  $:.unshift File.join(File.dirname(__FILE__),"ext")
5
+ require 'rutema/system'
5
6
  require 'rubygems'
6
- require 'rutema/gems'
7
7
  require 'hoe'
8
- require 'rutema/system'
9
-
10
8
  Hoe.spec('rutema') do |p|
11
9
  p.version=Rutema::Version::STRING
12
10
  p.rubyforge_name = 'patir'
13
11
  p.author = "Vassilis Rizopoulos"
14
12
  p.email = "riva@braveworld.net"
15
13
  p.summary = 'rutema is a test execution and management framework for heterogeneous testing environments'
16
- p.description = p.paragraphs_of('README.txt', 1..5).join("\n\n")
17
- p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
+ p.description = p.paragraphs_of('README.md', 1..5).join("\n\n")
15
+ p.url = "http://patir.rubyforge.org/rutema"
18
16
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
19
17
  p.extra_deps<<['patir',">=0.6.4"]
20
18
  p.extra_deps<<['highline','1.5.2']
21
19
  p.extra_deps<<['mailfactory','1.4.0']
22
- p.extra_deps<<['activerecord','2.3.8']
20
+ p.extra_deps<<['activerecord','3.0.5']
23
21
  p.extra_deps<<['ruport','1.6.3']
24
22
  p.extra_deps<<['acts_as_reportable','1.1.1']
25
- p.extra_deps<<['couchrest','=0.37']
26
- p.spec_extras={:executables=>["rutemax","rutema_upgrader"],
27
- :default_executable=>"rutemax"}
23
+ #p.extra_deps<<['couchrest','=1.0.1']
24
+ p.spec_extras={:executables=>["rutemax","rutema"],:default_executable=>"rutema"}
28
25
  end
29
26
 
30
27
  # vim: syntax=Ruby
data/bin/rutema ADDED
@@ -0,0 +1,9 @@
1
+ # Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
2
+ require 'rubygems'
3
+ require 'rutema/gems'
4
+ require 'rutema/system'
5
+ begin
6
+ Rutema::RutemaX.new(ARGV)
7
+ rescue
8
+ exit 1
9
+ end
data/bin/rutemax CHANGED
@@ -1,7 +1,9 @@
1
1
  # Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
2
+ require 'rubygems'
2
3
  require 'rutema/gems'
3
4
  require 'rutema/system'
4
5
  begin
6
+ puts "rutemax is deprecated and will be removed in the near future, use rutema instead"
5
7
  Rutema::RutemaX.new(ARGV)
6
8
  rescue
7
9
  exit 1
@@ -2,18 +2,17 @@
2
2
  $:.unshift File.join(File.dirname(__FILE__),"..")
3
3
 
4
4
  module Rutema
5
- #This module defines the "configuration directives" used in the configuration of RutemaX
5
+ #This module defines the "configuration directives" used in the configuration of Rutema
6
6
  #
7
7
  #Example
8
8
  #A configuration file needs as a minimum to define which parser to use and which tests to run.
9
9
  #
10
10
  #Since rutema configuration files are valid Ruby code, you can use the full power of the Ruby language including require directives
11
11
  #
12
- # require 'rubygems'
13
12
  # require 'rake'
14
13
  # configuration.parser={:class=>Rutema::MinimalXMLParser}
15
14
  # configuration.tests=FileList['all/of/the/tests/**/*.*']
16
- module RutemaXConfiguration
15
+ module RutemaConfiguration
17
16
  #Adds a hash of values to the tools hash of the configuration
18
17
  #
19
18
  #This hash is then accessible in the parser and reporters as a property of the configuration instance
@@ -79,7 +78,7 @@ module Rutema
79
78
  end
80
79
  end
81
80
 
82
- #Adds the files to the specifications available to RutemaX.
81
+ #Adds the files to the specifications available to Rutema.
83
82
  def tests= array_of_files
84
83
  @tests||=Array.new
85
84
  @tests+=array_of_files
@@ -124,11 +123,11 @@ module Rutema
124
123
  end
125
124
  end
126
125
 
127
- #This class reads a RutemaX configuration file
126
+ #This class reads a Rutema configuration file
128
127
  #
129
- #See Rutema::RutemaXConfiguration for configuration examples and directives
130
- class RutemaXConfigurator<Patir::Configurator
131
- include RutemaXConfiguration
128
+ #See Rutema::RutemaConfiguration for configuration examples and directives
129
+ class RutemaConfigurator<Patir::Configurator
130
+ include RutemaConfiguration
132
131
  def initialize config_file,logger=nil
133
132
  @reporters=Array.new
134
133
  @context=Hash.new
@@ -0,0 +1,45 @@
1
+ # Copyright (c) 2007-2011 Vassilis Rizopoulos. All rights reserved.
2
+ $:.unshift File.join(File.dirname(__FILE__),'..','..')
3
+ module Rutema
4
+ #The Elements module provides the namespace for the various modules adding parser functionality
5
+ module Elements
6
+ #Minimal offers a minimal(chic) set of elements for use in specifications
7
+ #
8
+ #These are:
9
+ # echo
10
+ # command
11
+ # prompt
12
+ module Minimal
13
+ #echo prints a message on the screen:
14
+ # <echo text="A meaningful message"/>
15
+ # <echo>A meaningful message</echo>
16
+ def element_echo step
17
+ step.cmd=Patir::RubyCommand.new("echo"){|cmd| cmd.error="";cmd.output="#{step.text}";$stdout.puts(cmd.output) ;:success}
18
+ end
19
+ #prompt asks the user a yes/no question. Answering yes means the step is succesful.
20
+ # <prompt text="Do you want fries with that?"/>
21
+ #
22
+ #A prompt element automatically makes a specification "attended"
23
+ def element_prompt step
24
+ step.attended=true
25
+ step.cmd=Patir::RubyCommand.new("prompt") do |cmd|
26
+ cmd.output=""
27
+ cmd.error=""
28
+ if HighLine.new.agree("#{step.text}")
29
+ step.output="y"
30
+ else
31
+ raise "n"
32
+ end#if
33
+ end#do rubycommand
34
+ end
35
+ #command executes a shell command
36
+ # <command cmd="useful_command.exe with parameters", working_directory="some/directory"/>
37
+ def element_command step
38
+ raise ParserError,"missing required attribute cmd in #{step}" unless step.has_cmd?
39
+ wd=Dir.pwd
40
+ wd=step.working_directory if step.has_working_directory?
41
+ step.cmd=Patir::ShellCommand.new(:cmd=>step.cmd,:working_directory=>File.expand_path(wd))
42
+ end
43
+ end
44
+ end
45
+ end
data/lib/rutema/gems.rb CHANGED
@@ -1,4 +1,4 @@
1
- gem 'activerecord','2.3.8'
1
+ gem 'activerecord','3.0.5'
2
2
  gem 'patir',">=0.6.4"
3
- gem 'acts_as_reportable','=1.1.1'
4
- gem 'couchrest','=0.37'
3
+ gem 'ruport','=1.6.3'
4
+ gem 'acts_as_reportable','>=1.1.1'
@@ -0,0 +1,164 @@
1
+ # Copyright (c) 2007-2010 Vassilis Rizopoulos. All rights reserved.
2
+ $:.unshift File.join(File.dirname(__FILE__),'..','..')
3
+ require 'rutema/models/base'
4
+ require 'active_record'
5
+ require 'ruport/acts_as_reportable'
6
+
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
+ #This is the schema for the AR database used to store test results
17
+ #
18
+ #We store the RutemaConfiguration#context for every run so that reports for past runs can be recreated without running the actual tests again.
19
+ class Schema< ::ActiveRecord::Migration
20
+ def self.up
21
+ create_table :runs do |t|
22
+ t.column :context, :string
23
+ end
24
+
25
+ create_table :scenarios do |t|
26
+ t.column :name, :string, :null=>false
27
+ t.column :run_id,:integer, :null=>false
28
+ t.column :attended,:bool, :null=>false
29
+ t.column :status, :string,:null=>false
30
+ t.column :number,:integer
31
+ t.column :start_time, :datetime,:null=>false
32
+ t.column :stop_time, :datetime
33
+ t.column :version, :string
34
+ t.column :title, :string
35
+ t.column :description, :string
36
+ end
37
+
38
+ create_table :steps do |t|
39
+ t.column :scenario_id,:integer, :null=>false
40
+ t.column :name, :string
41
+ t.column :number, :integer,:null=>false
42
+ t.column :status, :string,:null=>false
43
+ t.column :output, :text
44
+ t.column :error, :text
45
+ t.column :duration, :decimal
46
+ end
47
+
48
+ create_table :parse_errors do |t|
49
+ t.column :filename, :string,:null=>false
50
+ t.column :error, :string
51
+ t.column :run_id,:integer, :null=>false
52
+ end
53
+ end
54
+ end
55
+ class Run< ::ActiveRecord::Base
56
+ has_many :scenarios
57
+ has_many :parse_errors
58
+ serialize :context
59
+ acts_as_reportable
60
+ end
61
+ class Scenario< ::ActiveRecord::Base
62
+ belongs_to :run
63
+ has_many :steps
64
+ acts_as_reportable
65
+ end
66
+ class Step< ::ActiveRecord::Base
67
+ belongs_to :scenario
68
+ acts_as_reportable
69
+ end
70
+ class ParseError< ::ActiveRecord::Base
71
+ belongs_to :run
72
+ acts_as_reportable
73
+ end
74
+ #Exports the contents of the database/model as a yaml dump
75
+ class Export
76
+ def initialize params
77
+ @logger = params[:logger]
78
+ @logger ||= Patir.setup_logger
79
+ @result_set_size = params[:result_set_size]
80
+ @result_set_size ||= 1000
81
+ @currently_on_no=0
82
+ database_configuration = params[:db]
83
+ raise "No database configuration defined, missing :db configuration key." unless database_configuration
84
+ ActiveRecord.connect(database_configuration,@logger)
85
+ end
86
+ def next
87
+ @logger.info("Found #{Run.count} runs") if @currently_on_no==0
88
+ @logger.info("Exporting from #{@currently_on_no} to #{@currently_on_no+@result_set_size}")
89
+ export(@result_set_size)
90
+ end
91
+ def all
92
+ @logger.info("Found #{Run.count} runs")
93
+ export(nil)
94
+ end
95
+ private
96
+ def export offset=nil
97
+ if offset
98
+ runs=Run.find(:all,:order=>"id ASC",:limit=>@result_set_size,:offset=>@currently_on_no)
99
+ @currently_on_no+=offset
100
+ else
101
+ runs=Run.find(:all)
102
+ end
103
+ return nil if runs.empty?
104
+ export=[]
105
+ runs.each do |run|
106
+ e={:parse_errors=>[],:scenarios=>[],:context=>run.context}
107
+ run.parse_errors.each { |pe| e[:parse_errors]<<{:filename=>pe.filename, :error=>pe.error} }
108
+ run.scenarios.each { |sc| e[:scenarios]<<export_scenario(sc) }
109
+ export<<e
110
+ @logger.debug("Exported #{run.id}")
111
+ end
112
+ return export
113
+ end
114
+ def export_scenario sc
115
+ scenario={:name=>sc[:name],
116
+ :attended=>sc[:attended],
117
+ :status=>sc[:status],
118
+ :number=>sc[:number],
119
+ :start_time=>sc[:start_time],
120
+ :stop_time=>sc[:stop_time],
121
+ :version=>sc[:version],
122
+ :title=>sc[:title],
123
+ :description=>sc[:description],
124
+ :steps=>[]
125
+ }
126
+ sc.steps.each do |step|
127
+ st={:name=>step[:name],
128
+ :number=>step[:number],
129
+ :status=>step[:status],
130
+ :output=>step[:output],
131
+ :error=>step[:error],
132
+ :duration=>step[:duration]
133
+ }
134
+ scenario[:steps]<<st
135
+ end
136
+ return scenario
137
+ end
138
+ end
139
+ #Establishes an ActiveRecord connection
140
+ def self.connect cfg,logger
141
+ conn=cnct(cfg,logger)
142
+ Schema.migrate(:up) if perform_migration?(cfg)
143
+ end
144
+ private
145
+ #Establishes an active record connection using the cfg hash
146
+ #There is only a rudimentary check to ensure the integrity of cfg
147
+ def self.cnct cfg,logger
148
+ if cfg[:adapter] && cfg[:database]
149
+ logger.debug("Connecting to #{cfg[:database]}")
150
+ return ::ActiveRecord::Base.establish_connection(cfg)
151
+ else
152
+ raise Rutema::ConnectionError,"Erroneous database configuration. Missing :adapter and/or :database"
153
+ end
154
+ end
155
+ def self.perform_migration? cfg
156
+ return true if cfg[:migrate]
157
+ #special case for sqlite3
158
+ if cfg[:adapter]=="sqlite3" && !File.exists?(cfg[:database])
159
+ return true
160
+ end
161
+ return false
162
+ end
163
+ end
164
+ end