Sha256: 3b979050b49b640c667f9a881e7a68fb6c632940cdcec66ce52454d6c619927a

Contents?: true

Size: 889 Bytes

Versions: 7

Compression:

Stored size: 889 Bytes

Contents

require "spec_helper"

describe Microformat::Collection do
  subject do
    Microformat::Collection.new
  end
  
  describe "#<<" do
    it "should parse the element to the collection" do
      selector = ".selector"
      source = %Q(<html><body>
          <div class="#{selector.gsub(/^\./, "")}"></div>
      </body></html>)
      element = Nokogiri::HTML(source).css(selector).first
      parsed = mock("parsed_object")
      format = mock("format")
      format.should_receive(:parse).and_return(parsed)
      Microformat::Selectors.define(selector, format)
      subject << element
      expect(subject).to include parsed
    end
  end

  describe "#filter" do
    it "should filter the collection down to the specific classes" do
      objects = [Object.new, Hash.new, Array.new]
      subject.replace(objects)
      expect(subject.filter(Hash)).to eq [objects[1]]
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
elcamino-microformat-0.0.8 spec/microformat/collection_spec.rb
microformat-0.0.7 spec/microformat/collection_spec.rb
microformat-0.0.6 spec/microformat/collection_spec.rb
microformat-0.0.5 spec/microformat/collection_spec.rb
microformat-0.0.4 spec/microformat/collection_spec.rb
microformat-0.0.3 spec/microformat/collection_spec.rb
microformat-0.0.2 spec/microformat/collection_spec.rb