once-ler 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/onceler/basic_helpers.rb +0 -15
- data/lib/onceler/recorder.rb +2 -32
- data/lib/onceler.rb +0 -8
- metadata +19 -8
- data/lib/onceler/extensions/database_cleaner.rb +0 -13
- data/lib/onceler/transactions/active_record.rb +0 -11
- data/lib/onceler/transactions.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd1f2be3add85a6cc1457b6c839adb76fbeb2f61269cfe1b4235824f0a93261d
|
4
|
+
data.tar.gz: 8b843468d5fcd8706126e2471865c438df311942aa438b26b263361f9eace2d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fb8e9cd8a0186d980b0679609457c621fdca31018ced649fa0ae685cf2a9de5df1e0233ff4ed420aee873bc2f61b827d763a7eb45d0203d289a5039d0e61fd8
|
7
|
+
data.tar.gz: 0d2b59543918dfa2bda68a96a81ee68e9aab2f97ce74d7911a00a59e53eefaf2de87ec59f4cb6895015bd5ae5aefb57027e0b4058bfaa1bfb8c1e7f294a5b9c0
|
data/README.md
CHANGED
@@ -129,8 +129,7 @@ of activerecord callbacks/inserts/updates.
|
|
129
129
|
## Caveats
|
130
130
|
|
131
131
|
* If you are doing anything database-y, you need to use transactional
|
132
|
-
|
133
|
-
[database_cleaner](https://github.com/DatabaseCleaner/database_cleaner))
|
132
|
+
test via `use_transactional_fixtures=true`
|
134
133
|
* Your once'd blocks should have no side effects other than database
|
135
134
|
statements, return values, and instance variables.
|
136
135
|
* Your return values and instance variables:
|
@@ -113,21 +113,6 @@ module Onceler
|
|
113
113
|
superclass.onceler
|
114
114
|
end
|
115
115
|
|
116
|
-
# Set this if you have multiple (or different) conns you will be
|
117
|
-
# once-ler'ing. Can either be an enumerable, or a proc that returns
|
118
|
-
# one. Note that if given a proc, it will only be called once (the
|
119
|
-
# first time it's needed) and cached after that.
|
120
|
-
#
|
121
|
-
# context "Foo" do
|
122
|
-
# self.onceler_connections = -> { [Foo.connection] }
|
123
|
-
# ...
|
124
|
-
attr_writer :onceler_connections
|
125
|
-
def onceler_connections
|
126
|
-
@onceler_connections ||= [ActiveRecord::Base.connection]
|
127
|
-
@onceler_connections = instance_eval(&@onceler_connections) if @onceler_connections.respond_to?(:call)
|
128
|
-
@onceler_connections
|
129
|
-
end
|
130
|
-
|
131
116
|
private
|
132
117
|
|
133
118
|
def add_onceler_hooks!
|
data/lib/onceler/recorder.rb
CHANGED
@@ -1,16 +1,7 @@
|
|
1
1
|
require "onceler/recordable"
|
2
|
-
require "onceler/transactions"
|
3
2
|
|
4
3
|
module Onceler
|
5
4
|
class << self
|
6
|
-
def open_transactions
|
7
|
-
@open_transactions ||= 0
|
8
|
-
end
|
9
|
-
|
10
|
-
def open_transactions=(val)
|
11
|
-
@open_transactions = val
|
12
|
-
end
|
13
|
-
|
14
5
|
attr_accessor :recording
|
15
6
|
|
16
7
|
def recording?
|
@@ -19,8 +10,6 @@ module Onceler
|
|
19
10
|
end
|
20
11
|
|
21
12
|
class Recorder
|
22
|
-
include Transactions
|
23
|
-
|
24
13
|
attr_accessor :tape
|
25
14
|
|
26
15
|
def initialize(group_class)
|
@@ -61,8 +50,8 @@ module Onceler
|
|
61
50
|
|
62
51
|
def record!
|
63
52
|
Onceler.recording = true
|
64
|
-
begin_transactions!
|
65
53
|
@tape = @group_class.new
|
54
|
+
@tape.setup_fixtures
|
66
55
|
@tape.send :extend, Recordable
|
67
56
|
@tape.copy_from(parent_tape) if parent_tape
|
68
57
|
|
@@ -92,7 +81,7 @@ module Onceler
|
|
92
81
|
|
93
82
|
def reset!
|
94
83
|
run_before_hooks(:reset)
|
95
|
-
|
84
|
+
@tape&.teardown_fixtures
|
96
85
|
run_after_hooks(:reset)
|
97
86
|
end
|
98
87
|
|
@@ -135,25 +124,6 @@ module Onceler
|
|
135
124
|
instance.instance_variable_set(key, value)
|
136
125
|
end
|
137
126
|
end
|
138
|
-
|
139
|
-
def transactional_connections
|
140
|
-
@group_class.onceler_connections
|
141
|
-
end
|
142
|
-
|
143
|
-
def begin_transactions!
|
144
|
-
Onceler.open_transactions += 1
|
145
|
-
transactional_connections.each do |connection|
|
146
|
-
begin_transaction(connection)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def rollback_transactions!
|
151
|
-
transactional_connections.each do |connection|
|
152
|
-
rollback_transaction(connection)
|
153
|
-
end
|
154
|
-
ensure
|
155
|
-
Onceler.open_transactions -= 1
|
156
|
-
end
|
157
127
|
end
|
158
128
|
|
159
129
|
class Recording
|
data/lib/onceler.rb
CHANGED
@@ -4,11 +4,3 @@ require "rubygems"
|
|
4
4
|
require "onceler/basic_helpers"
|
5
5
|
require "onceler/configuration"
|
6
6
|
require "onceler/extensions/active_record"
|
7
|
-
|
8
|
-
if defined?(DatabaseCleaner)
|
9
|
-
unless !DatabaseCleaner.const_defined?("VERSION") ||
|
10
|
-
Gem::Requirement.new(">= 1.7").satisfied_by?(Gem::Version.new(DatabaseCleaner::VERSION))
|
11
|
-
raise "Onceler in only compatible with DatabaseCleaner >= 1.7."
|
12
|
-
end
|
13
|
-
require "onceler/extensions/database_cleaner"
|
14
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: once-ler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '6.2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '6.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '6.2'
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '3.6'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-rails
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '4.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4.0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: appraisal
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,11 +100,8 @@ files:
|
|
86
100
|
- lib/onceler/basic_helpers.rb
|
87
101
|
- lib/onceler/configuration.rb
|
88
102
|
- lib/onceler/extensions/active_record.rb
|
89
|
-
- lib/onceler/extensions/database_cleaner.rb
|
90
103
|
- lib/onceler/recordable.rb
|
91
104
|
- lib/onceler/recorder.rb
|
92
|
-
- lib/onceler/transactions.rb
|
93
|
-
- lib/onceler/transactions/active_record.rb
|
94
105
|
homepage: http://github.com/instructure/once-ler
|
95
106
|
licenses:
|
96
107
|
- MIT
|
@@ -110,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
121
|
- !ruby/object:Gem::Version
|
111
122
|
version: 2.6.0
|
112
123
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
124
|
+
rubygems_version: 3.1.4
|
114
125
|
signing_key:
|
115
126
|
specification_version: 4
|
116
127
|
summary: rspec supercharger
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require "database_cleaner/active_record/transaction"
|
2
|
-
|
3
|
-
class DatabaseCleaner::ActiveRecord::Transaction
|
4
|
-
include ::Onceler::Transactions
|
5
|
-
|
6
|
-
def start
|
7
|
-
begin_transaction(connection_class.connection)
|
8
|
-
end
|
9
|
-
|
10
|
-
def clean
|
11
|
-
rollback_transaction(connection_class.connection)
|
12
|
-
end
|
13
|
-
end
|
data/lib/onceler/transactions.rb
DELETED