derail_specs 0.2.1 → 0.3.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 +6 -2
- data/.rubocop_todo.yml +4 -20
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +1 -1
- data/README.md +23 -0
- data/example/Gemfile +1 -0
- data/example/Gemfile.lock +7 -1
- data/example/app/models/test.rb +2 -0
- data/example/db/migrate/20210916070010_create_tests.rb +9 -0
- data/example/db/schema.rb +21 -0
- data/example/factories.rb +5 -0
- data/example/tests.sh +5 -1
- data/lib/derail_specs/factory_bot.rb +14 -0
- data/lib/derail_specs/factory_bot_stub.rb +8 -0
- data/lib/derail_specs/server/app.rb +8 -0
- data/lib/derail_specs/version.rb +1 -1
- data/lib/derail_specs.rb +1 -0
- data/lib/tasks/derail_specs.rake +1 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3cb7b4de2c0df3488fd8d13cea48a9a432eb4a93c9154348373d19ffb2f5faf
|
4
|
+
data.tar.gz: 6640217cd89418908ad6cf8bf23d4acaf85aa75baf8f2495bdf661ff157d7161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3587e23efa379f03cdab789814e0ed81c026688d1013dc7e216625e69a320445631b3f5d6dec3a51ad58ac2f5a0d4fdc07e121ba93326ed2d4a9e32958752958
|
7
|
+
data.tar.gz: cfd6c514732a6b153115038a04aa979232d0d0306cbfb93d1915410b13b405d77a31382ec7b27f9989529c81cebec9edb1497f18d299cee26c43d8c166678601
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2021-09-
|
3
|
+
# on 2021-09-16 08:00:52 UTC using RuboCop version 1.21.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -18,30 +18,14 @@ Gemspec/RequiredRubyVersion:
|
|
18
18
|
Metrics/AbcSize:
|
19
19
|
Max: 34
|
20
20
|
|
21
|
-
# Offense count:
|
22
|
-
# Configuration parameters: IgnoredMethods.
|
23
|
-
Metrics/CyclomaticComplexity:
|
24
|
-
Max: 9
|
25
|
-
|
26
|
-
# Offense count: 6
|
21
|
+
# Offense count: 4
|
27
22
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
28
23
|
Metrics/MethodLength:
|
29
24
|
Max: 20
|
30
25
|
|
31
|
-
# Offense count:
|
32
|
-
# Configuration parameters: IgnoredMethods.
|
33
|
-
Metrics/PerceivedComplexity:
|
34
|
-
Max: 9
|
35
|
-
|
36
|
-
# Offense count: 1
|
37
|
-
# Cop supports --auto-correct.
|
38
|
-
Style/IfUnlessModifier:
|
39
|
-
Exclude:
|
40
|
-
- 'example/bin/bundle'
|
41
|
-
|
42
|
-
# Offense count: 4
|
26
|
+
# Offense count: 3
|
43
27
|
# Cop supports --auto-correct.
|
44
28
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
45
29
|
# URISchemes: http, https
|
46
30
|
Layout/LineLength:
|
47
|
-
Max:
|
31
|
+
Max: 127
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
|
4
|
+
## [0.3.0] - 2021-09-16
|
5
|
+
|
6
|
+
- Add `/factory-bot/create` route to map to FactoryBot.create
|
7
|
+
- Run `rake derail_specs:run` in Rails test environment
|
8
|
+
|
3
9
|
## [0.2.1] - 2021-09-15
|
4
10
|
|
5
|
-
- Fix Rails 5.2 missing method ActiveRecord::TestFixtures.setup_shared_connection_pool
|
11
|
+
- Fix Rails 5.2 missing method `ActiveRecord::TestFixtures.setup_shared_connection_pool`
|
6
12
|
|
7
13
|
## [0.2.0] - 2021-09-15
|
8
14
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,29 @@ beforeEach(async () => {
|
|
63
63
|
});
|
64
64
|
```
|
65
65
|
|
66
|
+
### FactoryBot.create
|
67
|
+
|
68
|
+
Post with a JSON array to `/factory-bot/create` with the following structure:
|
69
|
+
|
70
|
+
```JSON
|
71
|
+
["test", { "name": "Test Name", "created_at": "2011-11-11 11:11:11" }]
|
72
|
+
````
|
73
|
+
|
74
|
+
which will run:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
FactoryBot.create(:test, name: "Test Name", created_at: "2011-11-11 11:11:11")
|
78
|
+
```
|
79
|
+
|
80
|
+
Example curl:
|
81
|
+
|
82
|
+
```bash
|
83
|
+
curl -X POST \
|
84
|
+
-d '["test", { "name": "Test Name from Curl", "created_at": "2011-11-11 11:11:11" }]' \
|
85
|
+
-H 'Content-Type: application/json' \
|
86
|
+
127.0.0.1:3001/factory-bot/create
|
87
|
+
```
|
88
|
+
|
66
89
|
## Development
|
67
90
|
|
68
91
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/example/Gemfile
CHANGED
data/example/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
derail_specs (0.
|
4
|
+
derail_specs (0.3.0)
|
5
5
|
puma (>= 3.8.0)
|
6
6
|
railties (>= 5.2.0)
|
7
7
|
|
@@ -72,6 +72,11 @@ GEM
|
|
72
72
|
concurrent-ruby (1.1.9)
|
73
73
|
crass (1.0.6)
|
74
74
|
erubi (1.10.0)
|
75
|
+
factory_bot (6.2.0)
|
76
|
+
activesupport (>= 5.0.0)
|
77
|
+
factory_bot_rails (6.2.0)
|
78
|
+
factory_bot (~> 6.2.0)
|
79
|
+
railties (>= 5.0.0)
|
75
80
|
globalid (0.5.2)
|
76
81
|
activesupport (>= 5.0)
|
77
82
|
i18n (1.8.10)
|
@@ -147,6 +152,7 @@ PLATFORMS
|
|
147
152
|
|
148
153
|
DEPENDENCIES
|
149
154
|
derail_specs!
|
155
|
+
factory_bot_rails
|
150
156
|
pry-rails
|
151
157
|
puma (~> 5.0)
|
152
158
|
rails (~> 6.1.4, >= 6.1.4.1)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2021_09_16_070010) do
|
14
|
+
|
15
|
+
create_table "tests", force: :cascade do |t|
|
16
|
+
t.string "name"
|
17
|
+
t.datetime "created_at", precision: 6, null: false
|
18
|
+
t.datetime "updated_at", precision: 6, null: false
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/example/tests.sh
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
-
curl 127.0.0.1:3001
|
3
|
+
curl -s 127.0.0.1:3001 > /dev/null
|
4
4
|
curl 127.0.0.1:3001/reset-transaction
|
5
|
+
curl -X POST \
|
6
|
+
-d '["test", { "name": "Test Name from Curl", "created_at": "2011-11-11 11:11:11" }]' \
|
7
|
+
-H 'Content-Type: application/json' \
|
8
|
+
127.0.0.1:3001/factory-bot/create
|
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
gem 'factory_bot_rails'
|
3
|
+
require 'factory_bot_rails'
|
4
|
+
|
5
|
+
module DerailSpecs
|
6
|
+
class FactoryBot
|
7
|
+
def self.create(factory, options = nil)
|
8
|
+
::FactoryBot.create(factory, options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
rescue Gem::LoadError
|
13
|
+
require_relative 'factory_bot_stub'
|
14
|
+
end
|
@@ -7,6 +7,14 @@ module DerailSpecs
|
|
7
7
|
[202, { "Content-Type" => "text/plain" }, ["Accepted"]]
|
8
8
|
}
|
9
9
|
end
|
10
|
+
map "/factory-bot/create" do
|
11
|
+
run lambda { |env|
|
12
|
+
body = Rack::Request.new(env).body.gets
|
13
|
+
object = FactoryBot.create(*JSON.parse(body))
|
14
|
+
|
15
|
+
[202, { "Content-Type" => "application/json" }, [object.to_json]]
|
16
|
+
}
|
17
|
+
end
|
10
18
|
map "/" do
|
11
19
|
run Rails.application
|
12
20
|
end
|
data/lib/derail_specs/version.rb
CHANGED
data/lib/derail_specs.rb
CHANGED
data/lib/tasks/derail_specs.rake
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: derail_specs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Piechowski
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- example/Rakefile
|
68
68
|
- example/app/controllers/application_controller.rb
|
69
69
|
- example/app/models/application_record.rb
|
70
|
+
- example/app/models/test.rb
|
70
71
|
- example/app/views/layouts/application.html.erb
|
71
72
|
- example/bin/bundle
|
72
73
|
- example/bin/rails
|
@@ -94,6 +95,9 @@ files:
|
|
94
95
|
- example/config/locales/en.yml
|
95
96
|
- example/config/puma.rb
|
96
97
|
- example/config/routes.rb
|
98
|
+
- example/db/migrate/20210916070010_create_tests.rb
|
99
|
+
- example/db/schema.rb
|
100
|
+
- example/factories.rb
|
97
101
|
- example/public/404.html
|
98
102
|
- example/public/422.html
|
99
103
|
- example/public/500.html
|
@@ -104,6 +108,8 @@ files:
|
|
104
108
|
- example/tests.sh
|
105
109
|
- lib/derail_specs.rb
|
106
110
|
- lib/derail_specs/boot.rb
|
111
|
+
- lib/derail_specs/factory_bot.rb
|
112
|
+
- lib/derail_specs/factory_bot_stub.rb
|
107
113
|
- lib/derail_specs/railtie.rb
|
108
114
|
- lib/derail_specs/server.rb
|
109
115
|
- lib/derail_specs/server/app.rb
|