ndr_dev_support 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +25 -9
- data/README.md +34 -1
- data/code_safety.yml +8 -8
- data/lib/ndr_dev_support/integration_testing.rb +0 -1
- data/lib/ndr_dev_support/integration_testing/connection_sharing.rb +19 -0
- data/lib/ndr_dev_support/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5e420b22dd99cb540e221868882df3dd5ed5f72
|
4
|
+
data.tar.gz: 98e632dee9557a15efb6bc0a0b471bf0c19ccd27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58867215bd1bb215c1a11d98b8aad7ea0bef0c647bc9aaefb30c308bf90d5a4e33560c1a74f25c879e784228a6c4da990386cb1cdfc12d54481545ba27da6335
|
7
|
+
data.tar.gz: 3847cab395ecc6bca63662a838d7191f09850c32ce87c95dbbffd470aa452151d9a56d6dab9bb15e618349a8fb90344b47054209d84e5f5d5ccac23a83a86646
|
data/.rubocop.yml
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
AllCops:
|
8
8
|
# All cops should ignore files in the following locations:
|
9
9
|
Exclude:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
- 'bin/*'
|
11
|
+
- 'db/**/*'
|
12
|
+
- 'lib/generators/**/templates/*'
|
13
|
+
- 'vendor/**/*'
|
14
14
|
|
15
15
|
# Run the Rails cops by default (-R/--rails not required):
|
16
16
|
Rails:
|
@@ -22,10 +22,18 @@ Rails:
|
|
22
22
|
Style/BlockComments:
|
23
23
|
Enabled: false
|
24
24
|
|
25
|
+
Style/Documentation:
|
26
|
+
Exclude:
|
27
|
+
- 'test/**/*.rb'
|
28
|
+
|
25
29
|
Style/DotPosition:
|
26
30
|
# Multi-line method chaining should be done with trailing dots.
|
27
31
|
EnforcedStyle: trailing
|
28
32
|
|
33
|
+
Style/FrozenStringLiteralComment:
|
34
|
+
# We're not confident enough to make this recommendation everywhere
|
35
|
+
Enabled: false
|
36
|
+
|
29
37
|
Style/IfUnlessModifier:
|
30
38
|
MaxLineLength: 100
|
31
39
|
|
@@ -35,7 +43,7 @@ Style/ModuleFunction:
|
|
35
43
|
|
36
44
|
Style/NumericLiterals:
|
37
45
|
Exclude:
|
38
|
-
|
46
|
+
- 'test/**/*.rb'
|
39
47
|
|
40
48
|
Style/SingleLineBlockParams:
|
41
49
|
# Prefer readability of contextually-named variables.
|
@@ -48,15 +56,23 @@ Style/WhileUntilModifier:
|
|
48
56
|
# NOTE: we bump some metrics by 50%, in recognition of Rubocop's
|
49
57
|
# desire to split that which we would consider atomic.
|
50
58
|
|
59
|
+
Metrics/AbcSize:
|
60
|
+
Max: 23
|
61
|
+
|
62
|
+
Metrics/BlockLength:
|
63
|
+
# We're already limiting method size, blocks outside of methods
|
64
|
+
# can legitimately be long (RuboCop defaults to max: 25 lines).
|
65
|
+
Enabled: false
|
66
|
+
|
51
67
|
Metrics/ClassLength:
|
52
68
|
Max: 150
|
53
69
|
Exclude:
|
54
|
-
|
70
|
+
- 'test/**/*.rb'
|
55
71
|
|
56
72
|
Metrics/ModuleLength:
|
57
73
|
Max: 150
|
58
74
|
Exclude:
|
59
|
-
|
75
|
+
- 'test/**/*.rb'
|
60
76
|
|
61
77
|
Metrics/CyclomaticComplexity:
|
62
78
|
Max: 9
|
@@ -64,12 +80,12 @@ Metrics/CyclomaticComplexity:
|
|
64
80
|
Metrics/LineLength:
|
65
81
|
Max: 100
|
66
82
|
Exclude:
|
67
|
-
|
83
|
+
- 'test/**/*.rb'
|
68
84
|
|
69
85
|
Metrics/MethodLength:
|
70
86
|
Max: 15
|
71
87
|
Exclude:
|
72
|
-
|
88
|
+
- 'test/**/*.rb'
|
73
89
|
|
74
90
|
Metrics/PerceivedComplexity:
|
75
91
|
Max: 12
|
data/README.md
CHANGED
@@ -84,7 +84,7 @@ require 'ndr_dev_support/tasks'
|
|
84
84
|
|
85
85
|
### Integration test environment
|
86
86
|
|
87
|
-
ndr_dev_support bundles a configured Rails integration testing environment. It uses `capybara` and `poltergeist` to drive a PhantomJS headless browser, and includes
|
87
|
+
ndr_dev_support bundles a configured Rails integration testing environment. It uses `capybara` and `poltergeist` to drive a PhantomJS headless browser, and includes some sensible configuration.
|
88
88
|
|
89
89
|
If an integration test errors or fails, `capybara-screenshot` is used to automatically retrieve a full-height screenshot from PhantomJS, which is then stored in `tmp/`.
|
90
90
|
|
@@ -100,6 +100,39 @@ To use, ensure `phantomjs` is installed, and add the following to your applicati
|
|
100
100
|
require 'ndr_dev_support/integration_testing'
|
101
101
|
```
|
102
102
|
|
103
|
+
When using `capybara` with PhantomJS, the test database must be consistent between the test runner and the application being tested. With transactional tests in operation, this means that both must share a connection. Doing so is error-prone, and can introduce race conditions. However, some projects have had success with the approach, so it is available within `ndr_dev_support` with the following additional require statement:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
# WARNING: can result in race conditions within the test suite
|
107
|
+
require 'ndr_dev_support/integration_testing/connection_sharing'
|
108
|
+
```
|
109
|
+
|
110
|
+
The slower, more reliable, alternative is to use the `database_cleaner` gem. `ndr_dev_support` provides no built-in support for this approach, as configuration can be quite project-specific. However, as a starting point:
|
111
|
+
|
112
|
+
Add to the `Gemfile`:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
group :test do
|
116
|
+
gem 'database_cleaner'
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
Add to `test_helper.rb`:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
require 'database_cleaner'
|
124
|
+
DatabaseCleaner.strategy = :deletion # anecdotally, faster than :truncation for our projects
|
125
|
+
|
126
|
+
class ActionDispatch::IntegrationTest
|
127
|
+
# Don't wrap each test case in a transaction:
|
128
|
+
self.use_transactional_tests = false
|
129
|
+
|
130
|
+
# Instead, insert fixtures afresh between each test:
|
131
|
+
setup { DatabaseCleaner.start }
|
132
|
+
teardown { DatabaseCleaner.clean }
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
103
136
|
## Development
|
104
137
|
|
105
138
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/code_safety.yml
CHANGED
@@ -6,8 +6,8 @@ file safety:
|
|
6
6
|
safe_revision: c59a45986f8b6d087c8c21b1e889f31f7346da17
|
7
7
|
".rubocop.yml":
|
8
8
|
comments:
|
9
|
-
reviewed_by:
|
10
|
-
safe_revision:
|
9
|
+
reviewed_by: josh.pencheon
|
10
|
+
safe_revision: b37c9dc7871fad7c592945188b2e7307f1abedcd
|
11
11
|
".travis.yml":
|
12
12
|
comments:
|
13
13
|
reviewed_by: josh.pencheon
|
@@ -26,8 +26,8 @@ file safety:
|
|
26
26
|
safe_revision: c59a45986f8b6d087c8c21b1e889f31f7346da17
|
27
27
|
README.md:
|
28
28
|
comments:
|
29
|
-
reviewed_by:
|
30
|
-
safe_revision:
|
29
|
+
reviewed_by: josh.pencheon
|
30
|
+
safe_revision: 6cf4a9cab6f8f028d45e05e256b63d9fe9d1b7fc
|
31
31
|
Rakefile:
|
32
32
|
comments:
|
33
33
|
reviewed_by: josh.pencheon
|
@@ -47,7 +47,7 @@ file safety:
|
|
47
47
|
lib/ndr_dev_support/integration_testing.rb:
|
48
48
|
comments:
|
49
49
|
reviewed_by: josh.pencheon
|
50
|
-
safe_revision:
|
50
|
+
safe_revision: 5b238d73cfb0e506ced8b4e474cc2b3392838925
|
51
51
|
lib/ndr_dev_support/integration_testing/capybara.rb:
|
52
52
|
comments:
|
53
53
|
reviewed_by: josh.pencheon
|
@@ -55,7 +55,7 @@ file safety:
|
|
55
55
|
lib/ndr_dev_support/integration_testing/connection_sharing.rb:
|
56
56
|
comments:
|
57
57
|
reviewed_by: josh.pencheon
|
58
|
-
safe_revision:
|
58
|
+
safe_revision: 6cf4a9cab6f8f028d45e05e256b63d9fe9d1b7fc
|
59
59
|
lib/ndr_dev_support/integration_testing/poltergeist.rb:
|
60
60
|
comments:
|
61
61
|
reviewed_by: josh.pencheon
|
@@ -86,8 +86,8 @@ file safety:
|
|
86
86
|
safe_revision: a55c971cb770a8e5dc4be7ed66663dd5d695fcd1
|
87
87
|
lib/ndr_dev_support/version.rb:
|
88
88
|
comments:
|
89
|
-
reviewed_by:
|
90
|
-
safe_revision:
|
89
|
+
reviewed_by: josh.pencheon
|
90
|
+
safe_revision: 48575bd1b969dbae8bf03a645a6fa0b0ecf9bba9
|
91
91
|
lib/tasks/audit_code.rake:
|
92
92
|
comments: Identical to the version reviewed by josh.pencheon when contained within
|
93
93
|
ndr_support
|
@@ -1,5 +1,24 @@
|
|
1
1
|
module NdrDevSupport
|
2
2
|
module IntegrationTesting
|
3
|
+
# ==========================================================================
|
4
|
+
#
|
5
|
+
# !! Caution - please read carefully !!
|
6
|
+
#
|
7
|
+
# This approach to connection sharing is known to be susceptible
|
8
|
+
# to race conditions. Anecdotally, we've managed to avoid this
|
9
|
+
# being a problem with Oracle because of the use of the confuration
|
10
|
+
#
|
11
|
+
# ActiveRecord::Base.connection.raw_connection.non_blocking = false
|
12
|
+
#
|
13
|
+
# which prevents the C extension in the adapter being able to run
|
14
|
+
# non-blocking code (i.e. outside of the control of the global interpretter
|
15
|
+
# lock). On Postgres, we haven't employed an equivalent workaround.
|
16
|
+
#
|
17
|
+
# For a more resilient alternative, please use the 'database_cleaner'
|
18
|
+
# gem (see README for details).
|
19
|
+
#
|
20
|
+
# ==========================================================================
|
21
|
+
#
|
3
22
|
# Capybara starts another rails application in a new thread
|
4
23
|
# to test against. For transactional fixtures to work, we need
|
5
24
|
# to share the database connection between threads.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_dev_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NCRS Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|