rutema 0.6.5 → 0.7.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/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.7.0 / 2008-05-16
2
+ * Support for tools, paths and context information in the configuration solidified (http://patir.rubyforge.org/rutema/tool_configuration.html for more)
3
+ * Changes in the configuration for Historian and ActiveRecordReporter. Check the distro_test samples
4
+ * database connection code consolidated in db.rb
5
+ * Added support for jdbc/h2 to work with jRuby
6
+ * AR-reporter configuration expanded to support different adapters. Consistent with the Historian db configuration
7
+ * rutema unit tests now run under jRuby
8
+ * rutemah runs under jRuby
9
+
1
10
  == 0.6.5 / 2008-04-15
2
11
  * Updated rutemaweb controller to work with ramaze 0.3.9.1
3
12
  == 0.6.4 / 2008-03-30
data/Manifest.txt CHANGED
@@ -13,6 +13,7 @@ lib/rutema/reporter.rb
13
13
  lib/rutema/reporter_ar.rb
14
14
  lib/rutema/historian.rb
15
15
  lib/rutema/model.rb
16
+ lib/rutema/db.rb
16
17
  lib/rutemaweb/main.rb
17
18
  lib/rutemaweb/ramaze_controller.rb
18
19
  lib/rutemaweb/public/bg_menu.gif
@@ -39,8 +40,6 @@ test/samples/teardown.spec
39
40
  test/samples/test.spec
40
41
  test/samples/tests/no_title.spec
41
42
  test/samples/tests/sample.spec
42
- test/samples/valid_config.rb
43
- test/samples/rutemah_config.rb
44
43
  test/distro_test/config/minimal.rutema
45
44
  test/distro_test/config/database.rutema
46
45
  test/distro_test/config/database.rutemah
@@ -7,18 +7,24 @@ require 'patir/configuration'
7
7
  module Rutema
8
8
  #This module defines the "configuration directives" used in the configuration of RutemaX
9
9
  module RutemaXConfiguration
10
- #Adds a path to a tools to the tools hash of the configuration
10
+ #Adds a hash of values to the tools hash of the configuration
11
+ #
12
+ #
13
+ #This hash is then accessible in the parser and reporters as a property of the configuration instance
11
14
  #
12
15
  #Required keys:
13
16
  # :name - the name to use for accessing the path in code
14
- # :path - the path to the executable
15
17
  #Example:
16
- # configuration.tool={:name=>"make",:path=>"/bin/make"}
18
+ # configuration.tool={:name=>"make",:path=>"/bin/make",:configuration=>{:important=>"info"}}
19
+ #
20
+ #The path to make can be accessed in the parser as
21
+ # @configuration.make[:path]
22
+ #
23
+ #This way you can pass configuration information for the tools you use
17
24
  def tool= definition
18
25
  @tools||=Hash.new
19
26
  raise Patir::ConfigurationException,"required key :name is missing from #{definition}" unless definition[:name]
20
- raise Patir::ConfigurationException,"required key :path is missing from #{definition}" unless definition[:path]
21
- @tools[definition[:name]]=definition[:path]
27
+ @tools[definition[:name]]=definition
22
28
  end
23
29
  #Adds a path to the paths hash of the configuration
24
30
  #
@@ -57,9 +63,9 @@ module Rutema
57
63
  end
58
64
 
59
65
  #Hash values for passing data to the system. It's supposed to be used in the reporters and contain
60
- #values such as verson numbers, tester names etc.
66
+ #values such as version numbers, tester names etc.
61
67
  #
62
- def context_data= definition
68
+ def context= definition
63
69
  @context||=Hash.new
64
70
  raise Patir::ConfigurationException,"Only accepting hash values as context_data" unless definition.kind_of?(Hash)
65
71
  definition.each do |k,v|
@@ -98,6 +104,7 @@ module Rutema
98
104
  end
99
105
 
100
106
  private
107
+ #Checks if a path exists and raises a Patir::ConfigurationException if not
101
108
  def check_path path
102
109
  path=File.expand_path(path)
103
110
  raise Patir::ConfigurationException,"#{path} does not exist" unless File.exists?(path)
@@ -113,13 +120,14 @@ module Rutema
113
120
 
114
121
  #This module defines the "configuration directives" used in the configuration of RutemaH
115
122
  module RutemaHConfiguration
116
- #The configuration keys for the historian's database
117
- def source= definition
118
- if File.exists?(definition)
119
- @source=File.expand_path(definition)
120
- else
121
- raise Patir::ConfigurationException,"DB file '#{definition}' not found"
122
- end
123
+ #The configuration keys for the historian's database. This is adapter dependent.
124
+ #
125
+ #Currently SQLite is supported on MRI and h2 on jRuby.
126
+ #
127
+ #:database defines the name of the file (or directory for h2) to use for the database and is the only required key.
128
+ def db= definition
129
+ raise Patir::ConfigurationException,"required key :database is missing from #{definition}" unless definition[:database]
130
+ @db=definition
123
131
  end
124
132
  end
125
133
  #This class reads a RutemaX configuration file
@@ -144,6 +152,8 @@ module Rutema
144
152
  @configuration.check=@check
145
153
  @configuration.context=OpenStruct.new(@context)
146
154
  @configuration.parser=@parser
155
+ raise Patir::ConfigurationException,"No parser defined" unless @configuration.parser
156
+ raise Patir::ConfigurationException,"Syntax error in parser definition - missing :class" unless @configuration.parser[:class]
147
157
  @configuration.reporters=@reporters
148
158
  @configuration.tests=@tests.collect{|e| File.expand_path(e) }
149
159
  @configuration.filename=@config_file
@@ -161,7 +171,10 @@ module Rutema
161
171
 
162
172
  def configuration
163
173
  cfg=super
164
- cfg.source=@source
174
+ Dir.chdir(File.dirname(config_file)) do |path|
175
+ @db[:database]=File.expand_path(@db[:database])
176
+ cfg.db=@db
177
+ end
165
178
  return cfg
166
179
  end
167
180
  end
data/lib/rutema/db.rb ADDED
@@ -0,0 +1,125 @@
1
+ module Rutema
2
+
3
+ class SQLiteConnection
4
+ def initialize logger, database
5
+ @logger=logger
6
+ @database=database
7
+ end
8
+
9
+ def adapter
10
+ "sqlite3"
11
+ end
12
+
13
+ def connected?
14
+ result = ActiveRecord::Base.connected?
15
+ @logger.debug "Connected " + result.to_s
16
+ return result
17
+ end
18
+
19
+ def connect
20
+ ActiveRecord::Base.establish_connection(:adapter=>adapter, :database=>@database )
21
+ @logger.warn("'#{@database}' does not exist") if !(File.exists?(@database)) && @database!=":memory:"
22
+ connected?
23
+ end
24
+
25
+ def migrate
26
+ return if File.exists?(@database)
27
+ @logger.info "Migrating DB"
28
+ Model::Schema.migrate(:up)
29
+ end
30
+ end
31
+
32
+ class H2Connection
33
+ def initialize logger, database
34
+ @logger=logger
35
+ @database=database
36
+ end
37
+
38
+ def adapter
39
+ "jdbch2"
40
+ end
41
+ def port
42
+ 7098
43
+ end
44
+ def base_dir
45
+ "/"
46
+ end
47
+ def connected?
48
+ begin
49
+ ActiveRecord::Base.retrieve_connection
50
+ rescue RuntimeError
51
+ end
52
+ result = ActiveRecord::Base.connected?
53
+ @logger.debug "Connected " + result.to_s
54
+ result
55
+ end
56
+
57
+ def connect
58
+ connect_server
59
+ if not connected?
60
+ start_server
61
+ connect_server
62
+ end
63
+ connected?
64
+ end
65
+
66
+ def connect_server
67
+ url = server_url
68
+ @logger.info "Connecting to " + server_url
69
+ ActiveRecord::Base.establish_connection(:adapter=>adapter,
70
+ :driver => 'org.h2.Driver',
71
+ :url=> server_url)
72
+ end
73
+
74
+ def server_url
75
+ # database is supposed to be an absolute path
76
+ "jdbc:h2:tcp://localhost:" + port.to_s + @database
77
+ end
78
+
79
+ # Start a h2 server to allow mixed mode accessing.
80
+ def start_server
81
+ args = ["-tcpPort", port.to_s, "-baseDir", base_dir]
82
+ @logger.info "Starting H2 server using arguments " + args.join(" ")
83
+ require 'jdbc/h2'
84
+ Rutema.includeJava
85
+ org.h2.tools.Server.createTcpServer(args.to_java(:string)).start()
86
+ end
87
+
88
+ def migrate
89
+ return if File.exists?("#{@database}.data.db")
90
+ @logger.info "Migrating DB"
91
+ Model::Schema.migrate(:up)
92
+ end
93
+
94
+
95
+ end
96
+
97
+
98
+ #Exception occuring when connecting to a database
99
+ class ConnectionError<RuntimeError
100
+ end
101
+ #Establishes an ActiveRecord connection
102
+ def self.connect_to_ar database,logger,perform_migration=true
103
+ raise ConnectionError,"No database source defined in the configuration" unless database
104
+ logger.debug("Connecting to #{database}")
105
+ conn = connection(logger, database)
106
+ conn.connect
107
+ conn.migrate if perform_migration
108
+ end
109
+
110
+ private
111
+
112
+ @@connection=nil
113
+
114
+ def self.connection logger, database
115
+ if not @@connection
116
+ @@connection = RUBY_PLATFORM =~ /java/ ? H2Connection.new(logger, database) : SQLiteConnection.new(logger, database)
117
+ end
118
+ @@connection
119
+ end
120
+
121
+ def self.includeJava
122
+ # "undefined method 'include'" in instance method
123
+ include Java if RUBY_PLATFORM =~ /java/
124
+ end
125
+ end
@@ -1,6 +1,8 @@
1
- require 'rubygems'
1
+ $:.unshift File.join(File.dirname(__FILE__),"..")
2
2
  require 'rutema/model'
3
3
  require 'rutema/system'
4
+ require 'rutema/db'
5
+ require 'rubygems'
4
6
  require "ruport"
5
7
 
6
8
  module Rutema
@@ -58,22 +60,31 @@ module Rutema
58
60
  @logger=logger
59
61
  @logger||=Patir.setup_logger
60
62
  @configuration=configuration
61
- connect()
63
+ Rutema.connect_to_ar(@configuration.db[:database],@logger,false)
62
64
  end
63
65
 
64
66
  def history mode
65
- case mode
66
- when "all"
67
- table=Model::Scenario.report_table(:all)
68
- @logger.warn("No entries found") if table.empty?
69
- ret=Ruport::Data::Grouping(beautify(table),:by=>"run_id")
70
- when String
71
- ret=per_spec(mode)
67
+ begin
68
+ case mode
69
+ when "all"
70
+ table=Model::Scenario.report_table(:all)
71
+ if table.empty?
72
+ @logger.warn("No entries found")
73
+ else
74
+ ret=Ruport::Data::Grouping(beautify(table),:by=>"run_id")
75
+ end
76
+ when String
77
+ ret=per_spec(mode)
78
+ end
79
+ rescue
80
+ @logger.debug($!)
81
+ @logger.error("Could not retrieve scenario data from the database")
72
82
  end
73
83
  return ret
74
84
  end
75
85
  private
76
86
  def beautify table
87
+ @logger.debug("Beautifying...")
77
88
  table.reorder("run_id","name","status","attended","version","start_time","stop_time")
78
89
  table.replace_column("version") {|r| r.version ? r.version : "N/A"}
79
90
  table.replace_column("attended") {|r| r.attended=="t" ? "yes" : "no"}
@@ -81,37 +92,15 @@ module Rutema
81
92
  return table
82
93
  end
83
94
  def per_spec spec_name
84
- begin
85
- table=Model::Scenario.report_table(:all,:conditions=>"name = '#{spec_name}'",:except=>["id","number"])
86
- if table.empty?
87
- @logger.warn("No test run records found for #{spec_name}")
88
- nil
89
- else
90
- beautify(table)
91
- end
92
- rescue
93
- @logger.debug($!)
94
- @logger.error("Could not retrieve scenario data from the database")
95
- end
96
- end
97
- def connect
98
- ActiveRecord::Base.logger = @logger
99
- if @configuration.source
100
- if ActiveRecord::Base.connected?
101
- @logger.info("Using cached database connection")
102
- else
103
- if File.exist?(@configuration.source) || @configuration.source==":memory:"
104
- @logger.info("Connecting with database '#{@configuration.source}'")
105
- ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>@configuration.source )
106
- else
107
- @logger.fatal("Could not find #{@configuration.source}")
108
- exit 1
109
- end
110
- end
95
+ @logger.debug("History of #{spec_name}")
96
+ table=Model::Scenario.report_table(:all,:conditions=>"name = '#{spec_name}'",:except=>["id","number"])
97
+ if table.empty?
98
+ @logger.warn("No test run records found for #{spec_name}")
99
+ nil
111
100
  else
112
- @logger.fatal("No database source defined in the configuration")
113
- exit 1
101
+ beautify(table)
114
102
  end
103
+
115
104
  end
116
105
  end
117
106
  end
@@ -2,24 +2,31 @@
2
2
  require 'yaml'
3
3
  require 'rutema/reporter'
4
4
  require 'rutema/model'
5
+ require 'rutema/db'
5
6
  require 'rubygems'
6
7
  require 'patir/command'
7
8
 
8
9
  module Rutema
9
10
  #The ActiveRecordReporter will store the results of a test run in a database using ActiveRecord.
10
11
  #
11
- #The current implementation uses SQLite as the DBMS until we get enough time to implement the rest of the configuration.
12
+ #The DBMSs supported are dependent on the platform: either SQLite3 or h2 (jruby)
12
13
  class ActiveRecordReporter<Reporter
14
+ #The required keys in this reporter's configuration are:
15
+ # :db - the database configuration. A Hash with the DB adapter information
16
+ # :db=>{:database=>"sample.rb"}
17
+ #
18
+ #Optioanlly you can pass a Logger instance with the :logger key
13
19
  def initialize definition
14
20
  @logger=definition[:logger]
15
21
  @logger||=Patir.setup_logger
16
- raise "No database file defined" unless definition[:dbfile]
17
- unless definition[:dbfile]==":memory:"
18
- @dbfile=File.expand_path(definition[:dbfile])
22
+ database_configuration = definition[:db]
23
+ raise "No database configuration defined" unless database_configuration
24
+ unless database_configuration[:database]==":memory:"
25
+ @dbfile=File.expand_path(database_configuration[:database])
19
26
  else
20
- @dbfile=definition[:dbfile]
27
+ @dbfile=database_configuration[:database]
21
28
  end
22
- connect
29
+ Rutema.connect_to_ar(@dbfile,@logger)
23
30
  end
24
31
 
25
32
  #We get all the data for a Rutema::Model::Run entry in here.
@@ -70,13 +77,5 @@ module Rutema
70
77
  run_entry.save!
71
78
  end
72
79
 
73
- private
74
- def connect
75
- ActiveRecord::Base.logger = @logger
76
- @logger.info("Connecting with database '#{@dbfile}'")
77
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3",
78
- :database => @dbfile)
79
- Model::Schema.migrate(:up) unless File.exists?(@dbfile)
80
- end
81
80
  end
82
81
  end
data/lib/rutema/system.rb CHANGED
@@ -1,12 +1,10 @@
1
1
  # Copyright (c) 2007 Vassilis Rizopoulos. All rights reserved.
2
2
 
3
3
  require 'rexml/document'
4
-
4
+ $:.unshift File.join(File.dirname(__FILE__),"..")
5
5
  require 'rutema/specification'
6
6
  require 'rutema/configuration'
7
7
  require 'rutema/reporter_ar'
8
-
9
-
10
8
  require 'rubygems'
11
9
  require 'highline'
12
10
  require 'patir/command'
@@ -15,8 +13,8 @@ module Rutema
15
13
  #This module defines the version numbers for the library
16
14
  module Version
17
15
  MAJOR=0
18
- MINOR=6
19
- TINY=5
16
+ MINOR=7
17
+ TINY=0
20
18
  STRING=[ MAJOR, MINOR, TINY ].join( "." )
21
19
  end
22
20
  #Is raised when an error is found in a specification
@@ -604,10 +602,10 @@ module Rutema
604
602
  @logger.info("Report:\n#{@coordinator.to_s}")
605
603
  @coordinator.report
606
604
  if @coordinator.parse_errors.empty? && @coordinator.last_run_a_success?
607
- @logger.info("All tests succesful")
605
+ @logger.info("All tests successful")
608
606
  exit 0
609
607
  else
610
- @logger.warn("Not all tests were succesful")
608
+ @logger.warn("Not all tests were successful")
611
609
  exit 1
612
610
  end
613
611
  end
@@ -7,30 +7,13 @@ def start_ramaze
7
7
  logger=Patir.setup_logger
8
8
  db_file=parse_command_line(ARGV)
9
9
  db_file=File.expand_path(db_file)
10
- connect(db_file,logger)
10
+ Rutema.connect_to_ar(db_file,logger)
11
11
  require 'rutemaweb/ramaze_controller'
12
12
  Dir.chdir(File.dirname(__FILE__)) do
13
13
  Ramaze.start :force=>true#,:adapter=>:thin
14
14
  end
15
15
  end
16
- def connect db_file,logger
17
- if db_file
18
- if ActiveRecord::Base.connected?
19
- logger.info("Using cached database connection")
20
- else
21
- if File.exist?(db_file)
22
- logger.info("Connecting with database '#{db_file}'")
23
- ActiveRecord::Base.establish_connection(:adapter=>"sqlite3", :database=>db_file )
24
- else
25
- logger.fatal("Could not find #{db_file}")
26
- exit 1
27
- end
28
- end
29
- else
30
- logger.fatal("No database source defined in the configuration")
31
- exit 1
32
- end
33
- end
16
+
34
17
 
35
18
  def parse_command_line args
36
19
  args.options do |opt|
@@ -99,4 +99,7 @@ table {
99
99
  }
100
100
  .smallredtext a:hover{
101
101
  text-decoration:underline;
102
+ }
103
+ .vtable tr td {
104
+ text-align: left;
102
105
  }
@@ -3,6 +3,7 @@ $:.unshift File.join(File.dirname(__FILE__),"..")
3
3
  require 'rutema/system'
4
4
  require 'rubygems'
5
5
  require 'ramaze'
6
+ require 'rutemaweb/ruport_formatter.rb'
6
7
 
7
8
 
8
9
  module Rutema
@@ -82,8 +83,7 @@ module Rutema
82
83
  img_src=IMG_STEP_ERROR if "error"==r.status
83
84
  "<img src=\"#{img_src}\" align=\"center\"/>"
84
85
  end
85
- table.reorder("number","status","name","output","error","duration")
86
- ret=table.to_html
86
+ ret=table.to_vhtml
87
87
  end
88
88
  return ret
89
89
  end
@@ -1,5 +1,9 @@
1
+ #The parser to use
1
2
  configuration.parser={:class=>Rutema::MinimalXMLParser}
2
- configuration.reporter={:class=>Rutema::ActiveRecordReporter, :dbfile=>"sample.db"}
3
+ #Use the AR-Reporter.
4
+ #In case of reporters the whole Hash is passed to the reporter initializer, so any keys are dependent on the reporter to use
5
+ #Check the appropriate RDoc entries
6
+ configuration.reporter={:class=>Rutema::ActiveRecordReporter, :db=>{:database=>"sample.db"}}
3
7
  configuration.tests=[
4
8
  "../specs/T001.spec",
5
9
  "../specs/T002.spec",
@@ -1,2 +1,7 @@
1
+ #include the configuration from database.rutema
1
2
  configuration.load_from_file("database.rutema")
2
- configuration.source="sample.db"
3
+ #This is the verbose version of the configuration entry:
4
+ #configuration.db={:database=>"sample.db",:adapter=>"sqlite3"}
5
+ #For the time being the adapter is being automatically set according to the platform we're running on, so the :adapter is ignored
6
+ #SQLite for MRI and h2 for jRuby
7
+ configuration.db={:database=>"sample.db"}
@@ -1,7 +1,7 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
3
  require 'test/unit'
4
-
4
+ #$DEBUG=true
5
5
  module TestRutema
6
6
  require 'rutema/system'
7
7
 
@@ -13,23 +13,35 @@ module TestRutema
13
13
  def teardown
14
14
  Dir.chdir(@prev_dir)
15
15
  end
16
- def test_configuration
16
+ def test_rutemax_configuration
17
17
  cfg=nil
18
18
  #load the valid configuration
19
- assert_nothing_raised() { cfg=Rutema::RutemaXConfigurator.new("samples/valid_config.rb").configuration}
19
+ assert_nothing_raised() { cfg=Rutema::RutemaXConfigurator.new("distro_test/config/full.rutema").configuration}
20
20
  assert_not_nil(cfg.parser)
21
21
  assert_not_nil(cfg.reporters)
22
22
  assert_equal(1, cfg.reporters.size)
23
23
  assert_not_nil(cfg.tools)
24
+ assert_not_nil(cfg.tools.test[:configuration])
25
+ assert_not_nil(cfg.tools.test[:path])
26
+ assert_equal("test", cfg.tools.test[:name])
24
27
  assert_not_nil(cfg.paths)
28
+ assert_not_nil(cfg.paths.test)
25
29
  assert_not_nil(cfg.setup)
26
30
  assert_not_nil(cfg.teardown)
27
31
  assert_not_nil(cfg.check)
28
32
  assert_not_nil(cfg.tests)
29
33
  assert_not_nil(cfg.context)
30
34
  end
35
+ def test_rutemah_configuration
36
+ cfg=nil
37
+ #load the valid configuration
38
+ assert_nothing_raised() { cfg=Rutema::RutemaHConfigurator.new("distro_test/config/database.rutemah").configuration}
39
+ assert_not_nil(cfg.db)
40
+ assert_nothing_raised() { cfg=Rutema::RutemaHConfigurator.new("distro_test/config/jruby.rutemah").configuration}
41
+ assert_not_nil(cfg.db)
42
+ end
31
43
  def test_specification_paths
32
- cfg=Rutema::RutemaXConfigurator.new("samples/valid_config.rb").configuration
44
+ cfg=Rutema::RutemaXConfigurator.new("distro_test/config/full.rutema").configuration
33
45
  assert_not_nil(cfg.tests)
34
46
  end
35
47
  end
@@ -1,5 +1,4 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
- $:.unshift File.join(File.dirname(__FILE__),"..","ext")
3
2
  require 'test/unit'
4
3
  require 'ostruct'
5
4
  require 'fileutils'
@@ -7,23 +6,38 @@ require 'rutema/historian'
7
6
  #$DEBUG=true
8
7
  module TestRutema
9
8
  class TestHistorian<Test::Unit::TestCase
10
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3",:database =>":memory:")
11
- Rutema::Model::Schema.up
12
9
  def setup
13
10
  @configuration=OpenStruct.new
14
- @configuration.source=":memory:"
15
- a_bunch_of_data
11
+ @configuration.db={:database=>":memory:"}
12
+ @configuration.db={:database=>"db/h2"} if RUBY_PLATFORM =~ /java/
16
13
  end
17
14
  def teardown
15
+ ActiveRecord::Base.remove_connection
16
+ FileUtils.rm_rf("db/") if File.exists?("db/")
18
17
  end
19
18
  def test_history
20
19
  assert_nothing_raised() do
21
20
  h=Rutema::Historian.new(@configuration)
21
+ Rutema::Model::Schema.up
22
+ a_bunch_of_data
22
23
  assert_not_nil( h.history("all"), "There should be some history there" )
23
24
  assert_not_nil(h.history("TC001"), "TC001 should have some history" )
24
25
  assert_nil(h.history("test5"), "No history expected of test5" )
25
- puts h.history("all")
26
- puts h.history("TC002")
26
+ assert_not_nil( h.history("all") )
27
+ assert_not_nil( h.history("TC002") )
28
+ end
29
+ end
30
+ def test_no_db
31
+ ActiveRecord::Base.remove_connection
32
+ if RUBY_PLATFORM =~ /java/
33
+ @configuration.db={:database=>"foo",:adapter=>"jdbch2"}
34
+ else
35
+ @configuration.db={:database=>"foo",:adapter=>"sqlite3"}
36
+
37
+ end
38
+ assert_nothing_raised() do
39
+ h=Rutema::Historian.new(@configuration)
40
+ assert_nothing_raised() { h.history("all")}
27
41
  end
28
42
  end
29
43
 
@@ -39,23 +53,30 @@ module TestRutema
39
53
  1.upto(2) do |i|
40
54
  steps=[]
41
55
  steps<<Rutema::Model::Step.new(:name=>"hard",:number=>1,:status=>"success",
42
- :output=>"the first step is hard",:error=>"",:duration=>1)
56
+ :output=>"the first step is hard",:error=>"",:duration=>1)
43
57
  steps<<Rutema::Model::Step.new(:name=>"easy",:number=>2,:status=>"success",
44
- :output=>"the next step is easy",:error=>"",:duration=>1)
58
+ :output=>"the next step is easy",:error=>"",:duration=>1)
45
59
  scenarios<<Rutema::Model::Scenario.new(:name=>"TC00#{i}",:version=>"100",
46
- :attended=>false,:status=>"success",
47
- :start_time=>(Time.now-10000*i),:stop_time=>(Time.now-10000*i),
48
- :steps=>steps)
60
+ :attended=>false,:status=>"success",
61
+ :start_time=>(Time.now-10000*i),:stop_time=>(Time.now-10000*i),
62
+ :steps=>steps)
49
63
  end
50
64
  return scenarios
51
65
  end
52
66
  def failure_scenarios
53
67
  failed_step=Rutema::Model::Step.new(:name=>"echo",:number=>1,:status=>"error",
54
- :output=>"Hel^.",:error=>"IO error",:duration=>1)
68
+ :output=>"Hel^.",:error=>"IO error",:duration=>1)
55
69
  [Rutema::Model::Scenario.new(:name=>"TC003",:version=>"10",
56
70
  :attended=>false,:status=>"error",:steps=>[failed_step],
57
71
  :start_time=>(Time.now-10000),:stop_time=>Time.now)]
72
+ end
73
+ def setup_for_mri
74
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3",:database =>":memory:")
75
+ @configuration.db={:database=>":memory:",:adapter=>"sqlite3"}
76
+ end
77
+ def setup_for_java
78
+ ActiveRecord::Base.establish_connection(:adapter => "jdbch2",:database =>"db/h2")
79
+ @configuration.db={:database=>"db/h2",:adapter=>"jdbch2"}
80
+ end
58
81
  end
59
-
60
- end
61
- end
82
+ end
data/test/test_model.rb CHANGED
@@ -2,13 +2,24 @@ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
3
  require 'test/unit'
4
4
  require 'rutema/model'
5
+ require 'fileutils'
5
6
  require 'rubygems'
6
7
  require 'active_record/fixtures'
7
8
 
8
9
  module TestRutema
9
10
  class TestModel<Test::Unit::TestCase
10
- ActiveRecord::Base.establish_connection(:adapter=>"sqlite3",:dbfile=>":memory:")
11
- Rutema::Model::Schema.up
11
+ def setup
12
+ if RUBY_PLATFORM =~ /java/
13
+ ActiveRecord::Base.establish_connection(:adapter => "jdbch2",:database =>"db/h2")
14
+ else
15
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3",:database =>":memory:")
16
+ end
17
+ Rutema::Model::Schema.up
18
+ end
19
+ def teardown
20
+ ActiveRecord::Base.remove_connection
21
+ FileUtils.rm_rf("db/") if File.exists?("db/")
22
+ end
12
23
  #test the CRUD operations
13
24
  def test_create_read_update_delete
14
25
  #create
@@ -14,7 +14,6 @@ module TestRutema
14
14
  end
15
15
  end
16
16
  class TestActiveRecordReporter<Test::Unit::TestCase
17
- DB_FILE=":memory:"
18
17
  def setup
19
18
  @prev_dir=Dir.pwd
20
19
  Dir.chdir(File.dirname(__FILE__))
@@ -29,8 +28,12 @@ module TestRutema
29
28
  test2.step=MockCommand.new(2)
30
29
  test2.step=MockCommand.new(3)
31
30
  @status=[test1,test2]
31
+ @database={:db=>{:database=>":memory:"}}
32
+ @database={:db=>{:database=>"db/h2"}} if RUBY_PLATFORM =~ /java/
32
33
  end
33
34
  def teardown
35
+ ActiveRecord::Base.remove_connection
36
+ FileUtils.rm_rf("db")
34
37
  Dir.chdir(@prev_dir)
35
38
  end
36
39
  def test_report
@@ -39,7 +42,7 @@ module TestRutema
39
42
  specs={"test1"=>spec1,
40
43
  "test2"=>spec2
41
44
  }
42
- r=Rutema::ActiveRecordReporter.new(:dbfile=>DB_FILE)
45
+ r=Rutema::ActiveRecordReporter.new(@database)
43
46
  #without configuration
44
47
  assert_nothing_raised() { r.report(specs,@status,@parse_errors,nil) }
45
48
  configuration=OpenStruct.new
data/test/test_system.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
- $:.unshift File.join(File.dirname(__FILE__),"..","ext")
3
2
  require 'test/unit'
4
3
  require 'ostruct'
5
4
  require 'rubygems'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rutema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vassilis Rizopoulos
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-15 00:00:00 +02:00
12
+ date: 2008-05-16 00:00:00 +02:00
13
13
  default_executable: rutemax
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -122,6 +122,7 @@ files:
122
122
  - lib/rutema/reporter_ar.rb
123
123
  - lib/rutema/historian.rb
124
124
  - lib/rutema/model.rb
125
+ - lib/rutema/db.rb
125
126
  - lib/rutemaweb/main.rb
126
127
  - lib/rutemaweb/ramaze_controller.rb
127
128
  - lib/rutemaweb/public/bg_menu.gif
@@ -148,8 +149,6 @@ files:
148
149
  - test/samples/test.spec
149
150
  - test/samples/tests/no_title.spec
150
151
  - test/samples/tests/sample.spec
151
- - test/samples/valid_config.rb
152
- - test/samples/rutemah_config.rb
153
152
  - test/distro_test/config/minimal.rutema
154
153
  - test/distro_test/config/database.rutema
155
154
  - test/distro_test/config/database.rutemah
@@ -1,3 +0,0 @@
1
- #$:.unshift File.dirname(__FILE__)
2
- configuration.load_from_file("valid_config.rb")
3
- configuration.source="test.db"
@@ -1,20 +0,0 @@
1
- require 'rake'
2
- #
3
- configuration.parser={:class=>Rutema::MinimalXMLParser}
4
- configuration.reporter={:class=>Rutema::EmailReporter,
5
- :server=>"localhost",
6
- :port=>25,
7
- :recipients=>["test"],
8
- :sender=>"rutema",
9
- :subject=>"test",
10
- :dummy=>true
11
- }
12
- configuration.tool={:name=>"echo",:path=>"echo.exe"}
13
- configuration.tool={:name=>"tool",:path=>"tool.exe"}
14
- configuration.path={:name=>"SourcePath",:path=>"../../lib"}
15
- configuration.setup="setup.spec"
16
- configuration.teardown="teardown.spec"
17
- configuration.check="check.spec"
18
- configuration.tests=["test.spec"]
19
- configuration.tests=Rake::FileList["tests/*.spec"]
20
- configuration.context_data={:tester=>"riva"}