Sha256: 2cd451d31b5f2e9701bf7d7adff610c3ce63f41233ecf57a4887d9d96d89bb9b

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

require_relative "spec_helper"

describe Nyara do
  context ".reconfig_with_command_line_options" do
    before :each do
      Nyara.config.reset
    end

    def config cmd_opts
      Nyara.send :reconfig_with_command_line_options, cmd_opts
    end

    it "works" do
      config %w'-p 1234 -d'
      assert_equal 1234, Nyara.config['port']
      assert_equal true, Nyara.config['daemon']
    end

    it "works without -d" do
      config %w'-p 100'
      assert_equal 100, Nyara.config['port']
      assert_equal true, !Nyara.config['daemon']
    end

    it "raises for bad options" do
      assert_raise RuntimeError do
        config %w'xx'
      end
    end

    it "recognizes --daemon and --port" do
      config %w'--port=1245 --daemon'
      assert_equal 1245, Nyara.config['port']
      assert_equal true, Nyara.config['daemon']
    end

    it "raises for bad port" do
      assert_raise RuntimeError do
        config %w'--port 100000'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyara-0.1.pre.2 spec/nyara_spec.rb