Skip to content

Commit

Permalink
rubocop: fix Style/DotPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 26, 2016
1 parent 85ab239 commit 62324cf
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 130 deletions.
148 changes: 83 additions & 65 deletions spec/unit/provider/network_route/redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,60 @@ def fixture_data(file)
let(:data) { described_class.parse_file('', fixture_data('simple_routes')) }

it 'parses out normal ipv4 network routes' do
expect(data.find { |h| h[:name] == '172.17.67.0/30' })
.to eq(name: '172.17.67.0/30',
network: '172.17.67.0',
netmask: '255.255.255.252',
gateway: '172.18.6.2',
interface: 'vlan200')
expect(data.find { |h| h[:name] == '172.17.67.0/30' }).to eq(
name: '172.17.67.0/30',
network: '172.17.67.0',
netmask: '255.255.255.252',
gateway: '172.18.6.2',
interface: 'vlan200'
)
end
it 'parses out ipv6 network routes' do
expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' })
.to eq(name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200')
expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' }).to eq(
name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200'
)
end

it 'parses out default routes' do
expect(data.find { |h| h[:name] == 'default' }).to eq(name: 'default',
network: 'default',
netmask: '0.0.0.0',
gateway: '10.0.0.1',
interface: 'eth1')
expect(data.find { |h| h[:name] == 'default' }).to eq(
name: 'default',
network: 'default',
netmask: '0.0.0.0',
gateway: '10.0.0.1',
interface: 'eth1'
)
end
end

describe 'an advanced, well formed file' do
let(:data) { described_class.parse_file('', fixture_data('advanced_routes')) }
let :data do
described_class.parse_file('', fixture_data('advanced_routes'))
end

it 'parses out normal ipv4 network routes' do
expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' })
.to eq(name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200',
options: 'table 200')
expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' }).to eq(
name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200',
options: 'table 200'
)
end

it 'parses out normal ipv6 network routes' do
expect(data.find { |h| h[:name] == '172.17.67.0/30' })
.to eq(name: '172.17.67.0/30',
network: '172.17.67.0',
netmask: '255.255.255.252',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200')
expect(data.find { |h| h[:name] == '172.17.67.0/30' }).to eq(
name: '172.17.67.0/30',
network: '172.17.67.0',
netmask: '255.255.255.252',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200'
)
end
end

Expand All @@ -72,47 +80,57 @@ def fixture_data(file)
end

describe 'when formatting' do
let(:route1_provider) do
stub('route1_provider',
name: '172.17.67.0/30',
network: '172.17.67.0',
netmask: '30',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200')
let :route1_provider do
stub(
'route1_provider',
name: '172.17.67.0/30',
network: '172.17.67.0',
netmask: '30',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200'
)
end

let(:route2_provider) do
stub('lo_provider',
name: '172.28.45.0/30',
network: '172.28.45.0',
netmask: '30',
gateway: '172.18.6.2',
interface: 'eth0',
options: 'table 200')
let :route2_provider do
stub(
'lo_provider',
name: '172.28.45.0/30',
network: '172.28.45.0',
netmask: '30',
gateway: '172.18.6.2',
interface: 'eth0',
options: 'table 200'
)
end

let(:defaultroute_provider) do
stub('defaultroute_provider',
name: 'default',
network: 'default',
netmask: '',
gateway: '10.0.0.1',
interface: 'eth1',
options: 'table 200')
let :defaultroute_provider do
stub(
'defaultroute_provider',
name: 'default',
network: 'default',
netmask: '',
gateway: '10.0.0.1',
interface: 'eth1',
options: 'table 200'
)
end

let(:nooptions_provider) do
stub('nooptions_provider',
name: 'default',
network: 'default',
netmask: '',
gateway: '10.0.0.1',
interface: 'eth2',
options: :absent)
let :nooptions_provider do
stub(
'nooptions_provider',
name: 'default',
network: 'default',
netmask: '',
gateway: '10.0.0.1',
interface: 'eth2',
options: :absent
)
end

let(:content) { described_class.format_file('', [route1_provider, route2_provider, defaultroute_provider, nooptions_provider]) }
let :content do
described_class.format_file('', [route1_provider, route2_provider, defaultroute_provider, nooptions_provider])
end

describe 'writing the route line' do
describe 'For standard (non-default) routes' do
Expand Down
148 changes: 83 additions & 65 deletions spec/unit/provider/network_route/routes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,66 @@ def fixture_data(file)
fixture = fixture_data('simple_routes')
data = described_class.parse_file('', fixture)

expect(data.find { |h| h[:name] == '172.17.67.0/24' })
.to eq(name: '172.17.67.0/24',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200')
expect(data.find { |h| h[:name] == '172.17.67.0/24' }).to eq(
name: '172.17.67.0/24',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200'
)
end

it 'names default routes "default" and have a 0.0.0.0 netmask' do
fixture = fixture_data('simple_routes')
data = described_class.parse_file('', fixture)

expect(data.find { |h| h[:name] == 'default' })
.to eq(name: 'default',
network: 'default',
netmask: '0.0.0.0',
gateway: '172.18.6.2',
interface: 'vlan200')
expect(data.find { |h| h[:name] == 'default' }).to eq(
name: 'default',
network: 'default',
netmask: '0.0.0.0',
gateway: '172.18.6.2',
interface: 'vlan200'
)
end

it 'parses out simple ipv6 iface lines' do
fixture = fixture_data('simple_routes')
data = described_class.parse_file('', fixture)

expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' })
.to eq(name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200')
expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' }).to eq(
name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200'
)
end

it 'parses out advanced routes' do
fixture = fixture_data('advanced_routes')
data = described_class.parse_file('', fixture)

expect(data.find { |h| h[:name] == '172.17.67.0/24' }).to eq(name: '172.17.67.0/24',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200')
expect(data.find { |h| h[:name] == '172.17.67.0/24' }).to eq(
name: '172.17.67.0/24',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200'
)
end
it 'parses out advanced ipv6 iface lines' do
fixture = fixture_data('advanced_routes')
data = described_class.parse_file('', fixture)

expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' })
.to eq(name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200',
options: 'table 200')
expect(data.find { |h| h[:name] == '2a01:4f8:211:9d5:53::/96' }).to eq(
name: '2a01:4f8:211:9d5:53::/96',
network: '2a01:4f8:211:9d5:53::',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff::',
gateway: '2a01:4f8:211:9d5::2',
interface: 'vlan200',
options: 'table 200'
)
end

describe 'when reading an invalid routes file' do
Expand All @@ -79,27 +85,33 @@ def fixture_data(file)
end

describe 'when formatting' do
let(:route1_provider) do
stub('route1_provider',
name: '172.17.67.0',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200')
let :route1_provider do
stub(
'route1_provider',
name: '172.17.67.0',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200',
options: 'table 200'
)
end

let(:route2_provider) do
stub('lo_provider',
name: '172.28.45.0',
network: '172.28.45.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'eth0',
options: 'table 200')
let :route2_provider do
stub(
'lo_provider',
name: '172.28.45.0',
network: '172.28.45.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'eth0',
options: 'table 200'
)
end

let(:content) { described_class.format_file('', [route1_provider, route2_provider]) }
let :content do
described_class.format_file('', [route1_provider, route2_provider])
end

describe 'writing the route line' do
it 'writes all 5 fields' do
Expand All @@ -125,27 +137,33 @@ def fixture_data(file)
end
end
describe 'when formatting simple files' do
let(:route1_provider) do
stub('route1_provider',
name: '172.17.67.0',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200',
options: :absent)
let :route1_provider do
stub(
'route1_provider',
name: '172.17.67.0',
network: '172.17.67.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'vlan200',
options: :absent
)
end

let(:route2_provider) do
stub('lo_provider',
name: '172.28.45.0',
network: '172.28.45.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'eth0',
options: :absent)
let :route2_provider do
stub(
'lo_provider',
name: '172.28.45.0',
network: '172.28.45.0',
netmask: '255.255.255.0',
gateway: '172.18.6.2',
interface: 'eth0',
options: :absent
)
end

let(:content) { described_class.format_file('', [route1_provider, route2_provider]) }
let :content do
described_class.format_file('', [route1_provider, route2_provider])
end

describe 'writing the route line' do
it 'writes only fields' do
Expand Down

0 comments on commit 62324cf

Please sign in to comment.