Sha256: e840d9a027350a9211d705aa2eefddb39ec5117bf1ffbc42dfb4bcadfe892a94

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 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

6 entries across 6 versions & 1 rubygems

Version Path
wisepdf-1.2.6 test/parser_test.rb
wisepdf-1.2.5 test/parser_test.rb
wisepdf-1.2.4 test/parser_test.rb
wisepdf-1.2.3 test/parser_test.rb
wisepdf-1.2.2 test/parser_test.rb
wisepdf-1.2.1 test/parser_test.rb