datarockets-style 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 803ec04bc148a97a6a025daedf5fb3b59590bfe8
4
- data.tar.gz: 5a55887fbd7d868a061678cd7a26e020e29c82ee
3
+ metadata.gz: b7abb7599f2b6308e1bf7ba21af09f8d6d10658d
4
+ data.tar.gz: 064e54aa27dbe9e00453ad91eac3dcf7b33592c6
5
5
  SHA512:
6
- metadata.gz: 23b0c24787daf815f6620a6f9e378c707036f0a928205241740fcb56867d22f7cfd11242f99a99c9bd0d02868a2eef8586a100de83beabae8de2ff64ba0adb87
7
- data.tar.gz: b925359074352f9bb255a03054affdf2d9b1c03207148267d7df533a09e6498aab6e1c65d9e7ecdd4b4c973472644f735e6729cfd285e6dc05a00b4199ed1a6b
6
+ metadata.gz: b751d28c3f3f239d426f2e80f99be7866e1f63562b674175366ca2290e2c8e2cb9a7051abd00a9f3b7b695979ac801556230f7a49f67483ddeaa4fcd7629cf54
7
+ data.tar.gz: 72db0bda1af9bb3b9ad45c8b57482014a649d453fdc8dc7218293bb9ee9cfa18085488f1c9c8e40b5a8ccc3c809d39ae895d6c91a6159729dc9556e8a6156e43
data/.gitignore CHANGED
@@ -2,6 +2,5 @@
2
2
  /bundler/
3
3
  /.yardoc
4
4
  /_yardoc/
5
- /doc/
6
5
  /pkg/
7
6
  /tmp/
data/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-
4
4
 
5
5
  ## master (unreleased)
6
6
 
7
+ ## 0.5.0 (2019-10-26)
8
+
9
+ ### Changed
10
+
11
+ * Split single rubocop config to smaller (for ruby, rails and rspec). ([@r.dubrovsky][])
12
+ * Update rubocop to `0.75.1`.
13
+ * Update rubocop-rspec to `1.36.0`.
14
+ * Use block style for `RSpec/ExpectChange` cop. ([@r.dubrovsky][])
15
+ * Add `RSpec/MessageSpies` cop to style guide. ([@r.dubrovsky][])
16
+
17
+ ### Fixed
18
+
19
+ * Fix `RSpec/DescribedClass`'s error when `described_class` is used as part of a constant. This is part of rubocop-rspec changes.
20
+
7
21
  ## 0.4.0 (2019-08-13)
8
22
 
9
23
  ### Changed
data/CONTRIBUTING.md CHANGED
@@ -27,7 +27,7 @@ do so.
27
27
  * If your change has a corresponding open GitHub issue, prefix the commit message with `[Fix #github-issue-number]`.
28
28
  * Make sure to add tests for it. This is important so we don't break it
29
29
  in a future version unintentionally.
30
- * If you add new code-style rule or cop, add some words about it in the [Code Style Notes](STYLE_GUIDE.md).
30
+ * If you add new code-style rule or cop, add some words about it in the [Code Style Notes](doc/STYLE_GUIDE.md) or related files.
31
31
  * Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format).
32
32
  * If you deliver new cop, try to suggest and deliver it to the community [rubocop][7] gem.
33
33
  * [Squash related commits together][5].
data/Gemfile.lock CHANGED
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datarockets-style (0.4.0)
5
- rubocop (~> 0.74.0)
6
- rubocop-rspec (~> 1.35)
4
+ datarockets-style (0.5.0)
5
+ rubocop (>= 0.74, < 0.76)
6
+ rubocop-rspec (~> 1.36)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ast (2.4.0)
12
12
  jaro_winkler (1.5.3)
13
- parallel (1.17.0)
14
- parser (2.6.3.0)
13
+ parallel (1.18.0)
14
+ parser (2.6.5.0)
15
15
  ast (~> 2.4.0)
16
16
  rainbow (3.0.0)
17
- rake (10.5.0)
18
- rubocop (0.74.0)
17
+ rake (13.0.0)
18
+ rubocop (0.75.1)
19
19
  jaro_winkler (~> 1.5.1)
20
20
  parallel (~> 1.10)
21
21
  parser (>= 2.6)
22
22
  rainbow (>= 2.2.2, < 4.0)
23
23
  ruby-progressbar (~> 1.7)
24
24
  unicode-display_width (>= 1.4.0, < 1.7)
25
- rubocop-rspec (1.35.0)
26
- rubocop (>= 0.60.0)
25
+ rubocop-rspec (1.36.0)
26
+ rubocop (>= 0.68.1)
27
27
  ruby-progressbar (1.10.1)
28
28
  unicode-display_width (1.6.0)
29
29
 
@@ -31,9 +31,8 @@ PLATFORMS
31
31
  ruby
32
32
 
33
33
  DEPENDENCIES
34
- bundler (~> 1.16)
35
34
  datarockets-style!
36
- rake (~> 10.0)
35
+ rake (~> 13.0)
37
36
 
38
37
  BUNDLED WITH
39
38
  1.16.1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Datarockets shared style configs and notes of code-style convensions. Based on the [Rubocop](https://github.com/rubocop-hq/rubocop) util.
4
4
 
5
- This config enforces many of the guidelines outlined in the datarockets [Ruby Style Guide](STYLE_GUIDE.md).
5
+ This config enforces many of the guidelines outlined in the datarockets [Ruby Style Guide](doc/STYLE_GUIDE.md).
6
6
 
7
7
  ## Installation
8
8
 
@@ -30,10 +30,36 @@ $ bundle install
30
30
 
31
31
  Create a `.rubocop.yml` with the following directives:
32
32
 
33
+
34
+ ### Ruby application
35
+
36
+ This config includes specific rules for Ruby application. It works for Ruby gems and no-Rails applications.
37
+
38
+ ```yaml
39
+ inherit_gem:
40
+ datarockets-style:
41
+ - config/ruby.yml
42
+ ```
43
+
44
+ ### Rails application
45
+
46
+ For Rails applications, you can use a specific Rails instead of Ruby config
47
+
48
+ ```yaml
49
+ inherit_gem:
50
+ datarockets-style:
51
+ - config/rails.yml
52
+ ```
53
+
54
+ ### Rspec config
55
+
56
+ For Rspec tests, you can add a special rubocop config
57
+
33
58
  ```yaml
34
59
  inherit_gem:
35
60
  datarockets-style:
36
- - config/default.yml
61
+ - config/ruby.yml
62
+ - config/rspec.yml
37
63
  ```
38
64
 
39
65
  Now, run:
@@ -1,17 +1,3 @@
1
- AllCops:
2
- Exclude:
3
- - "db/**/*"
4
- - "bin/*"
5
- - "lib/tasks/**/*"
6
- - "config/**/*"
7
- - "node_modules/**/*"
8
- - "vendor/**/*"
9
- - "app/views/**/*"
10
- - "config.ru"
11
- - "Rakefile"
12
-
13
- require: rubocop-rspec
14
-
15
1
  Bundler/DuplicatedGem:
16
2
  Enabled: true
17
3
 
@@ -44,14 +30,6 @@ Layout/SpaceInsideHashLiteralBraces:
44
30
  EnforcedStyle: no_space
45
31
  EnforcedStyleForEmptyBraces: no_space
46
32
 
47
- Lint/AmbiguousBlockAssociation:
48
- Exclude:
49
- - "spec/**/*"
50
-
51
- Metrics/BlockLength:
52
- Exclude:
53
- - "spec/**/*"
54
-
55
33
  Metrics/LineLength:
56
34
  Max: 120
57
35
 
@@ -61,16 +39,6 @@ Naming/MemoizedInstanceVariableName:
61
39
  Naming/RescuedExceptionsVariableName:
62
40
  PreferredName: error
63
41
 
64
- RSpec/ContextWording:
65
- Prefixes:
66
- - when
67
- - with
68
- - without
69
- - for
70
-
71
- RSpec/ImplicitSubject:
72
- Enabled: false
73
-
74
42
  Style/BracesAroundHashParameters:
75
43
  EnforcedStyle: context_dependent
76
44
 
data/config/rails.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "db/**/*"
4
+ - "bin/*"
5
+ - "lib/tasks/**/*"
6
+ - "config/**/*"
7
+ - "node_modules/**/*"
8
+ - "vendor/**/*"
9
+ - "app/views/**/*"
10
+ - "config.ru"
11
+ - "Rakefile"
12
+
13
+ inherit_from: base.yml
data/config/rspec.yml ADDED
@@ -0,0 +1,25 @@
1
+ require: rubocop-rspec
2
+
3
+ Lint/AmbiguousBlockAssociation:
4
+ Exclude:
5
+ - "spec/**/*"
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - "spec/**/*"
10
+
11
+ RSpec/ContextWording:
12
+ Prefixes:
13
+ - when
14
+ - with
15
+ - without
16
+ - for
17
+
18
+ RSpec/ExpectChange:
19
+ EnforcedStyle: block
20
+
21
+ RSpec/ImplicitSubject:
22
+ Enabled: false
23
+
24
+ RSpec/MessageSpies:
25
+ EnforcedStyle: have_received
data/config/ruby.yml ADDED
@@ -0,0 +1,9 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "bin/*"
4
+ - "lib/tasks/**/*"
5
+ - "vendor/**/*"
6
+ - "config.ru"
7
+ - "Rakefile"
8
+
9
+ inherit_from: base.yml
@@ -30,9 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "rubocop", "~> 0.74.0"
34
- spec.add_dependency "rubocop-rspec", "~> 1.35"
33
+ spec.add_dependency "rubocop", ">= 0.74", "< 0.76"
34
+ spec.add_dependency "rubocop-rspec", "~> 1.36"
35
35
 
36
- spec.add_development_dependency "bundler", "~> 1.16"
37
- spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rake", "~> 13.0"
38
37
  end
@@ -2,6 +2,11 @@
2
2
 
3
3
  In datarockets we enforce a community [Ruby Style Guide](https://github.com/rubocop-hq/ruby-style-guide).
4
4
 
5
+ Also, we have some new rules for writing Rails applications and Rspec test. You can find it by next links:
6
+
7
+ - [Rails Style Guide](doc/STYLE_GUIDE_RAILS.md)
8
+ - [Rspec Style Guide](doc/STYLE_GUIDE_RSPEC.md)
9
+
5
10
  This is a small list of differences which we have when compared with community style guide:
6
11
 
7
12
  ## Table of contents
@@ -373,57 +378,3 @@ some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
373
378
  some_method(x, y, a: 1, b: 2)
374
379
  some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})
375
380
  ```
376
-
377
- ## Rspec
378
-
379
- * <a name="rspec-betterrspec"></a>
380
- We're happy to use [better spec rules](http://www.betterspecs.org/) for improving our tests.
381
- <sup>[[link](#rspec-betterrspec)]</sup>
382
-
383
- * <a name="rspec-file-length"></a>
384
- We're not limiting a length of rspec files.
385
- <sup>[[link](#rspec-file-length)]</sup>
386
-
387
- * <a name="rspec-subject"></a>
388
- Each subject should be named and we should not use `subject` in our test cases.
389
- Prefer to use `is_expected` that `expect(subject_name)` for small tests.
390
- <sup>[[link](#rspec-subject)]</sup>
391
-
392
- ```ruby
393
- # bad
394
- subject { service.call }
395
-
396
- it "test" do
397
- expect(subject).to eq value
398
- end
399
-
400
- # ok
401
- subject(:service_call) { service.call }
402
-
403
- it "test" do
404
- expect(service_call).to eq value
405
- end
406
-
407
- # better
408
- subject { service.call }
409
-
410
- it "test" do
411
- is_expected.to eq value
412
- end
413
- ```
414
-
415
- * <a name="rspec-context-wording"></a>
416
- When describing a context, start its description with "when", "for", with" or "without".
417
- <sup>[[link](#rspec-context-wording)]</sup>
418
-
419
- ```ruby
420
- # bad
421
- context "the display name not present" do
422
- # ...
423
- end
424
-
425
- # good
426
- context "when the display name is not present" do
427
- # ...
428
- end
429
- ```
@@ -0,0 +1,9 @@
1
+ # Rails Style Guide
2
+
3
+ This style is based on rules from [Ruby Style Guide](docs/STYLE_GUIDE.md). Also, we enforce rules from [community Rails Style Guide][1].
4
+
5
+ This is a small list of differences which we have when compared with community and our Ruby style guides:
6
+
7
+ ## TODO
8
+
9
+ [1]: https://github.com/rubocop-hq/rails-style-guide
@@ -0,0 +1,81 @@
1
+ # Rspec Style Guide
2
+
3
+ This style guide recommends best practices for writing a clear Rspec tests and enjoy this process.
4
+
5
+ * <a name="rspec-betterrspec"></a>
6
+ We're happy to use [better spec rules](http://www.betterspecs.org/) for improving our tests.
7
+ <sup>[[link](#rspec-betterrspec)]</sup>
8
+
9
+ * <a name="rspec-file-length"></a>
10
+ We're not limiting a length of rspec files.
11
+ <sup>[[link](#rspec-file-length)]</sup>
12
+
13
+ * <a name="rspec-subject"></a>
14
+ Each subject should be named and we should not use `subject` in our test cases.
15
+ Prefer to use `is_expected` that `expect(subject_name)` for small tests.
16
+ <sup>[[link](#rspec-subject)]</sup>
17
+
18
+ ```ruby
19
+ # bad
20
+ subject { service.call }
21
+
22
+ it "test" do
23
+ expect(subject).to eq value
24
+ end
25
+
26
+ # ok
27
+ subject(:service_call) { service.call }
28
+
29
+ it "test" do
30
+ expect(service_call).to eq value
31
+ end
32
+
33
+ # better
34
+ subject { service.call }
35
+
36
+ it "test" do
37
+ is_expected.to eq value
38
+ end
39
+ ```
40
+
41
+ * <a name="rspec-context-wording"></a>
42
+ When describing a context, start its description with "when", "for", with" or "without".
43
+ <sup>[[link](#rspec-context-wording)]</sup>
44
+
45
+ ```ruby
46
+ # bad
47
+ context "the display name not present" do
48
+ # ...
49
+ end
50
+
51
+ # good
52
+ context "when the display name is not present" do
53
+ # ...
54
+ end
55
+ ```
56
+
57
+ * <a name="rspec-expect-change"></a>
58
+ Prefer using blocks for change matcher than method calls.
59
+ <sup>[[link](#rspec-expect-change)]</sup>
60
+
61
+ ```ruby
62
+ # bad
63
+ expect { run }.to change(Foo, :bar)
64
+
65
+ # good
66
+ expect { run }.to change { Foo.bar }
67
+ ```
68
+
69
+ * <a name="rspec-message-spies"></a>
70
+ Check spies messages post-factum (after calling some methods).
71
+ <sup>[[link](#rspec-message-spies)]</sup>
72
+
73
+ ```ruby
74
+ # bad
75
+ expect(foo).to receive(:bar)
76
+ foo.bar
77
+
78
+ # good
79
+ foo.bar
80
+ expect(foo).to have_received(:bar)
81
+ ```
@@ -1,5 +1,5 @@
1
1
  module Datarockets
2
2
  module Style
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,71 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datarockets-style
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Dubrovsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-13 00:00:00.000000000 Z
11
+ date: 2019-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.74'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 0.74.0
22
+ version: '0.76'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.74'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 0.74.0
32
+ version: '0.76'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rubocop-rspec
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '1.35'
39
+ version: '1.36'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '1.35'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.16'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.16'
46
+ version: '1.36'
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: rake
57
49
  requirement: !ruby/object:Gem::Requirement
58
50
  requirements:
59
51
  - - "~>"
60
52
  - !ruby/object:Gem::Version
61
- version: '10.0'
53
+ version: '13.0'
62
54
  type: :development
63
55
  prerelease: false
64
56
  version_requirements: !ruby/object:Gem::Requirement
65
57
  requirements:
66
58
  - - "~>"
67
59
  - !ruby/object:Gem::Version
68
- version: '10.0'
60
+ version: '13.0'
69
61
  description:
70
62
  email:
71
63
  - r.dubrovsky@datarockets.com
@@ -86,11 +78,16 @@ files:
86
78
  - README.md
87
79
  - RELEASING.md
88
80
  - Rakefile
89
- - STYLE_GUIDE.md
90
81
  - bin/console
91
82
  - bin/setup
92
- - config/default.yml
83
+ - config/base.yml
84
+ - config/rails.yml
85
+ - config/rspec.yml
86
+ - config/ruby.yml
93
87
  - datarockets-style.gemspec
88
+ - doc/STYLE_GUIDE.md
89
+ - doc/STYLE_GUIDE_RAILS.md
90
+ - doc/STYLE_GUIDE_RSPEC.md
94
91
  - lib/datarockets/style.rb
95
92
  - lib/datarockets/style/version.rb
96
93
  homepage: https://github.com/datarockets/datarockets-style