bts-cucumber 0.1.13.2 → 0.1.13.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,9 +2,14 @@
2
2
  # Adapted by Aslak Hellesøy
3
3
  # Modified by Brian Schroeder to only use ActiveRecord (without ActionController or ActionMailer)
4
4
 
5
- if defined?(ActiveRecord::Base)
5
+ if !defined?(ActiveRecord::Base)
6
6
  throw "ActiveRecord::Base is not defined"
7
7
  end
8
+
9
+ require 'test/unit'
10
+ require 'active_record/fixtures'
11
+ # client user needs to set Test::Unit::TestCase.fixture_path on their own
12
+
8
13
  require 'test/unit/testresult'
9
14
 
10
15
  # So that Test::Unit doesn't launch at the end - makes it think it has already been run.
@@ -15,7 +20,33 @@ $main = self
15
20
  module Cucumber #:nodoc:
16
21
  module ActiveRecord
17
22
  # All scenarios will execute in the context of a new instance of World.
18
- class World
23
+ class World < Test::Unit::TestCase
24
+
25
+ # From Rails' ActionController::IntegrationTest
26
+ class << self
27
+ def use_transactional_fixtures=(flag) #:nodoc:
28
+ @_use_transactional_fixtures = true
29
+ @use_transactional_fixtures = flag
30
+ end
31
+
32
+ def use_instantiated_fixtures=(flag) #:nodoc:
33
+ @_use_instantiated_fixtures = true
34
+ @use_instantiated_fixtures = flag
35
+ end
36
+
37
+ def use_transactional_fixtures #:nodoc:
38
+ @_use_transactional_fixtures ?
39
+ @use_transactional_fixtures :
40
+ superclass.use_transactional_fixtures
41
+ end
42
+
43
+ def use_instantiated_fixtures #:nodoc:
44
+ @_use_instantiated_fixtures ?
45
+ @use_instantiated_fixtures :
46
+ superclass.use_instantiated_fixtures
47
+ end
48
+ end
49
+
19
50
  self.use_transactional_fixtures = false
20
51
 
21
52
  def initialize #:nodoc:
@@ -27,20 +58,20 @@ module Cucumber #:nodoc:
27
58
  World.use_transactional_fixtures = true
28
59
 
29
60
  $main.Before do
30
- if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
31
- ActiveRecord::Base.connection.increment_open_transactions
61
+ if ::ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
62
+ ::ActiveRecord::Base.connection.increment_open_transactions
32
63
  else
33
- ActiveRecord::Base.send :increment_open_transactions
64
+ ::ActiveRecord::Base.send :increment_open_transactions
34
65
  end
35
- ActiveRecord::Base.connection.begin_db_transaction
66
+ ::ActiveRecord::Base.connection.begin_db_transaction
36
67
  end
37
68
 
38
69
  $main.After do
39
- ActiveRecord::Base.connection.rollback_db_transaction
40
- if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
41
- ActiveRecord::Base.connection.decrement_open_transactions
70
+ ::ActiveRecord::Base.connection.rollback_db_transaction
71
+ if ::ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
72
+ ::ActiveRecord::Base.connection.decrement_open_transactions
42
73
  else
43
- ActiveRecord::Base.send :decrement_open_transactions
74
+ ::ActiveRecord::Base.send :decrement_open_transactions
44
75
  end
45
76
  end
46
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bts-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13.2
4
+ version: 0.1.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"