once-ler 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca5a789c430056627c2d72fee00c15255b7fa5a87674691e97c5e634cbf080fd
4
- data.tar.gz: b0b8b75be9608e4a460d6767ef24d9e12ba66a5c08063df81d999de1b566335a
3
+ metadata.gz: cd1f2be3add85a6cc1457b6c839adb76fbeb2f61269cfe1b4235824f0a93261d
4
+ data.tar.gz: 8b843468d5fcd8706126e2471865c438df311942aa438b26b263361f9eace2d3
5
5
  SHA512:
6
- metadata.gz: 7384764c1e629c58da218f6025cb8cbecf977cbc5eec6ad037f795afc65075801da0f473940a0bd93c54d3e60504cf4dc81cb7e792267ac80ec33bf166cc5fa1
7
- data.tar.gz: 831778e865fe5fa87aaaf00d4e4736c612a560375ed6d8fea213319eb7cbb221bc37e468b23079913456ba3d883fe2a591cbce2972bcdeb96f272b58ac38320f
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
- tests (either via `use_transactional_fixtures=true`, or something like
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!
@@ -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
- rollback_transactions!
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: 1.0.0
4
+ version: 2.0.0
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: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2022-02-16 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: '5.0'
19
+ version: '6.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.1'
22
+ version: '6.2'
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: '5.0'
29
+ version: '6.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.1'
32
+ version: '6.2'
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: '2.2'
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: '2.2'
74
+ version: 2.3.0
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: byebug
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -86,15 +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
- licenses: []
106
+ licenses:
107
+ - MIT
96
108
  metadata: {}
97
- post_install_message:
109
+ post_install_message:
98
110
  rdoc_options: []
99
111
  require_paths:
100
112
  - lib
@@ -102,16 +114,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
114
  requirements:
103
115
  - - ">="
104
116
  - !ruby/object:Gem::Version
105
- version: '2.4'
117
+ version: '2.6'
106
118
  required_rubygems_version: !ruby/object:Gem::Requirement
107
119
  requirements:
108
120
  - - ">="
109
121
  - !ruby/object:Gem::Version
110
122
  version: 2.6.0
111
123
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.6.2
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
@@ -1,12 +0,0 @@
1
- module Onceler
2
- module Transactions
3
- def begin_transaction(conn)
4
- conn.begin_transaction requires_new: true, joinable: false
5
- end
6
-
7
- def rollback_transaction(conn)
8
- conn.rollback_transaction
9
- end
10
- end
11
- end
12
-
@@ -1,2 +0,0 @@
1
- require "active_record"
2
- require "onceler/transactions/active_record"