Sha256: 4ecdc0251b0710b2a60b6c3ebf64e99bc07b6e6e17eb4625e803cedea3e6f870

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

require 'spec_helper'
module Sexpr
  describe Grammar, "parse" do

    def parser
      Object.new.tap{|x|
        def x.parse(s)
          Struct.new(:value).new([:parsed, s])
        end
      }
    end

    def grammar(options = {})
      Sexpr.load({}, {:parser => parser})
    end

    it 'it accepts a string' do
      grammar.parse("Hello world").should eq([:parsed, "Hello world"])
    end

    it 'it accepts a path' do
      grammar.parse(Path.here).should eq([:parsed, File.read(__FILE__)])
    end

    it 'it accepts an IO' do
      File.open(__FILE__, 'r') do |io|
        grammar.parse(io).should eq([:parsed, File.read(__FILE__)])
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sexpr-0.2.0 spec/grammar/test_parse.rb