Skip to content

Commit

Permalink
Fix unit tests for remote_address strategy.
Browse files Browse the repository at this point in the history
  • Loading branch information
rarruda committed Nov 12, 2018
1 parent d2ea146 commit 0c3d533
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions spec/unleash/strategy/remote_address_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
let(:unleash_context) { Unleash::Context.new(remote_address: '127.0.0.1') }

it 'should be enabled with correct params' do
expect(strategy.is_enabled?({'ips' => '192.168.0.1,127.0.0.1,172.12.0.1'}, unleash_context)).to be_truthy
expect(strategy.is_enabled?({'IPs' => '192.168.0.1,127.0.0.1,172.12.0.1'}, unleash_context)).to be_truthy

unleash_context2 = Unleash::Context.new
unleash_context2.remote_address = '172.12.0.1'
expect(strategy.is_enabled?({'ips' => '192.168.0.1,127.0.0.1,172.12.0.1'}, unleash_context2)).to be_truthy
expect(strategy.is_enabled?({'IPs' => '192.168.0.1,127.0.0.1,172.12.0.1'}, unleash_context2)).to be_truthy
end

it 'should be disabled with false params' do
expect(strategy.is_enabled?({'ips' => '192.168.0.1,172.12.0.1'}, unleash_context)).to be_falsey
expect(strategy.is_enabled?({'IPs' => '192.168.0.1,172.12.0.1'}, unleash_context)).to be_falsey
end

it 'should be disabled on invalid params' do
expect(strategy.is_enabled?({'ips' => nil}, unleash_context)).to be_falsey
expect(strategy.is_enabled?({'ips' => '192.168.0.1,172.12.0.1'}, unleash_context)).to be_falsey
expect(strategy.is_enabled?({'IPs' => nil}, unleash_context)).to be_falsey
expect(strategy.is_enabled?({}, unleash_context)).to be_falsey
expect(strategy.is_enabled?('ips_list', unleash_context)).to be_falsey
expect(strategy.is_enabled?('IPs_list', unleash_context)).to be_falsey
end

it 'should be disabled on invalid contexts' do
expect(strategy.is_enabled?({'ips' => '192.168.0.1,127.0.0.1,172.12.0.1'}, Unleash::Context.new)).to be_falsey
expect(strategy.is_enabled?({'ips' => '192.168.0.1,127.0.0.1,172.12.0.1'}, nil)).to be_falsey
expect(strategy.is_enabled?({'ips' => '192.168.0.1,127.0.0.1,172.12.0.1'})).to be_falsey
expect(strategy.is_enabled?({'IPs' => '192.168.0.1,127.0.0.1,172.12.0.1'}, Unleash::Context.new)).to be_falsey
expect(strategy.is_enabled?({'IPs' => '192.168.0.1,127.0.0.1,172.12.0.1'}, nil)).to be_falsey
expect(strategy.is_enabled?({'IPs' => '192.168.0.1,127.0.0.1,172.12.0.1'})).to be_falsey
end
end
end

0 comments on commit 0c3d533

Please sign in to comment.