Sha256: 3853da673f40a877fdd73696c72991998f8410cb04a962991694b05898be8435

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 Bytes

Contents

require "spec_helper"

describe StatefulParser do
  let(:parser) { StatefulParser.new }
  let(:content_to_parse) { 'Parse me statefully!' }
  let(:content_to_reject) { 'Do not parse this!' }
  
  describe ".detect" do
    context 'parseable content' do
      it "returns true" do
        expect(parser.detect(content_to_parse)).to eq(true)
      end
    end
    context 'rejectable content' do
      it "returns false" do
        expect(parser.detect(content_to_reject)).to eq(false)
      end
    end
  end

  describe '#parse' do
    before(:each) do
      parser.parse!(content_to_parse)
    end
    it 'parses the content properly' do
      expect(parser.gimme_data.to_s).to eq("[#<OpenStruct index=0, content=\"Parse\">, #<OpenStruct index=1, content=\"me\">, #<OpenStruct index=2, content=\"statefully!\">]")
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynamic_parser-0.0.2 spec/dynamic_parser/stateful_parser_spec.rb
dynamic_parser-0.0.0.pre.5 spec/dynamic_parser/stateful_parser_spec.rb