Sha256: 084b135dbcfc3b8a513089143ac34bd31d49aad843b12660d1b57e760c0f3a78

Contents?: true

Size: 1.41 KB

Versions: 7

Compression:

Stored size: 1.41 KB

Contents

require 'helper'

class ParserTest < Test::Unit::TestCase
  context "Options normalization" do
    setup do
      Wisepdf::Configuration.reset!

      @options = { Wisepdf::Parser::ESCAPED_OPTIONS.sample => 'value' }
    end

    should 'escape and parse digit options' do
      @options.merge!({
        :key => 10
      })
      expected = {
        '--key' => '10'
      }

      assert_equal expected, Wisepdf::Parser.parse(@options)
    end

    should 'escape and parse string options' do
      @options.merge!({
        :key => 'value'
      })
      expected = {
        '--key' => 'value'
      }

      assert_equal expected, Wisepdf::Parser.parse(@options)
    end

    should 'escape and parse boolean (true) options' do
      @options.merge!({
        :key => true
      })
      expected = {
        '--key' => nil
      }

      assert_equal expected, Wisepdf::Parser.parse(@options)
    end

    should 'escape and parse boolean (false) options' do
      @options.merge!({
        :key => false
      })
      expected = {}

      assert_equal expected, Wisepdf::Parser.parse(@options)
    end

    should 'escape and parse nested options' do
      @options.merge!({
        :key => 'value',
        :nested => {
          :key => 'value'
        }
      })
      expected = {
        '--key' => 'value',
        '--nested-key' => 'value'
      }

      assert_equal expected, Wisepdf::Parser.parse(@options)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wisepdf-1.4.0 test/parser_test.rb
wisepdf-1.3.1 test/parser_test.rb
wisepdf-1.3.0 test/parser_test.rb
wisepdf-1.2.10 test/parser_test.rb
wisepdf-1.2.9 test/parser_test.rb
wisepdf-1.2.8 test/parser_test.rb
wisepdf-1.2.7 test/parser_test.rb