once-ler 1.1.1 → 2.0.1
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 +26 -15
- data/lib/onceler/extensions/database_cleaner.rb +0 -13
- data/lib/onceler/transactions/active_record.rb +0 -12
- 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: 4a7e71ca5ff844380110ac4b4060be81811248388db45dbcb4b4a4e483f485ba
|
4
|
+
data.tar.gz: 8d7c37e025598dd704b0defb6fe457096d60b9ea3a9938078cec9da8bfe23f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0776abbe7e55c9df9da1ab76d8aa3fbb619cb9ba8ef7957f031ddcb98d834a1812f2287b087c6637201898ea5b4b05fd462682899e3396d471ee50d6e0c59134
|
7
|
+
data.tar.gz: 3a1e18714221814c6d07057acbde148b01d2b296232ac308afe107f173fcbf9c107d560e8f56b649d1fcf77b252a78167b55cf73f7187d4beb0b74bf50e241ea
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Jensen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,20 +16,20 @@ 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
|
-
version: '
|
22
|
+
version: '7.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
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
|
-
version: '
|
32
|
+
version: '7.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rspec
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,20 +44,34 @@ 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
|
50
64
|
requirements:
|
51
65
|
- - "~>"
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
67
|
+
version: 2.3.0
|
54
68
|
type: :development
|
55
69
|
prerelease: false
|
56
70
|
version_requirements: !ruby/object:Gem::Requirement
|
57
71
|
requirements:
|
58
72
|
- - "~>"
|
59
73
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
74
|
+
version: 2.3.0
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: byebug
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,16 +100,13 @@ 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
|
97
108
|
metadata: {}
|
98
|
-
post_install_message:
|
109
|
+
post_install_message:
|
99
110
|
rdoc_options: []
|
100
111
|
require_paths:
|
101
112
|
- lib
|
@@ -110,8 +121,8 @@ 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.1.
|
114
|
-
signing_key:
|
124
|
+
rubygems_version: 3.1.4
|
125
|
+
signing_key:
|
115
126
|
specification_version: 4
|
116
127
|
summary: rspec supercharger
|
117
128
|
test_files: []
|
@@ -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