|
111 | 111 | end |
112 | 112 | end |
113 | 113 |
|
114 | | - describe '#run_on_changes', :processes_after_running do |
115 | | - subject { super().run_on_changes(changed_paths) } |
116 | | - let(:changed_paths) do |
117 | | - [ |
118 | | - 'lib/guard/rubocop.rb', |
119 | | - 'spec/spec_helper.rb' |
120 | | - ] |
121 | | - end |
122 | | - |
123 | | - before do |
124 | | - allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(true) |
125 | | - allow_any_instance_of(Guard::Rubocop::Runner).to receive(:failed_paths).and_return([]) |
126 | | - end |
| 114 | + [:run_on_additions, :run_on_modifications].each do |method| |
| 115 | + describe "##{method}", :processes_after_running do |
| 116 | + subject { super().send(method, changed_paths) } |
| 117 | + let(:changed_paths) do |
| 118 | + [ |
| 119 | + 'lib/guard/rubocop.rb', |
| 120 | + 'spec/spec_helper.rb' |
| 121 | + ] |
| 122 | + end |
127 | 123 |
|
128 | | - it 'inspects changed files with rubocop' do |
129 | | - expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) |
130 | | - guard.run_on_changes(changed_paths) |
131 | | - end |
| 124 | + before do |
| 125 | + allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(true) |
| 126 | + allow_any_instance_of(Guard::Rubocop::Runner).to receive(:failed_paths).and_return([]) |
| 127 | + end |
132 | 128 |
|
133 | | - it 'passes cleaned paths to rubocop' do |
134 | | - expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths| |
135 | | - expect(paths).to eq([ |
136 | | - File.expand_path('some.rb'), |
137 | | - File.expand_path('dir/another.rb') |
138 | | - ]) |
| 129 | + it 'inspects changed files with rubocop' do |
| 130 | + expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) |
| 131 | + subject |
139 | 132 | end |
140 | | - guard.run_on_changes(changed_paths) |
141 | | - end |
142 | 133 |
|
143 | | - context 'when cleaned paths are empty' do |
144 | | - before do |
145 | | - allow(guard).to receive(:clean_paths).and_return([]) |
| 134 | + it 'passes cleaned paths to rubocop' do |
| 135 | + expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths| |
| 136 | + expect(paths).to eq([ |
| 137 | + File.expand_path('some.rb'), |
| 138 | + File.expand_path('dir/another.rb') |
| 139 | + ]) |
| 140 | + end |
| 141 | + subject |
146 | 142 | end |
147 | 143 |
|
148 | | - it 'does nothing' do |
149 | | - expect_any_instance_of(Guard::Rubocop::Runner).not_to receive(:run) |
150 | | - guard.run_on_changes(changed_paths) |
| 144 | + context 'when cleaned paths are empty' do |
| 145 | + before do |
| 146 | + allow(guard).to receive(:clean_paths).and_return([]) |
| 147 | + end |
| 148 | + |
| 149 | + it 'does nothing' do |
| 150 | + expect_any_instance_of(Guard::Rubocop::Runner).not_to receive(:run) |
| 151 | + subject |
| 152 | + end |
151 | 153 | end |
152 | | - end |
153 | 154 |
|
154 | | - let(:failed_path) { File.expand_path('Rakefile') } |
| 155 | + let(:failed_path) { File.expand_path('Rakefile') } |
155 | 156 |
|
156 | | - context 'when :keep_failed option is enabled' do |
157 | | - let(:options) { { keep_failed: true } } |
| 157 | + context 'when :keep_failed option is enabled' do |
| 158 | + let(:options) { { keep_failed: true } } |
158 | 159 |
|
159 | | - it 'also inspects paths which are failed last time' do |
160 | | - guard.failed_paths << failed_path |
161 | | - expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths| |
162 | | - expect(paths).to include failed_path |
| 160 | + it 'also inspects paths which are failed last time' do |
| 161 | + guard.failed_paths << failed_path |
| 162 | + expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths| |
| 163 | + expect(paths).to include failed_path |
| 164 | + end |
| 165 | + subject |
163 | 166 | end |
164 | | - guard.run_on_changes(changed_paths) |
165 | 167 | end |
166 | | - end |
167 | 168 |
|
168 | | - context 'when :keep_failed option is disabled' do |
169 | | - let(:options) { { keep_failed: false } } |
| 169 | + context 'when :keep_failed option is disabled' do |
| 170 | + let(:options) { { keep_failed: false } } |
170 | 171 |
|
171 | | - it 'inspects just changed paths' do |
172 | | - guard.failed_paths << failed_path |
173 | | - expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths| |
174 | | - expect(paths).to eq(changed_paths) |
| 172 | + it 'inspects just changed paths' do |
| 173 | + guard.failed_paths << failed_path |
| 174 | + expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths| |
| 175 | + expect(paths).to eq(changed_paths) |
| 176 | + end |
| 177 | + subject |
175 | 178 | end |
176 | | - guard.run_on_changes(changed_paths) |
177 | 179 | end |
178 | 180 | end |
179 | 181 | end |
|
0 commit comments