to_factory 2.0.0 → 3.0.0.pre.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +35 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop-disabled.yml +95 -0
  5. data/.rubocop-enabled.yml +1194 -0
  6. data/.rubocop.yml +938 -0
  7. data/CHANGELOG.md +11 -0
  8. data/Gemfile +6 -1
  9. data/README.md +11 -10
  10. data/Rakefile +17 -9
  11. data/lib/to_factory/collation.rb +9 -9
  12. data/lib/to_factory/file_sync.rb +11 -11
  13. data/lib/to_factory/file_writer.rb +18 -2
  14. data/lib/to_factory/finders/factory.rb +8 -2
  15. data/lib/to_factory/finders/model.rb +11 -13
  16. data/lib/to_factory/generation/attribute.rb +10 -12
  17. data/lib/to_factory/generation/factory.rb +3 -3
  18. data/lib/to_factory/klass_inference.rb +4 -6
  19. data/lib/to_factory/options_parser.rb +4 -4
  20. data/lib/to_factory/parsing/file.rb +87 -14
  21. data/lib/to_factory/representation.rb +9 -6
  22. data/lib/to_factory/version.rb +1 -1
  23. data/lib/to_factory.rb +7 -17
  24. data/spec/db/migrate/1_create_users.rb +4 -4
  25. data/spec/db/migrate/2_create_projects.rb +4 -4
  26. data/spec/db/migrate/3_create_not_namespaced.rb +4 -4
  27. data/spec/db/migrate/4_add_birthday_to_users.rb +3 -3
  28. data/spec/db/migrate/5_add_serialized_attributes_to_users.rb +3 -3
  29. data/spec/example_factories/admin.rb +6 -6
  30. data/spec/example_factories/admin_with_header.rb +7 -7
  31. data/spec/example_factories/inherited_project_with_header.rb +7 -0
  32. data/spec/example_factories/project_with_header.rb +4 -4
  33. data/spec/example_factories/user.rb +5 -5
  34. data/spec/example_factories/user_admin.rb +11 -11
  35. data/spec/example_factories/user_admin_root.rb +12 -12
  36. data/spec/example_factories/user_admin_super_admin.rb +6 -6
  37. data/spec/example_factories/user_admin_with_header.rb +12 -12
  38. data/spec/example_factories/user_with_header.rb +6 -6
  39. data/spec/integration/empty_factory_file_spec.rb +19 -0
  40. data/spec/integration/file_sync_spec.rb +16 -24
  41. data/spec/integration/file_writer_spec.rb +13 -9
  42. data/spec/integration/lint_spec.rb +4 -3
  43. data/spec/integration/multiple_to_factory_calls_spec.rb +96 -0
  44. data/spec/integration/non_active_record_classes_spec.rb +40 -0
  45. data/spec/integration/to_factory_method_spec.rb +21 -20
  46. data/spec/spec_helper.rb +9 -18
  47. data/spec/support/broken_models/invalid_ruby_file.rb +1 -0
  48. data/spec/support/broken_models/project.rb +3 -0
  49. data/spec/support/data_creation.rb +11 -13
  50. data/spec/support/match_sexp.rb +0 -1
  51. data/spec/support/non_active_record/inherited_project.rb +3 -0
  52. data/spec/support/non_active_record/project.rb +3 -0
  53. data/spec/support/non_active_record/some_other_service_inheriting_from_something_else.rb +4 -0
  54. data/spec/support/non_active_record/some_service.rb +2 -0
  55. data/spec/support/non_active_record/something_else.rb +2 -0
  56. data/spec/support/ruby_parser_exception_causing_string.rb +29 -29
  57. data/spec/unit/collation_spec.rb +9 -10
  58. data/spec/unit/file_writer_spec.rb +4 -8
  59. data/spec/unit/finders/factory_spec.rb +7 -9
  60. data/spec/unit/finders/model_spec.rb +35 -8
  61. data/spec/unit/generation/attribute_spec.rb +22 -22
  62. data/spec/unit/generation/factory_spec.rb +38 -14
  63. data/spec/unit/parsing/file_spec.rb +9 -9
  64. data/spec/unit/parsing/klass_inference_spec.rb +5 -7
  65. data/to_factory.gemspec +17 -15
  66. metadata +109 -44
  67. data/.travis.yml +0 -14
  68. data/lib/to_factory/parsing/syntax.rb +0 -83
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6906cfbba894ee5d9a25a7a8c30467c59c0c7c27
4
- data.tar.gz: 5a27e0c0912602908f81bd19335c46b880adbe77
2
+ SHA256:
3
+ metadata.gz: 01f94df88ff753c773d52d22da1ac7d85f16cace50153d5a77eb481fa731531e
4
+ data.tar.gz: 307ce4ac3bbafd0da3afe288b4f1529666d17db175ffc15bd3e73a2cd1dce871
5
5
  SHA512:
6
- metadata.gz: ac378d94509e96ea3417a714e6b4073033552fe675e43b263d020a577c9c2201f119ef23fe13563221a5a67d098bcca34f900f305117485980b3394faaa5c654
7
- data.tar.gz: d19f74bdd1789ebf9d57c0fc267c39e5c9db3221828c9adec12d4dbc6002ea0ef11818e9c2009ee0d4943ebb142f332553a8c4c752d139ce4947e15fcb2c7df7
6
+ metadata.gz: 64e0f3c9317cd0fc8b33e46fe8726bfb5cb2a17d03fbfc1cdbf499f817e57bb4ed8fd40331af7efbd88be4fef0b36bd6fa3fdeca297923f2bb3a288da3028444
7
+ data.tar.gz: 4fdf799e703a7bb5b29798b8406c602cdbf4d781d42a16bab3778f5699d5a6c56b8cc4939c1749c3f718996c3fadf512c42548b145e9b956aa9afcccebd8f546
@@ -0,0 +1,35 @@
1
+ name: RSpec
2
+ on:
3
+ pull_request:
4
+
5
+ jobs:
6
+ rspec:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v1
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ bundler-cache: false
13
+ ruby-version: 2.7.5
14
+ - uses: actions/cache@v2
15
+ with:
16
+ path: .github/vendor/bundle
17
+ key: bundle-use-ruby-for-danger-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
18
+ restore-keys: |
19
+ bundle-use-ruby-for-danger-${{ matrix.os }}-${{ matrix.ruby }}-
20
+ - name: bundle install
21
+ run: |
22
+ cd .github
23
+ bundle install --path=vendor/bundle --jobs 4 --retry 3
24
+ - name: setup db
25
+ run: |
26
+ bundle exec rake spec:migrate_db
27
+ - name: RSpec tests
28
+ run: bundle exec rspec -f j -o tmp/rspec_results.json -f p
29
+
30
+ - name: RSpec Report
31
+ uses: SonicGarden/rspec-report-action@v2
32
+ with:
33
+ token: ${{ secrets.GITHUB_TOKEN }}
34
+ json-path: tmp/rspec_results.json
35
+ if: always()
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ spec/db/test.sqlite3
9
9
  tmp/*
10
10
  !tmp/.keep
11
11
  *.sqlite3
12
+ /spec/dummy/spec/factories
@@ -0,0 +1,95 @@
1
+ # These are all the cops that are disabled in the default configuration.
2
+
3
+ Style/AutoResourceCleanup:
4
+ Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
5
+ Enabled: false
6
+
7
+ Style/CollectionMethods:
8
+ Description: 'Preferred collection methods.'
9
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size'
10
+ Enabled: false
11
+
12
+ Style/Copyright:
13
+ Description: 'Include a copyright notice in each file before any code.'
14
+ Enabled: false
15
+
16
+ Style/Encoding:
17
+ Description: 'Use UTF-8 as the source file encoding.'
18
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8'
19
+ Enabled: false
20
+
21
+ Style/InlineComment:
22
+ Description: 'Avoid inline comments.'
23
+ Enabled: false
24
+
25
+ Style/FirstArrayElementLineBreak:
26
+ Description: >-
27
+ Checks for a line break before the first element in a
28
+ multi-line array.
29
+ Enabled: false
30
+
31
+ Style/FirstHashElementLineBreak:
32
+ Description: >-
33
+ Checks for a line break before the first element in a
34
+ multi-line hash.
35
+ Enabled: false
36
+
37
+ Style/FirstMethodArgumentLineBreak:
38
+ Description: >-
39
+ Checks for a line break before the first argument in a
40
+ multi-line method call.
41
+ Enabled: false
42
+
43
+ Style/FirstMethodParameterLineBreak:
44
+ Description: >-
45
+ Checks for a line break before the first parameter in a
46
+ multi-line method parameter definition.
47
+ Enabled: false
48
+
49
+ Style/MethodCalledOnDoEndBlock:
50
+ Description: 'Avoid chaining a method call on a do...end block.'
51
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
52
+ Enabled: false
53
+
54
+ Style/MissingElse:
55
+ Description: >-
56
+ Require if/case expressions to have an else branches.
57
+ If enabled, it is recommended that
58
+ Style/UnlessElse and Style/EmptyElse be enabled.
59
+ This will conflict with Style/EmptyElse if
60
+ Style/EmptyElse is configured to style "both"
61
+ Enabled: false
62
+ EnforcedStyle: both
63
+ SupportedStyles:
64
+ # if - warn when an if expression is missing an else branch
65
+ # case - warn when a case expression is missing an else branch
66
+ # both - warn when an if or case expression is missing an else branch
67
+ - if
68
+ - case
69
+ - both
70
+
71
+ Style/MutableConstant:
72
+ Description: 'Do not assign mutable objects to constants.'
73
+ Enabled: false
74
+
75
+ Style/OptionHash:
76
+ Description: "Don't use option hashes when you can use keyword arguments."
77
+ Enabled: false
78
+
79
+ Style/Send:
80
+ Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
81
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#prefer-public-send'
82
+ Enabled: false
83
+
84
+ Style/StringMethods:
85
+ Description: 'Checks if configured preferred methods are used over non-preferred.'
86
+ Enabled: false
87
+
88
+ Style/SymbolArray:
89
+ Description: 'Use %i or %I for arrays of symbols.'
90
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-i'
91
+ Enabled: false
92
+
93
+ Lint/LiteralInInterpolation:
94
+ Description: 'Avoid interpolating literals in strings'
95
+ AutoCorrect: false