granite-form 0.1.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 +7 -0
- data/.codeclimate.yml +13 -0
- data/.github/workflows/ci.yml +35 -0
- data/.github/workflows/main.yml +29 -0
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/.rubocop.yml +64 -0
- data/.rubocop_todo.yml +48 -0
- data/Appraisals +8 -0
- data/CHANGELOG.md +73 -0
- data/Gemfile +8 -0
- data/Guardfile +77 -0
- data/LICENSE +22 -0
- data/README.md +429 -0
- data/Rakefile +6 -0
- data/gemfiles/rails.4.2.gemfile +15 -0
- data/gemfiles/rails.5.0.gemfile +15 -0
- data/gemfiles/rails.5.1.gemfile +15 -0
- data/gemfiles/rails.5.2.gemfile +15 -0
- data/gemfiles/rails.6.0.gemfile +14 -0
- data/gemfiles/rails.6.1.gemfile +14 -0
- data/gemfiles/rails.7.0.gemfile +14 -0
- data/granite-form.gemspec +31 -0
- data/lib/granite/form/active_record/associations.rb +57 -0
- data/lib/granite/form/active_record/nested_attributes.rb +20 -0
- data/lib/granite/form/base.rb +15 -0
- data/lib/granite/form/config.rb +42 -0
- data/lib/granite/form/errors.rb +111 -0
- data/lib/granite/form/extensions.rb +36 -0
- data/lib/granite/form/model/associations/base.rb +97 -0
- data/lib/granite/form/model/associations/collection/embedded.rb +14 -0
- data/lib/granite/form/model/associations/collection/proxy.rb +35 -0
- data/lib/granite/form/model/associations/embeds_any.rb +19 -0
- data/lib/granite/form/model/associations/embeds_many.rb +152 -0
- data/lib/granite/form/model/associations/embeds_one.rb +112 -0
- data/lib/granite/form/model/associations/nested_attributes.rb +215 -0
- data/lib/granite/form/model/associations/persistence_adapters/active_record/referenced_proxy.rb +33 -0
- data/lib/granite/form/model/associations/persistence_adapters/active_record.rb +68 -0
- data/lib/granite/form/model/associations/persistence_adapters/base.rb +55 -0
- data/lib/granite/form/model/associations/references_any.rb +43 -0
- data/lib/granite/form/model/associations/references_many.rb +113 -0
- data/lib/granite/form/model/associations/references_one.rb +88 -0
- data/lib/granite/form/model/associations/reflections/base.rb +92 -0
- data/lib/granite/form/model/associations/reflections/embeds_any.rb +52 -0
- data/lib/granite/form/model/associations/reflections/embeds_many.rb +17 -0
- data/lib/granite/form/model/associations/reflections/embeds_one.rb +19 -0
- data/lib/granite/form/model/associations/reflections/references_any.rb +65 -0
- data/lib/granite/form/model/associations/reflections/references_many.rb +30 -0
- data/lib/granite/form/model/associations/reflections/references_one.rb +32 -0
- data/lib/granite/form/model/associations/reflections/singular.rb +37 -0
- data/lib/granite/form/model/associations/validations.rb +41 -0
- data/lib/granite/form/model/associations.rb +120 -0
- data/lib/granite/form/model/attributes/attribute.rb +75 -0
- data/lib/granite/form/model/attributes/base.rb +134 -0
- data/lib/granite/form/model/attributes/collection.rb +19 -0
- data/lib/granite/form/model/attributes/dictionary.rb +28 -0
- data/lib/granite/form/model/attributes/localized.rb +44 -0
- data/lib/granite/form/model/attributes/reference_many.rb +21 -0
- data/lib/granite/form/model/attributes/reference_one.rb +52 -0
- data/lib/granite/form/model/attributes/reflections/attribute.rb +61 -0
- data/lib/granite/form/model/attributes/reflections/base.rb +62 -0
- data/lib/granite/form/model/attributes/reflections/collection.rb +12 -0
- data/lib/granite/form/model/attributes/reflections/dictionary.rb +15 -0
- data/lib/granite/form/model/attributes/reflections/localized.rb +45 -0
- data/lib/granite/form/model/attributes/reflections/reference_many.rb +12 -0
- data/lib/granite/form/model/attributes/reflections/reference_one.rb +49 -0
- data/lib/granite/form/model/attributes/reflections/represents.rb +56 -0
- data/lib/granite/form/model/attributes/represents.rb +67 -0
- data/lib/granite/form/model/attributes.rb +204 -0
- data/lib/granite/form/model/callbacks.rb +72 -0
- data/lib/granite/form/model/conventions.rb +40 -0
- data/lib/granite/form/model/dirty.rb +84 -0
- data/lib/granite/form/model/lifecycle.rb +309 -0
- data/lib/granite/form/model/localization.rb +26 -0
- data/lib/granite/form/model/persistence.rb +59 -0
- data/lib/granite/form/model/primary.rb +59 -0
- data/lib/granite/form/model/representation.rb +101 -0
- data/lib/granite/form/model/scopes.rb +118 -0
- data/lib/granite/form/model/validations/associated.rb +22 -0
- data/lib/granite/form/model/validations/nested.rb +56 -0
- data/lib/granite/form/model/validations.rb +29 -0
- data/lib/granite/form/model.rb +33 -0
- data/lib/granite/form/railtie.rb +9 -0
- data/lib/granite/form/undefined_class.rb +11 -0
- data/lib/granite/form/version.rb +5 -0
- data/lib/granite/form.rb +163 -0
- data/spec/lib/granite/form/active_record/associations_spec.rb +211 -0
- data/spec/lib/granite/form/active_record/nested_attributes_spec.rb +15 -0
- data/spec/lib/granite/form/config_spec.rb +66 -0
- data/spec/lib/granite/form/model/associations/embeds_many_spec.rb +706 -0
- data/spec/lib/granite/form/model/associations/embeds_one_spec.rb +533 -0
- data/spec/lib/granite/form/model/associations/nested_attributes_spec.rb +119 -0
- data/spec/lib/granite/form/model/associations/persistence_adapters/active_record_spec.rb +58 -0
- data/spec/lib/granite/form/model/associations/references_many_spec.rb +572 -0
- data/spec/lib/granite/form/model/associations/references_one_spec.rb +445 -0
- data/spec/lib/granite/form/model/associations/reflections/embeds_any_spec.rb +42 -0
- data/spec/lib/granite/form/model/associations/reflections/embeds_many_spec.rb +145 -0
- data/spec/lib/granite/form/model/associations/reflections/embeds_one_spec.rb +117 -0
- data/spec/lib/granite/form/model/associations/reflections/references_many_spec.rb +303 -0
- data/spec/lib/granite/form/model/associations/reflections/references_one_spec.rb +287 -0
- data/spec/lib/granite/form/model/associations/validations_spec.rb +137 -0
- data/spec/lib/granite/form/model/associations_spec.rb +198 -0
- data/spec/lib/granite/form/model/attributes/attribute_spec.rb +186 -0
- data/spec/lib/granite/form/model/attributes/base_spec.rb +97 -0
- data/spec/lib/granite/form/model/attributes/collection_spec.rb +72 -0
- data/spec/lib/granite/form/model/attributes/dictionary_spec.rb +100 -0
- data/spec/lib/granite/form/model/attributes/localized_spec.rb +103 -0
- data/spec/lib/granite/form/model/attributes/reflections/attribute_spec.rb +72 -0
- data/spec/lib/granite/form/model/attributes/reflections/base_spec.rb +56 -0
- data/spec/lib/granite/form/model/attributes/reflections/collection_spec.rb +37 -0
- data/spec/lib/granite/form/model/attributes/reflections/dictionary_spec.rb +43 -0
- data/spec/lib/granite/form/model/attributes/reflections/localized_spec.rb +37 -0
- data/spec/lib/granite/form/model/attributes/reflections/represents_spec.rb +70 -0
- data/spec/lib/granite/form/model/attributes/represents_spec.rb +85 -0
- data/spec/lib/granite/form/model/attributes_spec.rb +350 -0
- data/spec/lib/granite/form/model/callbacks_spec.rb +337 -0
- data/spec/lib/granite/form/model/conventions_spec.rb +11 -0
- data/spec/lib/granite/form/model/dirty_spec.rb +84 -0
- data/spec/lib/granite/form/model/lifecycle_spec.rb +356 -0
- data/spec/lib/granite/form/model/persistence_spec.rb +46 -0
- data/spec/lib/granite/form/model/primary_spec.rb +84 -0
- data/spec/lib/granite/form/model/representation_spec.rb +139 -0
- data/spec/lib/granite/form/model/scopes_spec.rb +86 -0
- data/spec/lib/granite/form/model/typecasting_spec.rb +193 -0
- data/spec/lib/granite/form/model/validations/associated_spec.rb +102 -0
- data/spec/lib/granite/form/model/validations/nested_spec.rb +164 -0
- data/spec/lib/granite/form/model/validations_spec.rb +31 -0
- data/spec/lib/granite/form/model_spec.rb +10 -0
- data/spec/lib/granite/form_spec.rb +11 -0
- data/spec/shared/nested_attribute_examples.rb +332 -0
- data/spec/spec_helper.rb +50 -0
- data/spec/support/model_helpers.rb +10 -0
- data/spec/support/muffle_helper.rb +7 -0
- metadata +403 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: cb26aa530c266a54d01fe3723d4ee44a95bedbefb140a5358403ebcdf78ced5c
|
|
4
|
+
data.tar.gz: 1c63d7e31c87a934a6c858c24c396f0547e16268997dcd2c2e8dbeac16ba98d5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2b28feea4881f8c4f6635f1e626345b4ea534306b8596deb8a61f2a38ce428950eb957bd9b1c936699fbe049a22e1c41d36dce4ebd695c769b3fee39c3ecf716
|
|
7
|
+
data.tar.gz: e0fdbd61872e007edaf0cf4ffed388b382f14e53e2637a04979eae1f4e2f1b67aa0bad71569b9ab4b2ce8cd2363820e380661f402edec70584c480962aa7c0e1
|
data/.codeclimate.yml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
rspec:
|
|
5
|
+
strategy:
|
|
6
|
+
fail-fast: false
|
|
7
|
+
matrix:
|
|
8
|
+
include:
|
|
9
|
+
- { ruby: '2.3', rails: '4.2' }
|
|
10
|
+
- { ruby: '2.4', rails: '5.0' }
|
|
11
|
+
- { ruby: '2.5', rails: '5.1' }
|
|
12
|
+
- { ruby: '2.6', rails: '5.2' }
|
|
13
|
+
- { ruby: '2.7', rails: '6.0' }
|
|
14
|
+
- { ruby: '3.0', rails: '6.1' }
|
|
15
|
+
- { ruby: '3.0', rails: '7.0' }
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
env:
|
|
18
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails.${{ matrix.rails }}.gemfile
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v2
|
|
21
|
+
- uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
|
24
|
+
bundler-cache: true
|
|
25
|
+
- run: bundle exec rspec
|
|
26
|
+
|
|
27
|
+
rubocop:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v2
|
|
31
|
+
- uses: ruby/setup-ruby@v1
|
|
32
|
+
with:
|
|
33
|
+
ruby-version: '3.0'
|
|
34
|
+
bundler-cache: true
|
|
35
|
+
- run: bundle exec rubocop
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
spec:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
name: Run specs in ruby v${{ matrix.ruby }} rails v${{ matrix.rails }}
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
ruby: [ '2.6', '2.7', '3.0' ]
|
|
12
|
+
rails: [ '6.0', '6.1' ]
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v2
|
|
15
|
+
|
|
16
|
+
- name: Set up Ruby
|
|
17
|
+
uses: ruby/setup-ruby@v1
|
|
18
|
+
with:
|
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
env:
|
|
23
|
+
BUNDLE_GEMFILE: gemfiles/rails.${{ matrix.rails }}.gemfile
|
|
24
|
+
run: bundle install
|
|
25
|
+
|
|
26
|
+
- name: Run specs
|
|
27
|
+
env:
|
|
28
|
+
BUNDLE_GEMFILE: gemfiles/rails.${{ matrix.rails }}.gemfile
|
|
29
|
+
run: bundle exec rake spec
|
data/.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
*.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
.rvmrc
|
|
19
|
+
.version-conf
|
|
20
|
+
.ruby-version
|
|
21
|
+
.ruby-gemset
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
AllCops:
|
|
4
|
+
DisplayCopNames: true
|
|
5
|
+
TargetRubyVersion: 2.2.10
|
|
6
|
+
|
|
7
|
+
Lint/AmbiguousBlockAssociation:
|
|
8
|
+
Enabled: false
|
|
9
|
+
|
|
10
|
+
Lint/EndAlignment:
|
|
11
|
+
EnforcedStyleAlignWith: variable
|
|
12
|
+
|
|
13
|
+
Layout/AccessModifierIndentation:
|
|
14
|
+
EnforcedStyle: outdent
|
|
15
|
+
|
|
16
|
+
Layout/AlignHash:
|
|
17
|
+
EnforcedLastArgumentHashStyle: always_ignore
|
|
18
|
+
|
|
19
|
+
Layout/AlignParameters:
|
|
20
|
+
EnforcedStyle: with_fixed_indentation
|
|
21
|
+
|
|
22
|
+
Layout/CaseIndentation:
|
|
23
|
+
EnforcedStyle: end
|
|
24
|
+
|
|
25
|
+
Layout/IndentArray:
|
|
26
|
+
EnforcedStyle: consistent
|
|
27
|
+
|
|
28
|
+
Layout/IndentHash:
|
|
29
|
+
EnforcedStyle: consistent
|
|
30
|
+
|
|
31
|
+
Layout/IndentHeredoc:
|
|
32
|
+
Enabled: false
|
|
33
|
+
|
|
34
|
+
Layout/MultilineMethodCallIndentation:
|
|
35
|
+
EnforcedStyle: indented
|
|
36
|
+
|
|
37
|
+
Layout/MultilineOperationIndentation:
|
|
38
|
+
EnforcedStyle: indented
|
|
39
|
+
|
|
40
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
41
|
+
EnforcedStyle: no_space
|
|
42
|
+
|
|
43
|
+
Metrics/BlockLength:
|
|
44
|
+
Exclude:
|
|
45
|
+
- '**/*_spec.rb'
|
|
46
|
+
- '**/*_examples.rb'
|
|
47
|
+
- '**/*.rake'
|
|
48
|
+
|
|
49
|
+
Metrics/ModuleLength:
|
|
50
|
+
Exclude:
|
|
51
|
+
- '**/*_spec.rb'
|
|
52
|
+
- 'lib/granite/form.rb'
|
|
53
|
+
|
|
54
|
+
Style/Alias:
|
|
55
|
+
EnforcedStyle: prefer_alias_method
|
|
56
|
+
|
|
57
|
+
Style/AndOr:
|
|
58
|
+
EnforcedStyle: conditionals
|
|
59
|
+
|
|
60
|
+
Style/DoubleNegation:
|
|
61
|
+
Enabled: false
|
|
62
|
+
|
|
63
|
+
Style/FrozenStringLiteralComment:
|
|
64
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2016-10-14 10:15:31 +0700 using RuboCop version 0.44.1.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 19
|
|
10
|
+
Metrics/AbcSize:
|
|
11
|
+
Max: 54
|
|
12
|
+
|
|
13
|
+
# Offense count: 2
|
|
14
|
+
# Configuration parameters: CountComments.
|
|
15
|
+
Metrics/ClassLength:
|
|
16
|
+
Max: 128
|
|
17
|
+
|
|
18
|
+
# Offense count: 4
|
|
19
|
+
Metrics/CyclomaticComplexity:
|
|
20
|
+
Max: 13
|
|
21
|
+
|
|
22
|
+
# Offense count: 904
|
|
23
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
|
|
24
|
+
# URISchemes: http, https
|
|
25
|
+
Metrics/LineLength:
|
|
26
|
+
Max: 187
|
|
27
|
+
|
|
28
|
+
# Offense count: 21
|
|
29
|
+
# Configuration parameters: CountComments.
|
|
30
|
+
Metrics/MethodLength:
|
|
31
|
+
Max: 43
|
|
32
|
+
|
|
33
|
+
# Offense count: 2
|
|
34
|
+
# Configuration parameters: CountComments.
|
|
35
|
+
Metrics/ModuleLength:
|
|
36
|
+
Max: 114
|
|
37
|
+
|
|
38
|
+
# Offense count: 2
|
|
39
|
+
Metrics/BlockLength:
|
|
40
|
+
Max: 27
|
|
41
|
+
|
|
42
|
+
# Offense count: 4
|
|
43
|
+
Metrics/PerceivedComplexity:
|
|
44
|
+
Max: 16
|
|
45
|
+
|
|
46
|
+
# Offense count: 75
|
|
47
|
+
Style/Documentation:
|
|
48
|
+
Enabled: false
|
data/Appraisals
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# master
|
|
2
|
+
|
|
3
|
+
# Version 1.2.0
|
|
4
|
+
|
|
5
|
+
* Rails 6.1 and 7 support (#80). Thanks to @ojab and @rewritten
|
|
6
|
+
|
|
7
|
+
# Version 1.1.7
|
|
8
|
+
|
|
9
|
+
* Add typecasting from `ActionController::Parameters` to `Hash` (#73)
|
|
10
|
+
|
|
11
|
+
# Version 1.1.6
|
|
12
|
+
|
|
13
|
+
* Fix Ruby 2.6 deprecations (#72)
|
|
14
|
+
|
|
15
|
+
# Version 1.1.5
|
|
16
|
+
|
|
17
|
+
* Rails 6 support (#70, #71)
|
|
18
|
+
|
|
19
|
+
# Version 1.1.4
|
|
20
|
+
|
|
21
|
+
## Changes
|
|
22
|
+
|
|
23
|
+
* `came_from_default?` attribute method (#66)
|
|
24
|
+
|
|
25
|
+
# Version 1.1.3
|
|
26
|
+
|
|
27
|
+
## Changes
|
|
28
|
+
|
|
29
|
+
* `came_from_user?` attribute method (#65)
|
|
30
|
+
|
|
31
|
+
# Version 1.1.2
|
|
32
|
+
|
|
33
|
+
## Changes
|
|
34
|
+
|
|
35
|
+
* `ActiveData.base_concern` config option in addition to `ActiveData.base_class` (#64)
|
|
36
|
+
|
|
37
|
+
# Version 1.1.1
|
|
38
|
+
|
|
39
|
+
## Changes
|
|
40
|
+
|
|
41
|
+
* `ActiveData.base_class` config option (#63)
|
|
42
|
+
|
|
43
|
+
* ActiveModel 5.2 compatibility (#62)
|
|
44
|
+
|
|
45
|
+
# Version 1.1.0
|
|
46
|
+
|
|
47
|
+
## Incompatible changes
|
|
48
|
+
|
|
49
|
+
* Represented attributes are not provided by default, to add them, `include ActiveData::Model::Representation` (#46)
|
|
50
|
+
|
|
51
|
+
* `include ActiveData::Model::Associations::Validations` is not included by default anymore, to get `validate_ancestry!`, `valid_ancestry?` and `invalid_ancestry?` methods back you need to include this module manually
|
|
52
|
+
|
|
53
|
+
## Changes
|
|
54
|
+
|
|
55
|
+
* Introduce persistence adapters for associations (#24, #51)
|
|
56
|
+
|
|
57
|
+
* `ActionController::Parameters` support (#43)
|
|
58
|
+
|
|
59
|
+
* Nested attributes simple method overriding (#41)
|
|
60
|
+
|
|
61
|
+
* Persistence for `references` associations (#28, #32)
|
|
62
|
+
|
|
63
|
+
* Support `update_only` option on collection nested attributes (#30)
|
|
64
|
+
|
|
65
|
+
* `embedder` accessor for embedded associations
|
|
66
|
+
|
|
67
|
+
* Dynamic scopes for `references` associations (#27)
|
|
68
|
+
|
|
69
|
+
## Bugfixes
|
|
70
|
+
|
|
71
|
+
* Fixed multiple validations on represented attributes and associations (#44)
|
|
72
|
+
|
|
73
|
+
* Proper boolean attributes defaults (#31, #33)
|
data/Gemfile
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
|
5
|
+
# directories %w(app lib config test spec features)
|
|
6
|
+
|
|
7
|
+
## Uncomment to clear the screen before every task
|
|
8
|
+
# clearing :on
|
|
9
|
+
|
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
|
12
|
+
## shell loop, e.g.:
|
|
13
|
+
##
|
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
|
15
|
+
##
|
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
|
17
|
+
## watching the project directory ('.'), then you will want to move
|
|
18
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
|
19
|
+
#
|
|
20
|
+
# $ mkdir config
|
|
21
|
+
# $ mv Guardfile config/
|
|
22
|
+
# $ ln -s config/Guardfile .
|
|
23
|
+
#
|
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
|
25
|
+
|
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
|
28
|
+
# * bundler: 'bundle exec rspec'
|
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
|
31
|
+
# installed the spring binstubs per the docs)
|
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
|
33
|
+
# * 'just' rspec: 'rspec'
|
|
34
|
+
|
|
35
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
|
36
|
+
require 'guard/rspec/dsl'
|
|
37
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
38
|
+
|
|
39
|
+
# Feel free to open issues for suggestions and improvements
|
|
40
|
+
|
|
41
|
+
# RSpec files
|
|
42
|
+
rspec = dsl.rspec
|
|
43
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
44
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
45
|
+
watch(rspec.spec_files)
|
|
46
|
+
|
|
47
|
+
# Ruby files
|
|
48
|
+
ruby = dsl.ruby
|
|
49
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
50
|
+
|
|
51
|
+
# Rails files
|
|
52
|
+
rails = dsl.rails(view_extensions: %w[erb haml slim])
|
|
53
|
+
dsl.watch_spec_files_for(rails.app_files)
|
|
54
|
+
dsl.watch_spec_files_for(rails.views)
|
|
55
|
+
|
|
56
|
+
watch(rails.controllers) do |m|
|
|
57
|
+
[
|
|
58
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
|
59
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
|
60
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
|
61
|
+
]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Rails config changes
|
|
65
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
|
66
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
|
67
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
|
68
|
+
|
|
69
|
+
# Capybara features specs
|
|
70
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
|
71
|
+
|
|
72
|
+
# Turnip features and steps
|
|
73
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
74
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
|
75
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
|
|
76
|
+
end
|
|
77
|
+
end
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 pyromaniac
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|