bts-cucumber 0.1.13.1 → 0.1.13.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ # Based on code from Brian Takita, Yurii Rashkovskii and Ben Mabey
2
+ # Adapted by Aslak Hellesøy
3
+ # Modified by Brian Schroeder to only use ActiveRecord (without ActionController or ActionMailer)
4
+
5
+ if defined?(ActiveRecord::Base)
6
+ throw "ActiveRecord::Base is not defined"
7
+ end
8
+ require 'test/unit/testresult'
9
+
10
+ # So that Test::Unit doesn't launch at the end - makes it think it has already been run.
11
+ Test::Unit.run = true if Test::Unit.respond_to?(:run=)
12
+
13
+ $main = self
14
+
15
+ module Cucumber #:nodoc:
16
+ module ActiveRecord
17
+ # All scenarios will execute in the context of a new instance of World.
18
+ class World
19
+ self.use_transactional_fixtures = false
20
+
21
+ def initialize #:nodoc:
22
+ @_result = Test::Unit::TestResult.new
23
+ end
24
+ end
25
+
26
+ def self.use_transactional_fixtures
27
+ World.use_transactional_fixtures = true
28
+
29
+ $main.Before do
30
+ if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
31
+ ActiveRecord::Base.connection.increment_open_transactions
32
+ else
33
+ ActiveRecord::Base.send :increment_open_transactions
34
+ end
35
+ ActiveRecord::Base.connection.begin_db_transaction
36
+ end
37
+
38
+ $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
42
+ else
43
+ ActiveRecord::Base.send :decrement_open_transactions
44
+ end
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+
51
+ World do
52
+ Cucumber::ActiveRecord::World.new
53
+ 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.1
4
+ version: 0.1.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -193,6 +193,7 @@ files:
193
193
  - lib/cucumber.rb
194
194
  - lib/cucumber/broadcaster.rb
195
195
  - lib/cucumber/cli.rb
196
+ - lib/cucumber/active_record/world.rb
196
197
  - lib/cucumber/core_ext/proc.rb
197
198
  - lib/cucumber/core_ext/string.rb
198
199
  - lib/cucumber/executor.rb