Skip to content

Commit d187bb9

Browse files
committed
Correct RSpec/ImplicitSubject
1 parent 1da319b commit d187bb9

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

.rubocop_todo.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-04-05 09:14:52 UTC using RuboCop version 1.48.1.
3+
# on 2023-04-05 10:28:45 UTC using RuboCop version 1.48.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -56,19 +56,18 @@ RSpec/DescribeClass:
5656
RSpec/ExampleLength:
5757
Max: 24
5858

59+
# Offense count: 25
60+
RSpec/MultipleExpectations:
61+
Max: 22
62+
5963
# Offense count: 20
60-
# This cop supports safe autocorrection (--autocorrect).
61-
# Configuration parameters: EnforcedStyle.
62-
# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit
63-
RSpec/ImplicitSubject:
64+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
65+
# SupportedStyles: always, named_only
66+
RSpec/NamedSubject:
6467
Exclude:
6568
- 'spec/defines/accounts_user_spec.rb'
6669
- 'spec/functions/accounts_ssh_authorized_keys_line_parser_spec.rb'
6770

68-
# Offense count: 25
69-
RSpec/MultipleExpectations:
70-
Max: 22
71-
7271
# Offense count: 29
7372
# Configuration parameters: AllowedGroups.
7473
RSpec/NestedGroups:

spec/defines/accounts_user_spec.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@
3030
let(:params) { {} }
3131

3232
it do
33-
is_expected.to contain_user(title).with('shell' => '/bin/bash')
34-
is_expected.to contain_user(title).with('home' => user_vars[:dan_home])
35-
is_expected.to contain_user(title).with('ensure' => 'present')
36-
is_expected.to contain_user(title).with('comment' => title)
37-
is_expected.to contain_user(title).with('gid' => title)
38-
is_expected.to contain_user(title).with('groups' => [])
39-
is_expected.to contain_user(title).with('allowdupe' => false)
40-
is_expected.to contain_user(title).with('managehome' => true)
33+
expect(subject).to contain_user(title).with('shell' => '/bin/bash')
34+
expect(subject).to contain_user(title).with('home' => user_vars[:dan_home])
35+
expect(subject).to contain_user(title).with('ensure' => 'present')
36+
expect(subject).to contain_user(title).with('comment' => title)
37+
expect(subject).to contain_user(title).with('gid' => title)
38+
expect(subject).to contain_user(title).with('groups' => [])
39+
expect(subject).to contain_user(title).with('allowdupe' => false)
40+
expect(subject).to contain_user(title).with('managehome' => true)
4141
end
4242

4343
it do
44-
is_expected.to contain_group(title).with('ensure' => 'present')
45-
is_expected.to contain_group(title).with('gid' => nil)
44+
expect(subject).to contain_group(title).with('ensure' => 'present')
45+
expect(subject).to contain_group(title).with('gid' => nil)
4646
end
4747
end
4848

@@ -75,16 +75,16 @@
7575
it { is_expected.to contain_user(title).with(param.to_s => params[param]) }
7676
end
7777
it do
78-
is_expected.to contain_user(title).with('gid' => params[:group])
79-
is_expected.to contain_group(params[:group]).with('ensure' => params[:ensure],
80-
'gid' => params[:gid])
78+
expect(subject).to contain_user(title).with('gid' => params[:group])
79+
expect(subject).to contain_group(params[:group]).with('ensure' => params[:ensure],
80+
'gid' => params[:gid])
8181
end
8282

8383
it { is_expected.to contain_group(params[:group]).that_comes_before("User[#{title}]") }
8484

8585
it do
86-
is_expected.to contain_accounts__home_dir(params[:home]).with('user' => title,
87-
'mode' => params[:home_mode])
86+
expect(subject).to contain_accounts__home_dir(params[:home]).with('user' => title,
87+
'mode' => params[:home_mode])
8888
end
8989

9090
it { is_expected.to contain_accounts__key_management("#{title}_key_management").with('sshkeys' => params[:sshkeys]) }

spec/functions/accounts_ssh_authorized_keys_line_parser_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@
44

55
describe 'accounts_ssh_authorized_keys_line_parser' do
66
it {
7-
is_expected.not_to eq(nil)
7+
expect(subject).not_to eq(nil)
88
}
99

1010
it {
11-
is_expected.to run.with_params('').and_raise_error(ArgumentError, %r{Wrong Keyline format!})
11+
expect(subject).to run.with_params('').and_raise_error(ArgumentError, %r{Wrong Keyline format!})
1212
}
1313

1414
it {
15-
is_expected.to run.with_params('options unknown-keytype key comment').and_raise_error(ArgumentError, %r{Wrong Keyline format!})
15+
expect(subject).to run.with_params('options unknown-keytype key comment').and_raise_error(ArgumentError, %r{Wrong Keyline format!})
1616
}
1717

1818
it {
19-
is_expected.to run.with_params('ssh-xyz key name with spaces').and_return( \
19+
expect(subject).to run.with_params('ssh-xyz key name with spaces').and_return( \
2020
['', 'ssh-xyz', 'key', 'name with spaces'],
2121
)
2222
}
2323

2424
it {
25-
is_expected.to run.with_params('"options with arguments",moreoptions,"moreoptions with arguments" ecdsa-xyz key name with spaces').and_return( \
25+
expect(subject).to run.with_params('"options with arguments",moreoptions,"moreoptions with arguments" ecdsa-xyz key name with spaces').and_return( \
2626
['"options with arguments",moreoptions,"moreoptions with arguments"', 'ecdsa-xyz', 'key', 'name with spaces'],
2727
)
2828
}
2929

3030
it {
31-
is_expected.to run.with_params('tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== [email protected]').and_return( \
31+
expect(subject).to run.with_params('tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== [email protected]').and_return( \
3232
['tunnel="0",command="sh /etc/netstart tun0"', 'ssh-rsa', 'AAAA...==', '[email protected]'],
3333
)
3434
}
3535

3636
it {
3737
# rubocop:disable Layout/LineLength
38-
is_expected.to run.with_params('command="rsync --server --sender -vlHogtpr --numeric-ids . /",from="192.168.1.1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ecdsa-sha2-nistp384 AAAA...= rsync backup').and_return( \
38+
expect(subject).to run.with_params('command="rsync --server --sender -vlHogtpr --numeric-ids . /",from="192.168.1.1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ecdsa-sha2-nistp384 AAAA...= rsync backup').and_return( \
3939
['command="rsync --server --sender -vlHogtpr --numeric-ids . /",from="192.168.1.1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding', 'ecdsa-sha2-nistp384', 'AAAA...=', 'rsync backup'],
4040
)
4141
# rubocop:enable Layout/LineLength

0 commit comments

Comments
 (0)