preek 1.5.0 → 1.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c585c8febf862238a426fd347775911454140bbb
4
- data.tar.gz: e1ec29fbab5d972d84a4abf5731cd815cd1d2e83
3
+ metadata.gz: 3de170e7e48fb838dc8486e5e454193df7ada8a5
4
+ data.tar.gz: f03da30344efc94f3348a0832c8c3cb436c806c3
5
5
  SHA512:
6
- metadata.gz: fa32eff70b87f0f4ebfa3ff282ed72399d15192fb537b403163c75f284f3486f4001a82d5631f40f33c8581068a6a91823bf8723ec101742fe928170007a4ed2
7
- data.tar.gz: 52f8ef1a293c65142a1d834e499a581d91f505f1dc9d81c56c5895f33b5183c93a431ed51ae807b49014b21c2e842164935c1cb8ff523b5499e695b590768883
6
+ metadata.gz: 13658f79c1f9748410bde706afa47a2ae53a09abe776a1cf8129f9a117e6c2e374aabbca76a489ba2d26457fd6ff65d4dd26480ca81f21cc021cf59430cb0377
7
+ data.tar.gz: 452cda3f91a5d0e2c3ee7e2d3c1eb1fbdcaa513c46273c2d9e1845870385f6c89be9ee1643b38ac7cdab229e3292642887f33cde1fc44c9fd672291c93457dc3
data/.rspec CHANGED
@@ -1,2 +1 @@
1
1
  --color
2
- --format documentation
data/README.md CHANGED
@@ -63,6 +63,16 @@ Preek::Smell(filenames, excludes)
63
63
 
64
64
  ```
65
65
 
66
+ ### Git
67
+ To run preek on your code before commit, place this in `.git/hooks/pre-commit`
68
+
69
+ ```bash
70
+ #!/bin/sh
71
+ exec bundle exec preek git
72
+ 0
73
+ ```
74
+
75
+
66
76
  ## Contributing
67
77
 
68
78
  1. Fork it
data/lib/preek/cli.rb CHANGED
@@ -38,11 +38,11 @@ module Preek
38
38
 
39
39
  desc 'git', 'Run Preek on git changes'
40
40
  def git
41
- args = git_status.scan(/[ M?]+(.*\.rb)/).flatten
41
+ args = git_status.scan(/[ M?]{2} (.*\.rb)/).flatten
42
42
  smell *args unless args.empty?
43
43
  end
44
44
 
45
- private
45
+ private
46
46
 
47
47
  def git_status
48
48
  `git status -s`
data/lib/preek/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Preek
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -16,12 +16,12 @@ describe Preek::CLI do
16
16
 
17
17
  context 'with no argument' do
18
18
  Given(:args){ [] }
19
- Then{ output.should include("was called with no arguments")}
19
+ Then{ expect(output).to include("was called with no arguments")}
20
20
  end
21
21
 
22
22
  context 'with "smell" and no argument' do
23
23
  Given(:args){ ['smell'] }
24
- Then{ output.should include("was called with no arguments")}
24
+ Then{ expect(output).to include("was called with no arguments")}
25
25
  end
26
26
  end
27
27
 
@@ -30,29 +30,29 @@ describe Preek::CLI do
30
30
 
31
31
  context 'with "smell" and a file as argument' do
32
32
  Given(:args){ ['smell', test_file('non_smelly')] }
33
- Then{output.should include("No smells")}
33
+ Then{expect(output).to include("No smells")}
34
34
  end
35
35
 
36
36
  context 'with a file as argument' do
37
37
  Given(:args){ [test_file('non_smelly')] }
38
- Then{output.should include("No smells")}
38
+ Then{expect(output).to include("No smells")}
39
39
  end
40
40
 
41
41
  context 'with "help" as argument' do
42
42
  Given(:args){ ['help'] }
43
- Then{output.should =~ /Commands:/}
43
+ Then{expect(output).to match /Commands:/}
44
44
  end
45
45
 
46
46
  context 'with "version"' do
47
47
  Given(:args){ ['version'] }
48
- Then {output.should =~ /(\d\.?){3}/}
48
+ Then {expect(output).to match /(\d\.?){3}/}
49
49
  end
50
50
 
51
51
  context "with non-existing file in ARGS" do
52
52
  Given(:args) { ['i/am/not/a_file'] }
53
- Then{output.should_not include("success")}
54
- Then{output.should include("No such file")}
55
- Then{output.should include(args[0])}
53
+ Then{expect(output).to_not include("success")}
54
+ Then{expect(output).to include("No such file")}
55
+ Then{expect(output).to include(args[0])}
56
56
  end
57
57
  end
58
58
  end
@@ -64,58 +64,58 @@ describe Preek::CLI do
64
64
 
65
65
  context "when given file has no smells" do
66
66
  Given(:args){ [test_file('non_smelly')] }
67
- Then{output.should include("No smells")}
68
- Then{output.should_not include(args[0])}
67
+ Then{expect(output).to include("No smells")}
68
+ Then{expect(output).to_not include(args[0])}
69
69
  end
70
70
 
71
71
  context "when given file has no smells and the other does not exist" do
72
72
  Given(:args){ [test_file('non_smelly'), 'i/am/not/a_file'] }
73
- Then{output.should include("No smells")}
74
- Then{output.should_not include(args[0])}
75
- Then{output.should include("No such file")}
76
- Then{output.should include(args[1])}
73
+ Then{expect(output).to include("No smells")}
74
+ Then{expect(output).to_not include(args[0])}
75
+ Then{expect(output).to include("No such file")}
76
+ Then{expect(output).to include(args[1])}
77
77
  end
78
78
 
79
79
  context "when given file has Irresponsible smell" do
80
80
  Given(:args){ [test_file('irresponsible')] }
81
- Then{output.should include("No smells")}
82
- Then{output.should_not include(args[0])}
81
+ Then{expect(output).to include("No smells")}
82
+ Then{expect(output).to_not include(args[0])}
83
83
  end
84
84
 
85
85
  context "when given a file with two smelly classes" do
86
86
  Given(:args){ [test_file('two_smelly_classes')] }
87
- Then{output.should include('SecondSmelly')}
88
- Then{output.should include('UncommunicativeMethodName')}
87
+ Then{expect(output).to include('SecondSmelly')}
88
+ Then{expect(output).to include('UncommunicativeMethodName')}
89
89
 
90
90
  describe 'total count' do
91
- Then{output.should match(/total.*1/)}
91
+ Then{expect(output).to match(/total.*1/)}
92
92
  end
93
93
  end
94
94
 
95
95
  context "when given two smelly files" do
96
96
  Given(:args){ [test_file('too_many_statements'), test_file('two_smelly_classes')] }
97
- Then{output.should include('UncommunicativeMethodName', 'TooManyStatements')}
98
- Then{output.should include(args[0], args[1])}
99
- Then{output.should include("#loong_method", "#x")}
97
+ Then{expect(output).to include('UncommunicativeMethodName', 'TooManyStatements')}
98
+ Then{expect(output).to include(args[0], args[1])}
99
+ Then{expect(output).to include("#loong_method", "#x")}
100
100
 
101
101
  describe 'total count' do
102
- Then{output.should match(/total.*2/)}
102
+ Then{expect(output).to match(/total.*2/)}
103
103
  end
104
104
  end
105
105
 
106
106
  context "when given one file without smells and another with smells" do
107
107
  Given(:args){ [test_file('non_smelly'), test_file('too_many_statements')] }
108
108
 
109
- Then{output.should include('TooManyStatements')}
110
- Then{output.should include(args[1])}
111
- Then{output.should include("#loong_method")}
112
- Then{output.should_not include(args[0])}
109
+ Then{expect(output).to include('TooManyStatements')}
110
+ Then{expect(output).to include(args[1])}
111
+ Then{expect(output).to include("#loong_method")}
112
+ Then{expect(output).to_not include(args[0])}
113
113
  end
114
114
 
115
115
  context "when given file has NilCheck smell" do
116
116
  Given(:args){ [test_file('nil_check')] }
117
- Then{output.should include("NilCheck")}
118
- Then{output.should include(args[0])}
117
+ Then{expect(output).to include("NilCheck")}
118
+ Then{expect(output).to include(args[0])}
119
119
  end
120
120
  end
121
121
 
@@ -124,25 +124,25 @@ describe Preek::CLI do
124
124
 
125
125
  context "when given file has Irresponsible smell" do
126
126
  Given(:args){ [test_file('irresponsible')] }
127
- Then{output.should include("Irresponsible")}
127
+ Then{expect(output).to include("Irresponsible")}
128
128
  end
129
129
 
130
130
  context "when given a file with two smelly classes" do
131
131
  Given(:args){ [test_file('two_smelly_classes')] }
132
- Then{output.should include('FirstSmelly', 'SecondSmelly')}
133
- Then{output.should include('IrresponsibleModule', 'UncommunicativeMethodName')}
132
+ Then{expect(output).to include('FirstSmelly', 'SecondSmelly')}
133
+ Then{expect(output).to include('IrresponsibleModule', 'UncommunicativeMethodName')}
134
134
  end
135
135
 
136
136
  context "when given two smelly files" do
137
137
  Given(:args){ [test_file('too_many_statements'), test_file('two_smelly_classes')] }
138
- Then{output.should include('IrresponsibleModule', 'UncommunicativeMethodName', 'TooManyStatements')}
139
- Then{output.should include(args[0], args[1])}
140
- Then{output.should include("#loong_method", "#x")}
138
+ Then{expect(output).to include('IrresponsibleModule', 'UncommunicativeMethodName', 'TooManyStatements')}
139
+ Then{expect(output).to include(args[0], args[1])}
140
+ Then{expect(output).to include("#loong_method", "#x")}
141
141
  end
142
142
 
143
143
  context "when given a file with two different smells" do
144
144
  Given(:args){ [test_file('irresponsible_and_lazy')] }
145
- Then{output.should include('IrresponsibleModule', 'UncommunicativeMethodName')}
145
+ Then{expect(output).to include('IrresponsibleModule', 'UncommunicativeMethodName')}
146
146
  end
147
147
  end
148
148
 
@@ -151,18 +151,18 @@ describe Preek::CLI do
151
151
 
152
152
  context "when given file has no smells" do
153
153
  Given(:args){ [test_file('non_smelly')] }
154
- Then{output.should include("No smells")}
155
- Then{output.should include(args[0])}
154
+ Then{expect(output).to include("No smells")}
155
+ Then{expect(output).to include(args[0])}
156
156
  end
157
157
 
158
158
  context "when given two smelly files" do
159
159
  Given(:args){ [test_file('too_many_statements'), test_file('two_smelly_classes')] }
160
- Then{output.should include(args[0], args[1])}
160
+ Then{expect(output).to include(args[0], args[1])}
161
161
  end
162
162
 
163
163
  context "when given one file without smells and another with smells" do
164
164
  Given(:args){ [test_file('non_smelly'), test_file('too_many_statements')] }
165
- Then{output.should include(args[1], args[0])}
165
+ Then{expect(output).to include(args[1], args[0])}
166
166
  end
167
167
  end
168
168
  end
@@ -178,9 +178,15 @@ describe Preek::CLI do
178
178
  Then{}
179
179
  end
180
180
 
181
+ context 'with deleted file' do
182
+ Given(:git_output){" M .travis.yml\n M Gemfile\n M lib/random/file.rb\n D ruby.rb\n"}
183
+ Given{cli.should_receive(:smell).with('lib/random/file.rb')}
184
+ Then{}
185
+ end
186
+
181
187
  context 'without ruby file' do
182
188
  Given(:git_output){" M .travis.yml\n M Gemfile\n M preek.gemspec\n"}
183
- Given{cli.should_not receive(:smell)}
189
+ Given{cli.should_not_receive(:smell)}
184
190
  Then{}
185
191
  end
186
192
  end
data/spec/spec_helper.rb CHANGED
@@ -7,9 +7,12 @@ require File.expand_path('../../lib/preek', __FILE__)
7
7
  require 'rspec/given'
8
8
 
9
9
  RSpec.configure do |config|
10
- config.treat_symbols_as_metadata_keys_with_true_values = true
11
10
  config.run_all_when_everything_filtered = true
12
11
  config.filter_run :focus
13
12
  config.order = 'random'
14
13
  config.fail_fast = true
14
+
15
+ config.mock_with :rspec do |mocks|
16
+ mocks.syntax = :should
17
+ end
15
18
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: preek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Neverland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: reek
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.14.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.14.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-given
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.3.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: guard-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 4.2.5
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 4.2.5
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: coveralls
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: 'Preek prints Ruby code smells in color, using Reek. '
@@ -116,9 +116,9 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - .gitignore
120
- - .rspec
121
- - .travis.yml
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
122
  - Gemfile
123
123
  - Guardfile
124
124
  - LICENSE
@@ -155,17 +155,17 @@ require_paths:
155
155
  - lib
156
156
  required_ruby_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - '>='
158
+ - - ">="
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - '>='
163
+ - - ">="
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.2.1
168
+ rubygems_version: 2.2.2
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Code smells in color