prefactory 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: 1332489daa6ce963998267eb39bf65c86230c965
4
- data.tar.gz: 87cbdfcf4efeee19253b6faeefdd70f9063c3431
3
+ metadata.gz: 6838c79473272087e2903348125c9adf2f9cdfe6
4
+ data.tar.gz: c32580da0f0b491e4bb2ab9678a257faebbe8f4e
5
5
  SHA512:
6
- metadata.gz: e0955140a9e5b688c1126ec1cfef0535feb29b0fd01340e7aca0c030b0efc9975721d0b5440473599e4b6150ec1cff9b6b7705515537170148c74f06f425cfff
7
- data.tar.gz: db7508fef186aad0c0a9b2e49cd421ec86bd09865ba10efcc9db0bd28e83cbd082f6b17dd5850549572db571e66f5f5ecce9e0c9a1f591a1859b3e6352ea5108
6
+ metadata.gz: d0cc5f57c32ddc83a8c284e60f197637f8e1861261f372d146cc97cea3342e933e930dfe42186505a4b92e4f31fa6177ef88cb35ef4af96a73aa7d740ff650bd
7
+ data.tar.gz: 93fc81a665cc1ba0d0e0a9de7c3197a36b151dcb69e02501c16d3a94f0db00e5d0cb8b9aa07503868f2ba391f8aba7301d01bd4c01330a2820b768060c3643e9
@@ -4,5 +4,7 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.2
6
6
  env:
7
- - "ACTIVE_RECORD_VERSION=4.0.0"
8
- - "ACTIVE_RECORD_VERSION=4.1.0"
7
+ - ACTIVE_RECORD_VERSION=4.0.0 RSPEC_VERSION=2.99
8
+ - ACTIVE_RECORD_VERSION=4.0.0
9
+ - ACTIVE_RECORD_VERSION=4.1.0 RSPEC_VERSION=2.99
10
+ - ACTIVE_RECORD_VERSION=4.1.0
data/README.md CHANGED
@@ -7,7 +7,8 @@ The ease and fidelity of factories with the performance of static fixtures.
7
7
  Prefactory allows you to create factory objects and perform other
8
8
  expensive ActiveRecord operations in RSpec before(:all) blocks, transparently
9
9
  wrapping example groups in nested transactions to automatically roll back
10
- any data changes that occur during a specific test.
10
+ any data changes that occur during a specific test, while also ensuring
11
+ after-commit callbacks are executed for the synthetic commits.
11
12
 
12
13
  ## Requirements
13
14
 
@@ -41,7 +42,7 @@ RSpec.configure do |config|
41
42
  end
42
43
  ```
43
44
 
44
- ## Example
45
+ ## Example Usage
45
46
 
46
47
  ``` ruby
47
48
  describe User do
@@ -100,6 +101,8 @@ describe User do
100
101
  end
101
102
  ```
102
103
 
104
+ See also: [An example rails application with Prefactory configured](https://github.com/seanwalbran/prefactory-example)
105
+
103
106
  ## Contributing
104
107
 
105
108
  1. Fork it ( http://github.com/socialcast/prefactory/fork )
@@ -21,5 +21,5 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  module Prefactory
24
- VERSION = "0.2.0"
24
+ VERSION = "0.3.0"
25
25
  end
@@ -93,6 +93,7 @@ module Prefactory
93
93
  # are scoped only to the group.
94
94
  base.instance_eval do
95
95
  def describe_with_transaction(*args, &block)
96
+ original_caller = caller
96
97
  modified_block = proc do
97
98
  instance_eval do
98
99
  before(:all) { clear_prefactory_memoizations }
@@ -103,6 +104,14 @@ module Prefactory
103
104
  end
104
105
  instance_eval(&block)
105
106
  end
107
+
108
+ caller_metadata = { :caller => original_caller }
109
+ if args.last.is_a?(Hash)
110
+ args.last.merge!(caller_metadata)
111
+ else
112
+ args << caller_metadata
113
+ end
114
+
106
115
  describe_without_transaction(*args, &modified_block)
107
116
  end
108
117
 
@@ -3,6 +3,12 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'prefactory/version'
5
5
 
6
+ rspec_version = if ENV["RSPEC_VERSION"].to_s == ''
7
+ nil
8
+ else
9
+ "~> #{ENV['RSPEC_VERSION']}"
10
+ end
11
+
6
12
  active_record_version = case ENV["ACTIVE_RECORD_VERSION"].to_s
7
13
  when 'master'
8
14
  { github: "rails/activerecord" }
@@ -28,6 +34,7 @@ Gem::Specification.new do |spec|
28
34
  spec.require_paths = ['lib']
29
35
 
30
36
  spec.add_dependency 'rspec_around_all', '~> 0'
37
+ spec.add_dependency('rspec', rspec_version) if rspec_version
31
38
  spec.add_dependency 'activerecord', active_record_version
32
39
  spec.add_dependency 'factory_girl_rails', '~> 4'
33
40
 
@@ -32,9 +32,9 @@ describe Prefactory do
32
32
  @in_before_each = in_before_all?
33
33
  end
34
34
  it "is only true when called inside a before(:all)" do
35
- @in_before_all.should be_true
36
- @in_before_each.should be_false
37
- in_before_all?.should be_false # in this it-block context
35
+ expect(@in_before_all).to be_truthy
36
+ expect(@in_before_each).to be_falsey
37
+ expect(in_before_all?).to be_falsey # in this it-block context
38
38
  end
39
39
  after(:each) do
40
40
  flunk if in_before_all?
@@ -44,6 +44,23 @@ describe Prefactory do
44
44
  end
45
45
  end
46
46
 
47
+ describe "location metadata" do
48
+ context "with no other user metadata" do
49
+ it do
50
+ expect(RSpec.current_example.metadata[:location]).to include "prefactory_spec.rb"
51
+ expect(RSpec.current_example.metadata[:example_group][:location]).to include "prefactory_spec.rb"
52
+ end
53
+ end
54
+ context "with other user metadata", :foo => :bar, :baz => :bop do
55
+ it do
56
+ expect(RSpec.current_example.metadata[:location]).to include "prefactory_spec.rb"
57
+ expect(RSpec.current_example.metadata[:example_group][:location]).to include "prefactory_spec.rb"
58
+ expect(RSpec.current_example.metadata[:foo]).to eq(:bar)
59
+ expect(RSpec.current_example.metadata[:baz]).to eq(:bop)
60
+ end
61
+ end
62
+ end
63
+
47
64
  describe "#prefactory_add" do
48
65
 
49
66
  context "when passing a block with no FactoryGirl activity" do
@@ -53,12 +70,12 @@ describe Prefactory do
53
70
  end
54
71
  end
55
72
  it "creates an object using the provided name" do
56
- my_blog.should be_present
57
- my_blog.title.should == 'My Blog'
58
- my_blog.id.should be_present
59
- Blog.where(:id => my_blog.id).should exist
60
- prefactory(:my_blog).should == my_blog
61
- my_blog.counter.should be_nil
73
+ expect(my_blog).to be_present
74
+ expect(my_blog.title).to eq('My Blog')
75
+ expect(my_blog.id).to be_present
76
+ expect(Blog.where(:id => my_blog.id)).to exist
77
+ expect(prefactory(:my_blog)).to eq(my_blog)
78
+ expect(my_blog.counter).to be_nil
62
79
  end
63
80
  end
64
81
 
@@ -67,12 +84,12 @@ describe Prefactory do
67
84
  prefactory_add :blog
68
85
  end
69
86
  it "creates an object based on the factory name, via FactoryGirl::Syntax::Methods" do
70
- blog.should be_present
71
- blog.title.should =~ /\ATitle [0-9]+\z/
72
- blog.id.should be_present
73
- Blog.where(:id => blog.id).should exist
74
- prefactory(:blog).should == blog
75
- blog.counter.should be_nil
87
+ expect(blog).to be_present
88
+ expect(blog.title).to match(/\ATitle [0-9]+\z/)
89
+ expect(blog.id).to be_present
90
+ expect(Blog.where(:id => blog.id)).to exist
91
+ expect(prefactory(:blog)).to eq(blog)
92
+ expect(blog.counter).to be_nil
76
93
  end
77
94
  end
78
95
  context "when passing a factory name and additional attributes" do
@@ -80,12 +97,12 @@ describe Prefactory do
80
97
  prefactory_add :blog, :counter => 12
81
98
  end
82
99
  it "uses the additional attributes" do
83
- blog.should be_present
84
- blog.title.should =~ /\ATitle [0-9]+\z/
85
- blog.id.should be_present
86
- Blog.where(:id => blog.id).should exist
87
- prefactory(:blog).should == blog
88
- blog.counter.should == 12
100
+ expect(blog).to be_present
101
+ expect(blog.title).to match(/\ATitle [0-9]+\z/)
102
+ expect(blog.id).to be_present
103
+ expect(Blog.where(:id => blog.id)).to exist
104
+ expect(prefactory(:blog)).to eq(blog)
105
+ expect(blog.counter).to eq(12)
89
106
  end
90
107
  end
91
108
  context "when using a different name and an explicit create call in a block" do
@@ -93,12 +110,12 @@ describe Prefactory do
93
110
  prefactory_add(:some_other_blog) { create :blog, :counter => 24 }
94
111
  end
95
112
  it "uses the other name" do
96
- some_other_blog.should be_present
97
- some_other_blog.title.should =~ /\ATitle [0-9]+\z/
98
- some_other_blog.id.should be_present
99
- Blog.where(:id => some_other_blog.id).should exist
100
- prefactory(:some_other_blog).should == some_other_blog
101
- some_other_blog.counter.should == 24
113
+ expect(some_other_blog).to be_present
114
+ expect(some_other_blog.title).to match(/\ATitle [0-9]+\z/)
115
+ expect(some_other_blog.id).to be_present
116
+ expect(Blog.where(:id => some_other_blog.id)).to exist
117
+ expect(prefactory(:some_other_blog)).to eq(some_other_blog)
118
+ expect(some_other_blog.counter).to eq(24)
102
119
  end
103
120
  end
104
121
  context "when referencing the object within the before-all block" do
@@ -107,25 +124,25 @@ describe Prefactory do
107
124
  blog.update_attributes! :counter => 42
108
125
  end
109
126
  it "works" do
110
- blog.counter.should == 42
127
+ expect(blog.counter).to eq(42)
111
128
  end
112
129
  end
113
130
  context "nesting a before-all with a prefactory_add" do
114
131
  before :all do
115
132
  prefactory_add :blog, :title => 'the big book of trains'
116
133
  end
117
- it { blog.should be_present }
134
+ it { expect(blog).to be_present }
118
135
  context "and another before-all prefactory_add" do
119
136
  before :all do
120
137
  prefactory_add :comment, :blog => blog, :text => 'old text'
121
138
  end
122
139
  it do
123
- comment.should be_present
124
- comment.blog.should == blog
140
+ expect(comment).to be_present
141
+ expect(comment.blog).to eq(blog)
125
142
  end
126
143
  it do
127
- blog.should be_present
128
- blog.title.should == 'the big book of trains'
144
+ expect(blog).to be_present
145
+ expect(blog.title).to eq('the big book of trains')
129
146
  end
130
147
  context "when modifying the object in a before-each" do
131
148
  before do
@@ -133,10 +150,10 @@ describe Prefactory do
133
150
  blog.update_attributes! :title => 'the little book of calm'
134
151
  end
135
152
  it do
136
- comment.text.should == 'new text'
153
+ expect(comment.text).to eq('new text')
137
154
  end
138
155
  it do
139
- blog.title.should == 'the little book of calm'
156
+ expect(blog.title).to eq('the little book of calm')
140
157
  end
141
158
  end
142
159
  context "when modifying the object in a before-all" do
@@ -145,23 +162,23 @@ describe Prefactory do
145
162
  blog.update_attributes! :title => 'the little book of calm'
146
163
  end
147
164
  it do
148
- comment.text.should == 'new text'
165
+ expect(comment.text).to eq('new text')
149
166
  end
150
167
  it do
151
- blog.title.should == 'the little book of calm'
168
+ expect(blog.title).to eq('the little book of calm')
152
169
  end
153
170
  end
154
171
  context "when not modifying the object" do
155
172
  it do
156
- comment.text.should == 'old text'
173
+ expect(comment.text).to eq('old text')
157
174
  end
158
175
  it do
159
- blog.title.should == 'the big book of trains'
176
+ expect(blog.title).to eq('the big book of trains')
160
177
  end
161
178
  end
162
179
  end
163
180
  it "preserves the title" do
164
- blog.title.should == 'the big book of trains'
181
+ expect(blog.title).to eq('the big book of trains')
165
182
  end
166
183
  end
167
184
 
@@ -178,13 +195,13 @@ describe Prefactory do
178
195
  end
179
196
  end
180
197
  it "raises an error in a before-each context" do
181
- @before_each_exception.should be_present
198
+ expect(@before_each_exception).to be_present
182
199
  end
183
200
  it "raises an error in an it-context" do
184
201
  expect { prefactory_add(:comment) }.to raise_error
185
202
  end
186
203
  it "works in a before-all context" do
187
- prefactory(:blog).should be_present
204
+ expect(prefactory(:blog)).to be_present
188
205
  end
189
206
  end
190
207
  end
@@ -197,31 +214,31 @@ describe Prefactory do
197
214
  context "when passed a key associated with a prefactory_add'ed object" do
198
215
  let(:key) { :blog }
199
216
  it do
200
- should be_present
201
- should == blog
202
- should be_a Blog
217
+ is_expected.to be_present
218
+ is_expected.to eq(blog)
219
+ is_expected.to be_a Blog
203
220
  end
204
221
  context "that has since been destroyed in a before-each" do
205
222
  before { blog.destroy }
206
223
  it do
207
- should be_present
208
- should be_destroyed
209
- blog.should be_present
210
- Blog.where(:id => blog.id).should_not exist
224
+ is_expected.to be_present
225
+ is_expected.to be_destroyed
226
+ expect(blog).to be_present
227
+ expect(Blog.where(:id => blog.id)).not_to exist
211
228
  end
212
229
  end
213
230
  context "that has since been destroyed in a before-all" do
214
231
  before(:all) { blog.destroy }
215
- it { should be_nil }
232
+ it { is_expected.to be_nil }
216
233
  it "does not raise an error when calling the key name as a method" do
217
- blog.should be_nil
234
+ expect(blog).to be_nil
218
235
  end
219
236
  end
220
237
  end
221
238
  context "when passed a nonexistent key" do
222
239
  let(:key) { :frog }
223
240
  it do
224
- should be_nil
241
+ is_expected.to be_nil
225
242
  expect { frog }.to raise_error(NameError)
226
243
  end
227
244
  end
@@ -231,15 +248,15 @@ describe Prefactory do
231
248
  before(:all) { prefactory_add :comment }
232
249
  before(:all) { prefactory_add :another_blog, :title => blog.id.to_s }
233
250
  it do
234
- blog.should be_present
235
- Blog.where(:id => blog.id).should exist
251
+ expect(blog).to be_present
252
+ expect(Blog.where(:id => blog.id)).to exist
236
253
  end
237
254
  it do
238
- comment.should be_present
239
- Comment.where(:id => comment.id).should exist
255
+ expect(comment).to be_present
256
+ expect(Comment.where(:id => comment.id)).to exist
240
257
  end
241
258
  it do
242
- another_blog.title.should == blog.id.to_s
259
+ expect(another_blog.title).to eq(blog.id.to_s)
243
260
  end
244
261
  end
245
262
  end
@@ -251,17 +268,17 @@ describe Prefactory do
251
268
  FactoryGirl.create :comment, :text => blog.title
252
269
  end
253
270
  it do
254
- blog.should be_present
255
- Blog.where(:id => blog.id).should exist
271
+ expect(blog).to be_present
272
+ expect(Blog.where(:id => blog.id)).to exist
256
273
  end
257
274
  it do
258
- comment.should be_present
259
- comment.counter.should == 12
260
- Comment.where(:id => comment.id).should exist
275
+ expect(comment).to be_present
276
+ expect(comment.counter).to eq(12)
277
+ expect(Comment.where(:id => comment.id)).to exist
261
278
  end
262
279
  it do
263
- some_other_comment.text.should be_present
264
- some_other_comment.text.should == blog.title
280
+ expect(some_other_comment.text).to be_present
281
+ expect(some_other_comment.text).to eq(blog.title)
265
282
  end
266
283
  end
267
284
  end
@@ -81,7 +81,7 @@ RSpec::Matchers.define :trigger_callbacks_for do |types|
81
81
  end
82
82
  }
83
83
 
84
- match_for_should do |model_instance|
84
+ match do |model_instance|
85
85
  check_for_match.call(model_instance, types)
86
86
  result = true
87
87
  result = false unless @called.present?
@@ -89,7 +89,7 @@ RSpec::Matchers.define :trigger_callbacks_for do |types|
89
89
  result
90
90
  end
91
91
 
92
- match_for_should_not do |model_instance|
92
+ match_when_negated do |model_instance|
93
93
  check_for_match.call(model_instance, types)
94
94
  result = true
95
95
  result = false unless @not_called.present?
@@ -97,11 +97,11 @@ RSpec::Matchers.define :trigger_callbacks_for do |types|
97
97
  result
98
98
  end
99
99
 
100
- failure_message_for_should do |actual|
100
+ failure_message do |actual|
101
101
  ["Called:\t#{@called.join("\n\t")}", "Not called:\t#{@called.join("\n\t")}"].join("\n")
102
102
  end
103
103
 
104
- failure_message_for_should_not do |actual|
104
+ failure_message_when_negated do |actual|
105
105
  ["Called:\t#{@called.join("\n\t")}", "Not called:\t#{@called.join("\n\t")}"].join("\n")
106
106
  end
107
107
 
@@ -28,17 +28,17 @@ describe "WithDisposableTransactionExtension#with_disposable_transaction" do
28
28
  previous_open_transaction_count = Blog.connection.open_transactions
29
29
  Blog.with_disposable_transaction do
30
30
  blog.update_attributes! :title => 'bar'
31
- blog.reload.title.should == 'bar'
32
- Blog.connection.open_transactions.should == previous_open_transaction_count + 1
31
+ expect(blog.reload.title).to eq('bar')
32
+ expect(Blog.connection.open_transactions).to eq(previous_open_transaction_count + 1)
33
33
  end
34
- blog.reload.title.should == 'foo'
35
- Blog.connection.open_transactions.should == previous_open_transaction_count
34
+ expect(blog.reload.title).to eq('foo')
35
+ expect(Blog.connection.open_transactions).to eq(previous_open_transaction_count)
36
36
  end
37
37
  it "preserves the return value" do
38
38
  result = Blog.with_disposable_transaction do
39
39
  1
40
40
  end
41
- result.should == 1
41
+ expect(result).to eq(1)
42
42
  end
43
43
  it "raises any StandardError occuring in the block" do
44
44
  expect do
@@ -53,37 +53,37 @@ describe "Transactional wrapping" do
53
53
  shared_examples_for "synthetic after_commit" do
54
54
  it "calls after_commit hooks at this open transaction level, but not above" do
55
55
  blog = Blog.create! :title => 'foo'
56
- blog.called_after_commit.should == 1
57
- blog.reload.title.should == 'foo'
56
+ expect(blog.called_after_commit).to eq(1)
57
+ expect(blog.reload.title).to eq('foo')
58
58
 
59
59
  blog.update_attributes! :title => 'bar'
60
- blog.called_after_commit.should == 2
61
- blog.reload.title.should == 'bar'
60
+ expect(blog.called_after_commit).to eq(2)
61
+ expect(blog.reload.title).to eq('bar')
62
62
 
63
63
  ActiveRecord::Base.connection.transaction(:requires_new => true) do
64
64
  blog.update_attributes! :title => 'quux'
65
- blog.called_after_commit.should == 2
65
+ expect(blog.called_after_commit).to eq(2)
66
66
  end
67
- blog.reload.title.should == 'quux'
67
+ expect(blog.reload.title).to eq('quux')
68
68
 
69
- blog.called_after_commit.should == 3
69
+ expect(blog.called_after_commit).to eq(3)
70
70
  ActiveRecord::Base.connection.transaction(:requires_new => true) do
71
71
  blog.update_attributes! :title => 'ragz'
72
- blog.called_after_commit.should == 3
72
+ expect(blog.called_after_commit).to eq(3)
73
73
  raise ActiveRecord::Rollback
74
74
  end
75
- blog.called_after_commit.should == 3
76
- blog.reload.title.should == 'quux'
75
+ expect(blog.called_after_commit).to eq(3)
76
+ expect(blog.reload.title).to eq('quux')
77
77
  end
78
78
 
79
79
  it "does not call after_commit hooks when an error is raised" do
80
80
  blog = Blog.create! :title => 'foo'
81
- blog.called_after_commit.should == 1
81
+ expect(blog.called_after_commit).to eq(1)
82
82
 
83
83
  # raise the level at which a synthetic commit should take place
84
84
  Blog.with_disposable_transaction do
85
85
  blog.update_attributes! :title => 'ragz'
86
- blog.called_after_commit.should == 2
86
+ expect(blog.called_after_commit).to eq(2)
87
87
  end
88
88
 
89
89
  # raise the level at which a synthetic commit should take place
@@ -91,33 +91,33 @@ describe "Transactional wrapping" do
91
91
  expect do
92
92
  ActiveRecord::Base.connection.transaction(:requires_new => true) do
93
93
  blog.update_attributes! :title => 'ragz'
94
- blog.called_after_commit.should == 2
94
+ expect(blog.called_after_commit).to eq(2)
95
95
  raise "Something blows up"
96
96
  end
97
97
  end.to raise_error("Something blows up")
98
- blog.called_after_commit.should == 2
99
- blog.reload.title.should == 'foo'
98
+ expect(blog.called_after_commit).to eq(2)
99
+ expect(blog.reload.title).to eq('foo')
100
100
  end
101
101
 
102
- blog.called_after_commit.should == 2
103
- blog.reload.title.should == 'foo'
102
+ expect(blog.called_after_commit).to eq(2)
103
+ expect(blog.reload.title).to eq('foo')
104
104
  end
105
105
 
106
106
  end
107
107
 
108
108
  it "wraps describe blocks in a savepoint transaction" do
109
- ActiveRecord::Base.connection.current_transaction.should be_a ActiveRecord::ConnectionAdapters::SavepointTransaction
109
+ expect(ActiveRecord::Base.connection.current_transaction).to be_a ActiveRecord::ConnectionAdapters::SavepointTransaction
110
110
  end
111
111
  it "wrapped the suite before this describe block" do
112
- ActiveRecord::Base.connection.open_transactions.should == 2
112
+ expect(ActiveRecord::Base.connection.open_transactions).to eq(2)
113
113
  end
114
114
  it "considers this level as commitable" do
115
- ActiveRecord::Base.connection.commit_at_open_transaction_level.should == 2
115
+ expect(ActiveRecord::Base.connection.commit_at_open_transaction_level).to eq(2)
116
116
  end
117
117
  it "does not consider a nested transaction to be commitable" do
118
118
  ActiveRecord::Base.connection.transaction(:requires_new => true) do
119
- ActiveRecord::Base.connection.open_transactions.should == 3
120
- ActiveRecord::Base.connection.commit_at_open_transaction_level.should == 2
119
+ expect(ActiveRecord::Base.connection.open_transactions).to eq(3)
120
+ expect(ActiveRecord::Base.connection.commit_at_open_transaction_level).to eq(2)
121
121
  end
122
122
  end
123
123
  it_behaves_like "synthetic after_commit"
@@ -125,16 +125,16 @@ describe "Transactional wrapping" do
125
125
  [:describe, :context].each do |nesting_method|
126
126
  send(nesting_method, "with a nested #{nesting_method}") do
127
127
  it "is wrapped in in a new savepoint transaction" do
128
- ActiveRecord::Base.connection.current_transaction.should be_a ActiveRecord::ConnectionAdapters::SavepointTransaction
129
- ActiveRecord::Base.connection.open_transactions.should == 3
128
+ expect(ActiveRecord::Base.connection.current_transaction).to be_a ActiveRecord::ConnectionAdapters::SavepointTransaction
129
+ expect(ActiveRecord::Base.connection.open_transactions).to eq(3)
130
130
  end
131
131
  it "considers this level as commitable" do
132
- ActiveRecord::Base.connection.commit_at_open_transaction_level.should == 3
132
+ expect(ActiveRecord::Base.connection.commit_at_open_transaction_level).to eq(3)
133
133
  end
134
134
  it "does not consider a nested transaction to be commitable" do
135
135
  ActiveRecord::Base.connection.transaction(:requires_new => true) do
136
- ActiveRecord::Base.connection.open_transactions.should == 4
137
- ActiveRecord::Base.connection.commit_at_open_transaction_level.should == 3
136
+ expect(ActiveRecord::Base.connection.open_transactions).to eq(4)
137
+ expect(ActiveRecord::Base.connection.commit_at_open_transaction_level).to eq(3)
138
138
  end
139
139
  end
140
140
  it_behaves_like "synthetic after_commit"
@@ -142,16 +142,16 @@ describe "Transactional wrapping" do
142
142
  [:describe, :context].each do |nesting_method|
143
143
  send(nesting_method, "with a nested #{nesting_method}") do
144
144
  it "is wrapped in in a new savepoint transaction" do
145
- ActiveRecord::Base.connection.current_transaction.should be_a ActiveRecord::ConnectionAdapters::SavepointTransaction
146
- ActiveRecord::Base.connection.open_transactions.should == 4
145
+ expect(ActiveRecord::Base.connection.current_transaction).to be_a ActiveRecord::ConnectionAdapters::SavepointTransaction
146
+ expect(ActiveRecord::Base.connection.open_transactions).to eq(4)
147
147
  end
148
148
  it "considers this level as commitable" do
149
- ActiveRecord::Base.connection.commit_at_open_transaction_level.should == 4
149
+ expect(ActiveRecord::Base.connection.commit_at_open_transaction_level).to eq(4)
150
150
  end
151
151
  it "does not consider a nested transaction to be commitable" do
152
152
  ActiveRecord::Base.connection.transaction(:requires_new => true) do
153
- ActiveRecord::Base.connection.open_transactions.should == 5
154
- ActiveRecord::Base.connection.commit_at_open_transaction_level.should == 4
153
+ expect(ActiveRecord::Base.connection.open_transactions).to eq(5)
154
+ expect(ActiveRecord::Base.connection.commit_at_open_transaction_level).to eq(4)
155
155
  end
156
156
  end
157
157
  it_behaves_like "synthetic after_commit"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prefactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - developers@socialcast.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-23 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec_around_all