Sha256: 8264210e8065774340524973edbff0538001baa7e8a979acbab8aecbb3cd73dc

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

module RedisFailover
  describe CLI do
    describe '.parse' do
      it 'returns empty result for empty options' do
        CLI.parse({}).should == {}
      end

      it 'properly parses a server port' do
        opts = CLI.parse(['-P 2222'])
        opts.should == {:port => 2222}
      end

      it 'properly parses redis nodes' do
        opts = CLI.parse(['-n host1:1,host2:2,host3:3'])
        opts[:nodes].should == [
          {:host => 'host1', :port => '1'},
          {:host => 'host2', :port => '2'},
          {:host => 'host3', :port => '3'}
        ]
      end

      it 'properly parses a redis password' do
        opts = CLI.parse(['-n host:port', '-p redis_pass'])
        opts[:nodes].should == [{
          :host => 'host',
          :port => 'port',
          :password => 'redis_pass'
        }]
      end

      it 'properly parses max node failures' do
        opts = CLI.parse(['-n host:port', '-p redis_pass', '--max-failures', '1'])
        opts[:max_failures].should == 1
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redis_failover-0.4.0 spec/cli_spec.rb
redis_failover-0.3.0 spec/cli_spec.rb
redis_failover-0.2.0 spec/cli_spec.rb
redis_failover-0.1.1 spec/cli_spec.rb
redis_failover-0.1.0 spec/cli_spec.rb