Skip to content

Commit 3aadaf6

Browse files
committed
Fix @lsanchez-r7's feedback, single expectation per test and avoid explicit use of subject
1 parent 701d647 commit 3aadaf6

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

spec/lib/rex/mac_oui_spec.rb

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
describe Rex::Oui do
77
describe ".lookup_oui_fullname" do
8-
subject { described_class.lookup_oui_fullname(mac) }
8+
subject(:oui_fullname) { described_class.lookup_oui_fullname(mac) }
99

1010
context "when valid mac for OUI with name" do
1111
let(:mac) { '000011' }
@@ -28,13 +28,13 @@
2828
context "when invalid mac format" do
2929
let(:mac) { 'invalid' }
3030
it "raises an error" do
31-
expect { subject }.to raise_error
31+
expect { oui_fullname }.to raise_error
3232
end
3333
end
3434
end
3535

3636
describe ".lookup_oui_company_name" do
37-
subject { described_class.lookup_oui_company_name(mac) }
37+
subject(:oui_company_name) { described_class.lookup_oui_company_name(mac) }
3838

3939
context "when valid mac for OUI with name" do
4040
let(:mac) { '000011' }
@@ -57,34 +57,30 @@
5757
context "when invalid mac format" do
5858
let(:mac) { 'invalid' }
5959
it "raises an error" do
60-
expect { subject }.to raise_error
60+
expect { oui_company_name }.to raise_error
6161
end
6262
end
6363
end
6464

6565
describe ".check_mac" do
6666
context "when valid mac" do
67-
it "returns nil" do
68-
expect(described_class.check_mac('AA:BB:CC')).to be_nil
69-
expect(described_class.check_mac('AABBCC')).to be_nil
70-
expect(described_class.check_mac('AA:BB:CC:DD')).to be_nil
71-
expect(described_class.check_mac('AABBCCDD')).to be_nil
72-
expect(described_class.check_mac('AA:BB:CC:DD:EE')).to be_nil
73-
expect(described_class.check_mac('AABBCCDDEE')).to be_nil
74-
expect(described_class.check_mac('AA:BB:CC:DD:EE:FF')).to be_nil
75-
expect(described_class.check_mac('AABBCCDDEEFF')).to be_nil
76-
end
67+
it { expect(described_class.check_mac('AA:BB:CC')).to be_nil }
68+
it { expect(described_class.check_mac('AABBCC')).to be_nil }
69+
it { expect(described_class.check_mac('AA:BB:CC:DD')).to be_nil }
70+
it { expect(described_class.check_mac('AABBCCDD')).to be_nil }
71+
it { expect(described_class.check_mac('AA:BB:CC:DD:EE')).to be_nil }
72+
it { expect(described_class.check_mac('AABBCCDDEE')).to be_nil }
73+
it { expect(described_class.check_mac('AA:BB:CC:DD:EE:FF')).to be_nil }
74+
it { expect(described_class.check_mac('AABBCCDDEEFF')).to be_nil }
7775
end
7876

7977
context "when invalid mac" do
80-
it "raises an error" do
81-
expect { described_class.check_mac('AA') }.to raise_error
82-
expect { described_class.check_mac('AA:BB:CC:DD:JJ') }.to raise_error
83-
expect { described_class.check_mac('AA:BB') }.to raise_error
84-
expect { described_class.check_mac('AABB') }.to raise_error
85-
expect { described_class.check_mac('AA:BB:CC:DD:EE:FF:AA') }.to raise_error
86-
expect { described_class.check_mac('AABBCCDDEEFFAA') }.to raise_error
87-
end
78+
it { expect { described_class.check_mac('AA') }.to raise_error }
79+
it { expect { described_class.check_mac('AA:BB:CC:DD:JJ') }.to raise_error }
80+
it { expect { described_class.check_mac('AA:BB') }.to raise_error }
81+
it { expect { described_class.check_mac('AABB') }.to raise_error }
82+
it { expect { described_class.check_mac('AA:BB:CC:DD:EE:FF:AA') }.to raise_error }
83+
it { expect { described_class.check_mac('AABBCCDDEEFFAA') }.to raise_error }
8884
end
8985
end
9086
end

0 commit comments

Comments
 (0)