rubocop-rspec 1.6.0 → 1.7.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/CHANGELOG.md +22 -0
- data/README.md +23 -0
- data/Rakefile +19 -1
- data/config/default.yml +78 -15
- data/lib/rubocop-rspec.rb +19 -1
- data/lib/rubocop/cop/rspec/any_instance.rb +5 -1
- data/lib/rubocop/cop/rspec/be_eql.rb +58 -0
- data/lib/rubocop/cop/rspec/describe_class.rb +2 -3
- data/lib/rubocop/cop/rspec/describe_method.rb +4 -3
- data/lib/rubocop/cop/rspec/described_class.rb +4 -35
- data/lib/rubocop/cop/rspec/empty_example_group.rb +100 -0
- data/lib/rubocop/cop/rspec/example_length.rb +5 -2
- data/lib/rubocop/cop/rspec/example_wording.rb +5 -2
- data/lib/rubocop/cop/rspec/expect_actual.rb +79 -0
- data/lib/rubocop/cop/rspec/file_path.rb +3 -1
- data/lib/rubocop/cop/rspec/focus.rb +12 -28
- data/lib/rubocop/cop/rspec/hook_argument.rb +122 -0
- data/lib/rubocop/cop/rspec/instance_variable.rb +53 -12
- data/lib/rubocop/cop/rspec/leading_subject.rb +58 -0
- data/lib/rubocop/cop/rspec/let_setup.rb +58 -0
- data/lib/rubocop/cop/rspec/message_chain.rb +33 -0
- data/lib/rubocop/cop/rspec/message_expectation.rb +58 -0
- data/lib/rubocop/cop/rspec/multiple_describes.rb +10 -7
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +89 -0
- data/lib/rubocop/cop/rspec/named_subject.rb +10 -1
- data/lib/rubocop/cop/rspec/nested_groups.rb +125 -0
- data/lib/rubocop/cop/rspec/not_to_not.rb +3 -3
- data/lib/rubocop/cop/rspec/subject_stub.rb +136 -0
- data/lib/rubocop/cop/rspec/verified_doubles.rb +4 -1
- data/lib/rubocop/rspec.rb +10 -0
- data/lib/rubocop/rspec/config_formatter.rb +33 -0
- data/lib/rubocop/rspec/description_extractor.rb +35 -0
- data/lib/rubocop/rspec/inject.rb +2 -6
- data/lib/rubocop/rspec/language.rb +73 -0
- data/lib/rubocop/rspec/language/node_pattern.rb +16 -0
- data/lib/rubocop/rspec/spec_only.rb +61 -0
- data/lib/rubocop/rspec/top_level_describe.rb +6 -0
- data/lib/rubocop/rspec/version.rb +1 -1
- data/rubocop-rspec.gemspec +1 -0
- data/spec/project/changelog_spec.rb +81 -0
- data/spec/project/default_config_spec.rb +52 -0
- data/spec/project/project_requires_spec.rb +8 -0
- data/spec/rubocop/cop/rspec/be_eql_spec.rb +59 -0
- data/spec/rubocop/cop/rspec/described_class_spec.rb +2 -2
- data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +79 -0
- data/spec/rubocop/cop/rspec/example_length_spec.rb +50 -30
- data/spec/rubocop/cop/rspec/example_wording_spec.rb +21 -3
- data/spec/rubocop/cop/rspec/expect_actual_spec.rb +136 -0
- data/spec/rubocop/cop/rspec/file_path_spec.rb +48 -71
- data/spec/rubocop/cop/rspec/focus_spec.rb +1 -1
- data/spec/rubocop/cop/rspec/hook_argument_spec.rb +189 -0
- data/spec/rubocop/cop/rspec/instance_variable_spec.rb +37 -0
- data/spec/rubocop/cop/rspec/leading_subject_spec.rb +54 -0
- data/spec/rubocop/cop/rspec/let_setup_spec.rb +66 -0
- data/spec/rubocop/cop/rspec/message_chain_spec.rb +21 -0
- data/spec/rubocop/cop/rspec/message_expectation_spec.rb +63 -0
- data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +84 -0
- data/spec/rubocop/cop/rspec/nested_groups_spec.rb +55 -0
- data/spec/rubocop/cop/rspec/not_to_not_spec.rb +12 -2
- data/spec/rubocop/cop/rspec/subject_stub_spec.rb +183 -0
- data/spec/rubocop/rspec/config_formatter_spec.rb +48 -0
- data/spec/rubocop/rspec/description_extractor_spec.rb +35 -0
- data/spec/rubocop/rspec/language/selector_set_spec.rb +29 -0
- data/spec/rubocop/rspec/spec_only_spec.rb +97 -0
- data/spec/shared/rspec_only_cop_behavior.rb +68 -0
- data/spec/spec_helper.rb +13 -1
- metadata +72 -5
- data/spec/project_spec.rb +0 -115
data/spec/project_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
describe 'RuboCop Project' do # rubocop:disable RSpec/DescribeClass
|
2
|
-
describe 'default configuration file' do
|
3
|
-
let(:cop_names) do
|
4
|
-
Dir.glob(File.join(File.dirname(__FILE__), '..', 'lib', 'rubocop', 'cop',
|
5
|
-
'rspec', '*.rb'))
|
6
|
-
.map do |file|
|
7
|
-
cop_name = File.basename(file, '.rb')
|
8
|
-
.gsub(/(^|_)(.)/) { Regexp.last_match(2).upcase }
|
9
|
-
|
10
|
-
"RSpec/#{cop_name}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject(:default_config) do
|
15
|
-
RuboCop::ConfigLoader.load_file('config/default.yml')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'has configuration for all cops' do
|
19
|
-
expect(default_config.keys.sort).to eq(cop_names.sort)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'has a nicely formatted description for all cops' do
|
23
|
-
cop_names.each do |name|
|
24
|
-
description = default_config[name]['Description']
|
25
|
-
expect(description).not_to be_nil
|
26
|
-
expect(description).not_to include("\n")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'changelog' do
|
32
|
-
subject(:changelog) do
|
33
|
-
path = File.join(File.dirname(__FILE__), '..', 'CHANGELOG.md')
|
34
|
-
File.read(path)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'has link definitions for all implicit links' do
|
38
|
-
implicit_link_names = changelog.scan(/\[([^\]]+)\]\[\]/).flatten.uniq
|
39
|
-
implicit_link_names.each do |name|
|
40
|
-
expect(changelog).to include("[#{name}]: http")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe 'entry' do
|
45
|
-
subject(:entries) { lines.grep(/^\*/).map(&:chomp) }
|
46
|
-
let(:lines) { changelog.each_line }
|
47
|
-
|
48
|
-
it 'has a whitespace between the * and the body' do
|
49
|
-
entries.each do |entry|
|
50
|
-
expect(entry).to match(/^\* \S/)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'has a link to the contributors at the end' do
|
55
|
-
entries.each do |entry|
|
56
|
-
expect(entry).to match(/\(\[@\S+\]\[\](?:, \[@\S+\]\[\])*\)$/)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'link to related issue on github' do
|
61
|
-
let(:issues) do
|
62
|
-
entries.map do |entry|
|
63
|
-
entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^\)]+)\)/)
|
64
|
-
end.compact
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'has an issue number prefixed with #' do
|
68
|
-
issues.each do |issue|
|
69
|
-
expect(issue[:number]).to match(/^#\d+$/)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'has a valid URL' do
|
74
|
-
issues.each do |issue|
|
75
|
-
number = issue[:number].gsub(/\D/, '')
|
76
|
-
pattern = %r{^https://github\.com/.+/.+/(?:issues|pull)/#{number}$} # rubocop:disable LineLength
|
77
|
-
expect(issue[:url]).to match(pattern)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'has a colon and a whitespace at the end' do
|
82
|
-
entries_including_issue_link = entries.select do |entry|
|
83
|
-
entry.match(/^\*\s*\[/)
|
84
|
-
end
|
85
|
-
|
86
|
-
entries_including_issue_link.each do |entry|
|
87
|
-
expect(entry).to include('): ')
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'body' do
|
93
|
-
let(:bodies) do
|
94
|
-
entries.map do |entry|
|
95
|
-
entry
|
96
|
-
.sub(/^\*\s*(?:\[.+?\):\s*)?/, '')
|
97
|
-
.sub(/\s*\([^\)]+\)$/, '')
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'does not start with a lower case' do
|
102
|
-
bodies.each do |body|
|
103
|
-
expect(body).not_to match(/^[a-z]/)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'ends with a punctuation' do
|
108
|
-
bodies.each do |body|
|
109
|
-
expect(body).to match(/[\.\!]$/)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|