Sha256: 543d8d09a1bbe3d3f98b803d3631ab9c91a109126451003e6e8edc60f6cfac6d

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
wisepdf-1.2.0 test/parser_test.rb