transactional_capybara 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +17 -13
- data/Rakefile +10 -7
- data/lib/transactional_capybara/shared_connection.rb +7 -10
- data/lib/transactional_capybara/shared_connection/active_record.rb +15 -0
- data/lib/transactional_capybara/shared_connection/sequel.rb +6 -0
- data/lib/transactional_capybara/version.rb +1 -1
- data/spec/.travis.config.yml +3 -1
- data/spec/ajax_spec.rb +0 -1
- data/spec/config.yml.example +3 -1
- data/spec/spec_helper.rb +3 -6
- data/spec/support/active_record_setup.rb +13 -0
- data/spec/support/db_config.rb +6 -0
- data/spec/support/{model.rb → model/active_record.rb} +0 -0
- data/spec/support/model/sequel.rb +5 -0
- data/spec/support/sequel_setup.rb +11 -0
- data/spec/support/server.rb +3 -2
- data/transactional_capybara.gemspec +1 -0
- metadata +28 -6
- data/spec/support/schema.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c9cf729d42a0122c754de2e83c0a04915e31e4a
|
4
|
+
data.tar.gz: d37be5f09cf6c06743ebbc1bb7e0f03ba67e7af8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4d7ff9a275cb53bee768731c3fe9098620d2b7feb2c6cc12cdb87d3acaf4d6d0a10fc6e8caec1ef5f86b22ece3791c09b304989df8c14fe03e82544c3a760de
|
7
|
+
data.tar.gz: d1cc0c121d663faa17a143229d1e3a7760a36a344ee1eacd59152729eff19e5b507bbbf7c6b4a71f2be56dbfa5238ba4cfd2e80f4da24ee2221ea9b81d64fe18
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
transactional_capybara (0.1.0
|
4
|
+
transactional_capybara (0.1.0)
|
5
5
|
capybara
|
6
6
|
|
7
7
|
GEM
|
@@ -76,6 +76,7 @@ GEM
|
|
76
76
|
multi_json (~> 1.0)
|
77
77
|
rubyzip (~> 1.0)
|
78
78
|
websocket (~> 1.0)
|
79
|
+
sequel (4.42.1)
|
79
80
|
sinatra (1.4.6)
|
80
81
|
rack (~> 1.4)
|
81
82
|
rack-protection (~> 1.4)
|
@@ -105,6 +106,7 @@ DEPENDENCIES
|
|
105
106
|
rake
|
106
107
|
rspec
|
107
108
|
selenium-webdriver
|
109
|
+
sequel
|
108
110
|
sinatra
|
109
111
|
sqlite3
|
110
112
|
transactional_capybara!
|
data/README.md
CHANGED
@@ -11,6 +11,20 @@ Use this instead.
|
|
11
11
|
|
12
12
|
For a detailed explanation of how this works, refer to the [introductory blog post].
|
13
13
|
|
14
|
+
## Support ##
|
15
|
+
|
16
|
+
Right now this gem automatically handles the following things:
|
17
|
+
|
18
|
+
* ActiveRecord
|
19
|
+
* Sequel
|
20
|
+
* jQuery
|
21
|
+
* Angular
|
22
|
+
|
23
|
+
Tested on Capybara 2.4.x, may not work on other major versions.
|
24
|
+
|
25
|
+
Don't see something you want?
|
26
|
+
I'd love a pull request, or even just a friendly inquiry!
|
27
|
+
|
14
28
|
## Setup ##
|
15
29
|
|
16
30
|
Add it to your Gemfile, of course:
|
@@ -138,19 +152,9 @@ after :each do
|
|
138
152
|
end
|
139
153
|
```
|
140
154
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
Right now this gem automatically fixes the following things:
|
145
|
-
|
146
|
-
* ActiveRecord
|
147
|
-
* jQuery
|
148
|
-
* Angular
|
149
|
-
|
150
|
-
Tested on Capybara 2.4.x, may not work on other major versions.
|
151
|
-
|
152
|
-
Don't see something you want?
|
153
|
-
I'd love a pull request, or even just a friendly inquiry!
|
155
|
+
## Sequel ##
|
156
|
+
If you want to have shared database connections with sequel just
|
157
|
+
add the option `single_threaded: true` to your sequel connection in test.
|
154
158
|
|
155
159
|
## Contributing
|
156
160
|
|
data/Rakefile
CHANGED
@@ -9,14 +9,17 @@ namespace :test do
|
|
9
9
|
desc "Run tests against all drivers and all databases listed in the config"
|
10
10
|
task :all do
|
11
11
|
db_config = YAML.load_file(File.join(File.dirname(__FILE__), "spec/config.yml"))
|
12
|
-
db_config["database"].keys.
|
12
|
+
configs = db_config["database"].keys.product(
|
13
|
+
%w[selenium webkit poltergeist],
|
14
|
+
%w[active_record sequel]
|
15
|
+
)
|
16
|
+
configs.each do |db_name, driver, orm|
|
13
17
|
ENV['DB'] = db_name
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
18
|
+
ENV['DRIVER'] = driver
|
19
|
+
ENV['ORM'] = orm
|
20
|
+
puts ENV.to_hash.slice 'DRIVER', 'DB', 'ORM'
|
21
|
+
Rake::Task['test:rspec'].reenable
|
22
|
+
Rake::Task['test:rspec'].invoke
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
@@ -1,15 +1,12 @@
|
|
1
|
-
class ActiveRecord::Base
|
2
|
-
mattr_accessor :shared_connection
|
3
|
-
@@shared_connection = nil
|
4
|
-
|
5
|
-
def self.connection
|
6
|
-
@@shared_connection || retrieve_connection
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
1
|
module TransactionalCapybara
|
11
2
|
module_function
|
12
3
|
def share_connection
|
13
|
-
|
4
|
+
#noop is default
|
14
5
|
end
|
15
6
|
end
|
7
|
+
if defined?(ActiveRecord::Base)
|
8
|
+
require_relative './shared_connection/active_record'
|
9
|
+
end
|
10
|
+
if defined?(Sequel::Model)
|
11
|
+
require_relative './shared_connection/sequel'
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ActiveRecord::Base
|
2
|
+
mattr_accessor :shared_connection
|
3
|
+
@@shared_connection = nil
|
4
|
+
|
5
|
+
def self.connection
|
6
|
+
@@shared_connection || retrieve_connection
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module TransactionalCapybara
|
11
|
+
module_function
|
12
|
+
def share_connection
|
13
|
+
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
14
|
+
end
|
15
|
+
end
|
data/spec/.travis.config.yml
CHANGED
data/spec/ajax_spec.rb
CHANGED
data/spec/config.yml.example
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
|
3
|
-
|
4
|
-
db = db_config["database"][db_type]
|
2
|
+
ENV['DB'] ||= 'sqlite'
|
3
|
+
ENV['ORM'] ||= 'active_record'
|
5
4
|
|
6
|
-
|
7
|
-
ActiveRecord::Base.establish_connection(db)
|
8
|
-
load File.join(File.dirname(__FILE__), "support/schema.rb")
|
5
|
+
require_relative "support/#{ENV['ORM']}_setup.rb"
|
9
6
|
|
10
7
|
require 'capybara/rspec'
|
11
8
|
require 'capybara/poltergeist'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require_relative 'db_config'
|
3
|
+
|
4
|
+
config = db_config('active_record')
|
5
|
+
ActiveRecord::Base.establish_connection(config)
|
6
|
+
|
7
|
+
ActiveRecord::Schema.define do
|
8
|
+
create_table :test_values, :force => true do |t|
|
9
|
+
t.string :content
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require_relative 'model/active_record'
|
File without changes
|
data/spec/support/server.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'sinatra'
|
2
2
|
require 'tilt/erb'
|
3
|
-
require_relative 'model'
|
4
3
|
|
5
4
|
class AjaxServer < Sinatra::Base
|
6
5
|
set :public_folder, File.dirname(__FILE__) + '/vendor'
|
7
6
|
|
8
|
-
|
7
|
+
class << self
|
8
|
+
attr_accessor :should_return_from_ajax
|
9
|
+
end
|
9
10
|
|
10
11
|
get "/boring_page" do
|
11
12
|
erb "Hi", layout: :basic
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "sinatra"
|
26
26
|
spec.add_development_dependency "rspec"
|
27
27
|
spec.add_development_dependency "activerecord"
|
28
|
+
spec.add_development_dependency "sequel"
|
28
29
|
spec.add_development_dependency "mysql2"
|
29
30
|
spec.add_development_dependency "sqlite3"
|
30
31
|
spec.add_development_dependency "pg"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transactional_capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Young
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sequel
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: mysql2
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +212,19 @@ files:
|
|
198
212
|
- lib/transactional_capybara/ajax_helpers.rb
|
199
213
|
- lib/transactional_capybara/rspec.rb
|
200
214
|
- lib/transactional_capybara/shared_connection.rb
|
215
|
+
- lib/transactional_capybara/shared_connection/active_record.rb
|
216
|
+
- lib/transactional_capybara/shared_connection/sequel.rb
|
201
217
|
- lib/transactional_capybara/version.rb
|
202
218
|
- spec/.travis.config.yml
|
203
219
|
- spec/ajax_spec.rb
|
204
220
|
- spec/config.yml.example
|
205
221
|
- spec/spec_helper.rb
|
222
|
+
- spec/support/active_record_setup.rb
|
223
|
+
- spec/support/db_config.rb
|
206
224
|
- spec/support/migration.rb
|
207
|
-
- spec/support/model.rb
|
208
|
-
- spec/support/
|
225
|
+
- spec/support/model/active_record.rb
|
226
|
+
- spec/support/model/sequel.rb
|
227
|
+
- spec/support/sequel_setup.rb
|
209
228
|
- spec/support/server.rb
|
210
229
|
- spec/support/vendor/angular.js
|
211
230
|
- spec/support/vendor/jquery.js
|
@@ -244,9 +263,12 @@ test_files:
|
|
244
263
|
- spec/ajax_spec.rb
|
245
264
|
- spec/config.yml.example
|
246
265
|
- spec/spec_helper.rb
|
266
|
+
- spec/support/active_record_setup.rb
|
267
|
+
- spec/support/db_config.rb
|
247
268
|
- spec/support/migration.rb
|
248
|
-
- spec/support/model.rb
|
249
|
-
- spec/support/
|
269
|
+
- spec/support/model/active_record.rb
|
270
|
+
- spec/support/model/sequel.rb
|
271
|
+
- spec/support/sequel_setup.rb
|
250
272
|
- spec/support/server.rb
|
251
273
|
- spec/support/vendor/angular.js
|
252
274
|
- spec/support/vendor/jquery.js
|