Skip to content

Commit d5146b4

Browse files
authored
Use Rubocop to inspect rspec files (#601)
1 parent e07f971 commit d5146b4

15 files changed

+1357
-1264
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"settings": {
66
"terminal.integrated.profiles.linux": {
77
"bash": {
8-
"path": "bash",
8+
"path": "bash"
99
}
1010
}
1111
},

.rubocop.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require:
44
- rubocop-rspec
55
AllCops:
66
DisplayCopNames: true
7-
TargetRubyVersion: '2.4'
7+
TargetRubyVersion: '2.5'
88
Include:
99
- "**/*.rb"
1010
Exclude:
@@ -20,10 +20,7 @@ AllCops:
2020
- "**/Guardfile"
2121
- tooling/kube_tool/*
2222
- tooling/*
23-
- spec/defines/*
24-
- spec/classes/*
2523
- spec/*
26-
- spec/acceptance/*
2724
- rakelib/*
2825
- plans/*.pp
2926
- tasks/*

.sync.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,11 @@ Rakefile:
3636
strict:
3737
configs:
3838
AllCops:
39-
TargetRubyVersion: '2.4'
39+
TargetRubyVersion: '2.5'
4040
Exclude:
4141
- tooling/kube_tool/*
4242
- tooling/*
43-
- spec/defines/*
44-
- spec/classes/*
4543
- spec/*
46-
- spec/acceptance/*
4744
- rakelib/*
4845
- plans/*.pp
4946
- tasks/*

metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"version_requirement": ">= 6.24.0 < 8.0.0"
6969
}
7070
],
71-
"pdk-version": "2.6.0",
71+
"pdk-version": "2.6.1",
7272
"template-url": "https://github.com/puppetlabs/pdk-templates.git#main",
73-
"template-ref": "heads/main-0-g434e063"
73+
"template-ref": "heads/main-0-g383f471"
7474
}

spec/acceptance/integration_kubernetes_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
describe 'set up controller' do
1111
it 'sets up the controller' do
1212
run_shell('puppet agent --test', expect_failures: true) do |r|
13-
expect(r.exit_code.to_s).to match(/0|2/)
13+
expect(r.exit_code.to_s).to match(%r{0|2})
1414
end
1515
end
1616
end
@@ -21,7 +21,7 @@
2121
describe 'set up worker' do
2222
it 'sets up the worker' do
2323
run_shell('puppet agent --test', expect_failures: true) do |r|
24-
expect(r.exit_code.to_s).to match(/0|2/)
24+
expect(r.exit_code.to_s).to match(%r{0|2})
2525
end
2626
end
2727
end
@@ -32,24 +32,24 @@
3232
describe 'set up worker' do
3333
it 'sets up the worker' do
3434
run_shell('puppet agent --test', expect_failures: true) do |r|
35-
expect(r.exit_code.to_s).to match(/0|2/)
35+
expect(r.exit_code.to_s).to match(%r{0|2})
3636
end
3737
end
3838
end
3939
end
4040
context 'verify the k8 nodes' do
4141
before(:all) { change_target_host('controller') }
42-
hostname1, ipaddr1, int_ipaddr1 = fetch_ip_hostname_by_role('controller')
43-
hostname2, ipaddr2, int_ipaddr2 = fetch_ip_hostname_by_role('worker1')
44-
hostname3, ipaddr3, int_ipaddr3 = fetch_ip_hostname_by_role('worker2')
42+
hostname1, _ipaddr1, = fetch_ip_hostname_by_role('controller')
43+
hostname2, _ipaddr2, = fetch_ip_hostname_by_role('worker1')
44+
hostname3, _ipaddr3, = fetch_ip_hostname_by_role('worker2')
4545
after(:all) { reset_target_host }
4646
describe 'verify the k8 nodes' do
4747
it 'verify the k8 nodes' do
4848
run_shell('sleep 20')
4949
run_shell('KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes') do |r|
50-
expect(r.stdout).to match(/#{hostname1}(\s)+Ready(\s)+control-plane,master/)
51-
expect(r.stdout).to match(/#{hostname2}(\s)+Ready/)
52-
expect(r.stdout).to match(/#{hostname3}(\s)+Ready/)
50+
expect(r.stdout).to match(%r{#{hostname1}(\s)+Ready(\s)+control-plane,master})
51+
expect(r.stdout).to match(%r{#{hostname2}(\s)+Ready})
52+
expect(r.stdout).to match(%r{#{hostname3}(\s)+Ready})
5353
end
5454
end
5555
end

spec/acceptance/kubernetes_spec.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
end
77

88
describe 'kubernetes class', :integration do
9-
109
context 'it should install the module and run' do
1110
before(:all) { change_target_host('controller') }
1211
after(:all) { reset_target_host }
@@ -35,15 +34,15 @@ class {'kubernetes':
3534
}
3635
MANIFEST
3736

38-
it 'should run' do
37+
it 'runs' do
3938
apply_manifest(pp)
4039
end
4140

42-
it 'should install kubectl' do
41+
it 'installs kubectl' do
4342
run_shell('kubectl')
4443
end
4544

46-
it 'should install kube-dns' do
45+
it 'installs kube-dns' do
4746
run_shell('KUBECONFIG=/etc/kubernetes/admin.conf kubectl get deploy --namespace kube-system coredns')
4847
end
4948
end
@@ -53,22 +52,22 @@ class {'kubernetes':
5352
after(:all) { reset_target_host }
5453
it 'can deploy an application into a namespace and expose it' do
5554
run_shell('KUBECONFIG=/etc/kubernetes/admin.conf kubectl create -f /tmp/nginx.yml') do |r|
56-
expect(r.stdout).to match(/my-nginx created\nservice\/my-nginx created\n/)
55+
expect(r.stdout).to match(%r{my-nginx created\nservice/my-nginx created\n})
5756
end
5857
end
5958

6059
it 'can access the deployed service' do
6160
run_shell('sleep 60')
6261
run_shell('curl --retry 10 --retry-delay 15 -s 10.96.188.5') do |r|
63-
expect(r.stdout).to match (/Welcome to nginx!/)
62+
expect(r.stdout).to match(%r{Welcome to nginx!})
6463
end
6564
end
6665

6766
it 'can delete a deployment' do
6867
run_shell('KUBECONFIG=/etc/kubernetes/admin.conf kubectl delete -f /tmp/nginx.yml') do |r|
69-
expect(r.stdout).to match(/deployment.apps "my-nginx" deleted\nservice "my-nginx" deleted/)
68+
expect(r.stdout).to match(%r{deployment.apps "my-nginx" deleted\nservice "my-nginx" deleted})
7069
end
71-
run_shell('KUBECONFIG=/etc/kubernetes/admin.conf kubectl get deploy --all-namespaces | grep nginx', :expect_failures => true)
70+
run_shell('KUBECONFIG=/etc/kubernetes/admin.conf kubectl get deploy --all-namespaces | grep nginx', expect_failures: true)
7271
end
7372
end
7473
end

spec/classes/cluster_roles_spec.rb

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
require 'spec_helper'
22
describe 'kubernetes::cluster_roles', :type => :class do
3-
let(:facts) do {
4-
:kernel => 'Linux',
5-
:networking => {
6-
:hostname => 'foo',
3+
let(:facts) do
4+
{
5+
kernel: 'Linux',
6+
networking: {
7+
hostname: 'foo',
78
},
8-
:os => {
9-
:family => "Debian",
10-
:name => 'Ubuntu',
11-
:release => {
12-
:full => '16.04',
9+
os: {
10+
family: 'Debian',
11+
name: 'Ubuntu',
12+
release: {
13+
full: '16.04',
1314
},
14-
:distro => {
15-
:codename => "xenial",
15+
distro: {
16+
codename: 'xenial',
1617
},
1718
},
18-
:ec2_metadata => {
19-
:hostname => 'ip-10-10-10-1.ec2.internal',
19+
ec2_metadata: {
20+
hostname: 'ip-10-10-10-1.ec2.internal',
2021
},
21-
} end
22+
}
23+
end
2224

2325
context 'with controller => true' do
2426
let(:pre_condition) { 'include kubernetes' }
25-
let(:params) do
26-
{
27-
'controller' => true,
28-
'worker' => false,
29-
}
27+
let(:params) do
28+
{
29+
'controller' => true,
30+
'worker' => false,
31+
}
3032
end
3133

32-
it { should contain_kubernetes__kubeadm_init('foo') }
34+
it { is_expected.to contain_kubernetes__kubeadm_init('foo') }
3335
end
3436

3537
context 'with worker => true' do
3638
let(:pre_condition) { 'include kubernetes' }
37-
let(:params) do
38-
{
39-
'controller' => false,
40-
'worker' => true,
41-
}
39+
let(:params) do
40+
{
41+
'controller' => false,
42+
'worker' => true,
43+
}
4244
end
4345

44-
it { should contain_kubernetes__kubeadm_join('foo') }
46+
it { is_expected.to contain_kubernetes__kubeadm_join('foo') }
4547
end
4648
end

0 commit comments

Comments
 (0)