Skip to content

Commit 4ad499d

Browse files
committed
Adjust SpaceInsideBlockBraces to give some space
1 parent 671760a commit 4ad499d

File tree

8 files changed

+42
-39
lines changed

8 files changed

+42
-39
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Layout/SpaceInsidePercentLiteralDelimiters:
7272
Layout/SpaceAroundEqualsInParameterDefault:
7373
EnforcedStyle: space
7474

75+
Layout/SpaceInsideBlockBraces:
76+
EnforcedStyleForEmptyBraces: space
77+
7578
Layout/SpaceAroundBlockParameters:
7679
Enabled: false
7780

benchmarks/before_block_capture_block_vs_yield.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def capture_block_and_call_n_times(n, &block)
2121

2222
Benchmark.ips do |x|
2323
x.report("Yield #{count} times ") do
24-
yield_n_times(count) {}
24+
yield_n_times(count) { }
2525
end
2626

2727
x.report("Capture block and yield #{count} times") do
28-
capture_block_and_yield_n_times(count) {}
28+
capture_block_and_yield_n_times(count) { }
2929
end
3030

3131
x.report("Capture block and call #{count} times ") do
32-
capture_block_and_call_n_times(count) {}
32+
capture_block_and_call_n_times(count) { }
3333
end
3434
end
3535
end

lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class HaveBroadcastedTo < RSpec::Matchers::BuiltIn::BaseMatcher
88
def initialize(target, channel:)
99
@target = target
1010
@channel = channel
11-
@block = proc {}
11+
@block = proc { }
1212
@data = nil
1313
set_expected_number(:exactly, 1)
1414
end

lib/rspec/rails/matchers/active_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize
1515
@args = []
1616
@queue = nil
1717
@at = nil
18-
@block = proc {}
18+
@block = proc { }
1919
set_expected_number(:exactly, 1)
2020
end
2121

spec/rspec/rails/example/controller_example_group_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def my_helper
6969

7070
before do
7171
group.class_exec do
72-
controller(Class.new) {}
72+
controller(Class.new) { }
7373
end
7474

7575
allow(controller).to receive(:foos_url).and_return('http://test.host/foos')
@@ -116,13 +116,13 @@ def my_helper
116116
end
117117

118118
it "infers the anonymous controller class" do
119-
group.controller {}
119+
group.controller { }
120120
expect(group.controller_class.superclass).to eq(anonymous_klass)
121121
end
122122

123123
it "infers the anonymous controller class when no ApplicationController is present" do
124124
hide_const '::ApplicationController'
125-
group.controller {}
125+
group.controller { }
126126
expect(group.controller_class.superclass).to eq(anonymous_klass)
127127
end
128128
end
@@ -136,13 +136,13 @@ def my_helper
136136
end
137137

138138
it "sets the anonymous controller class to ApplicationController" do
139-
group.controller {}
139+
group.controller { }
140140
expect(group.controller_class.superclass).to eq(ApplicationController)
141141
end
142142

143143
it "sets the anonymous controller class to ActiveController::Base when no ApplicationController is present" do
144144
hide_const '::ApplicationController'
145-
group.controller {}
145+
group.controller { }
146146
expect(group.controller_class.superclass).to eq(ActionController::Base)
147147
end
148148
end
@@ -152,35 +152,35 @@ def my_helper
152152
let(:controller_class) { group.controller_class }
153153

154154
it "sets the name as AnonymousController if it's anonymous" do
155-
group.controller {}
155+
group.controller { }
156156
expect(controller_class.name).to eq "AnonymousController"
157157
end
158158

159159
it "sets the name according to defined controller if it is not anonymous" do
160160
stub_const "FoosController", Class.new(::ApplicationController)
161-
group.controller(FoosController) {}
161+
group.controller(FoosController) { }
162162
expect(controller_class.name).to eq "FoosController"
163163
end
164164

165165
it "sets name as AnonymousController if defined as ApplicationController" do
166-
group.controller(ApplicationController) {}
166+
group.controller(ApplicationController) { }
167167
expect(controller_class.name).to eq "AnonymousController"
168168
end
169169

170170
it "sets name as AnonymousController if the controller is abstract" do
171171
abstract_controller = Class.new(::ApplicationController)
172172
def abstract_controller.abstract?; true; end
173173

174-
group.controller(abstract_controller) {}
174+
group.controller(abstract_controller) { }
175175
expect(controller_class.name).to eq "AnonymousController"
176176
end
177177

178178
it "sets name as AnonymousController if it inherits outer group's anonymous controller" do
179179
outer_group = group_for ApplicationController
180-
outer_group.controller {}
180+
outer_group.controller { }
181181

182-
inner_group = group.describe {}
183-
inner_group.controller(outer_group.controller_class) {}
182+
inner_group = group.describe { }
183+
inner_group.controller(outer_group.controller_class) { }
184184

185185
expect(inner_group.controller_class.name).to eq "AnonymousController"
186186
end
@@ -192,7 +192,7 @@ def abstract_controller.abstract?; true; end
192192

193193
it "sets the name according to the defined controller namespace if it is not anonymous" do
194194
stub_const "A::B::FoosController", Class.new(::ApplicationController)
195-
group.controller(A::B::FoosController) {}
195+
group.controller(A::B::FoosController) { }
196196
expect(controller_class.name).to eq "A::B::FoosController"
197197
end
198198

@@ -201,7 +201,7 @@ def abstract_controller.abstract?; true; end
201201
def abstract_controller.abstract?; true; end
202202
stub_const "A::B::FoosController", abstract_controller
203203

204-
group.controller(A::B::FoosController) {}
204+
group.controller(A::B::FoosController) { }
205205
expect(controller_class.name).to eq "AnonymousController"
206206
end
207207
end

spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ def broadcast(stream, msg)
6464
end
6565

6666
it "passes when negated" do
67-
expect {}.not_to have_broadcasted_to('stream')
67+
expect { }.not_to have_broadcasted_to('stream')
6868
end
6969

7070
it "fails when message is not sent" do
7171
expect {
72-
expect {}.to have_broadcasted_to('stream')
72+
expect { }.to have_broadcasted_to('stream')
7373
}.to raise_error(/expected to broadcast exactly 1 messages to stream, but broadcast 0/)
7474
end
7575

@@ -85,7 +85,7 @@ def broadcast(stream, msg)
8585
it "reports correct number in fail error message" do
8686
broadcast('stream', 'one')
8787
expect {
88-
expect {}.to have_broadcasted_to('stream').exactly(1)
88+
expect { }.to have_broadcasted_to('stream').exactly(1)
8989
}.to raise_error(/expected to broadcast exactly 1 messages to stream, but broadcast 0/)
9090
end
9191

@@ -139,7 +139,7 @@ def broadcast(stream, msg)
139139

140140
it "generates failure message with at least hint" do
141141
expect {
142-
expect {}.to have_broadcasted_to('stream').at_least(:once)
142+
expect { }.to have_broadcasted_to('stream').at_least(:once)
143143
}.to raise_error(/expected to broadcast at least 1 messages to stream, but broadcast 0/)
144144
end
145145

spec/rspec/rails/matchers/active_job_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ def self.name; "LoggingJob"; end
9393
end
9494

9595
it "passes when negated" do
96-
expect {}.not_to have_enqueued_job
96+
expect { }.not_to have_enqueued_job
9797
end
9898

9999
it "fails when job is not enqueued" do
100100
expect {
101-
expect {}.to have_enqueued_job
101+
expect { }.to have_enqueued_job
102102
}.to raise_error(/expected to enqueue exactly 1 jobs, but enqueued 0/)
103103
end
104104

@@ -114,7 +114,7 @@ def self.name; "LoggingJob"; end
114114
it "reports correct number in fail error message" do
115115
heavy_lifting_job.perform_later
116116
expect {
117-
expect {}.to have_enqueued_job.exactly(1)
117+
expect { }.to have_enqueued_job.exactly(1)
118118
}.to raise_error(/expected to enqueue exactly 1 jobs, but enqueued 0/)
119119
end
120120

@@ -184,7 +184,7 @@ def self.name; "LoggingJob"; end
184184

185185
it "generates failure message with at least hint" do
186186
expect {
187-
expect {}.to have_enqueued_job.at_least(:once)
187+
expect { }.to have_enqueued_job.at_least(:once)
188188
}.to raise_error(/expected to enqueue at least 1 jobs, but enqueued 0/)
189189
end
190190

@@ -442,12 +442,12 @@ def self.name; "LoggingJob"; end
442442
end
443443

444444
it "passes when negated" do
445-
expect {}.not_to have_performed_job
445+
expect { }.not_to have_performed_job
446446
end
447447

448448
it "fails when job is not performed" do
449449
expect {
450-
expect {}.to have_performed_job
450+
expect { }.to have_performed_job
451451
}.to raise_error(/expected to perform exactly 1 jobs, but performed 0/)
452452
end
453453

@@ -463,7 +463,7 @@ def self.name; "LoggingJob"; end
463463
it "reports correct number in fail error message" do
464464
heavy_lifting_job.perform_later
465465
expect {
466-
expect {}.to have_performed_job.exactly(1)
466+
expect { }.to have_performed_job.exactly(1)
467467
}.to raise_error(/expected to perform exactly 1 jobs, but performed 0/)
468468
end
469469

@@ -524,7 +524,7 @@ def self.name; "LoggingJob"; end
524524

525525
it "generates failure message with at least hint" do
526526
expect {
527-
expect {}.to have_performed_job.at_least(:once)
527+
expect { }.to have_performed_job.at_least(:once)
528528
}.to raise_error(/expected to perform at least 1 jobs, but performed 0/)
529529
end
530530

spec/rspec/rails/matchers/have_enqueued_mail_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def email_with_args(arg1, arg2); end
6262
end
6363

6464
it "passes when negated" do
65-
expect {}.not_to have_enqueued_mail(TestMailer, :test_email)
65+
expect { }.not_to have_enqueued_mail(TestMailer, :test_email)
6666
end
6767

6868
it "passes when given 0 arguments" do
@@ -72,7 +72,7 @@ def email_with_args(arg1, arg2); end
7272
end
7373

7474
it "passes when negated with 0 arguments" do
75-
expect {}.not_to have_enqueued_email
75+
expect { }.not_to have_enqueued_email
7676
end
7777

7878
it "passes when only given mailer argument" do
@@ -82,7 +82,7 @@ def email_with_args(arg1, arg2); end
8282
end
8383

8484
it "passes when negated with only mailer arguments" do
85-
expect {}.not_to have_enqueued_email(TestMailer)
85+
expect { }.not_to have_enqueued_email(TestMailer)
8686
end
8787

8888
it "ensure that the right mailer is enqueued" do
@@ -168,19 +168,19 @@ def email_with_args(arg1, arg2); end
168168

169169
it "generates a failure message when given 0 argument" do
170170
expect {
171-
expect {}.to have_enqueued_mail.at_least(:once)
171+
expect { }.to have_enqueued_mail.at_least(:once)
172172
}.to raise_error(/expected to enqueue ActionMailer::Base at least 1 time but enqueued 0/)
173173
end
174174

175175
it "generates a failure message when given only mailer argument" do
176176
expect {
177-
expect {}.to have_enqueued_mail(TestMailer).at_least(:once)
177+
expect { }.to have_enqueued_mail(TestMailer).at_least(:once)
178178
}.to raise_error(/expected to enqueue TestMailer at least 1 time but enqueued 0/)
179179
end
180180

181181
it "generates a failure message with at least hint" do
182182
expect {
183-
expect {}.to have_enqueued_mail(TestMailer, :test_email).at_least(:once)
183+
expect { }.to have_enqueued_mail(TestMailer, :test_email).at_least(:once)
184184
}.to raise_error(/expected to enqueue TestMailer.test_email at least 1 time but enqueued 0/)
185185
end
186186

@@ -225,13 +225,13 @@ def email_with_args(arg1, arg2); end
225225

226226
it "generates a failure message" do
227227
expect {
228-
expect {}.to have_enqueued_email(TestMailer, :test_email)
228+
expect { }.to have_enqueued_email(TestMailer, :test_email)
229229
}.to raise_error(/expected to enqueue TestMailer.test_email/)
230230
end
231231

232232
it "generates a failure message with arguments" do
233233
expect {
234-
expect {}.to have_enqueued_email(TestMailer, :email_with_args).with(1, 2)
234+
expect { }.to have_enqueued_email(TestMailer, :email_with_args).with(1, 2)
235235
}.to raise_error(/expected to enqueue TestMailer.email_with_args exactly 1 time with \[1, 2\], but enqueued 0/)
236236
end
237237

0 commit comments

Comments
 (0)