Sha256: 9a3fc1a7f76a1ac3716381e45b7121c6015a49696f9d98f890b11bcb838aaf0c

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require 'rdf/spec'

module RDF_Countable
  extend RSpec::SharedContext
  include RDF::Spec::Matchers

  before :each do
    raise '+@countable+ must be defined in a before(:each) block' unless instance_variable_get('@countable')

    @statements = RDF::Spec.quads

    if @countable.empty?
      if @countable.respond_to?(:<<) && (@countable.writable? rescue true)
        @statements.each { |statement| @countable << statement }
      else
        raise "+@countable+ must respond to #<< or be pre-populated with the statements in #{RDF::Spec::TRIPLES_FILE} in a before(:each) block"
      end
    end
  end

  describe RDF::Countable do
    subject {@countable}

    it {should respond_to(:empty?)}
    it {should_not be_empty}
    it {should respond_to(:count)}
    its(:count) {should == @statements.size}
    it {should respond_to(:size)}
    its(:size) {should == @statements.size}

    context "when empty" do
      subject {[].extend(RDF::Countable)}
      it {should be_empty}
      its(:count) {should == 0}
      its(:size) {should == 0}
    end

    its(:to_enum) {should be_countable}
    its(:enum_for) {should be_countable}
    it "#enum_for(:each)" do
      subject.enum_for(:each).should be_countable
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-spec-1.1.0.p3 lib/rdf/spec/countable.rb
rdf-spec-1.0.7 lib/rdf/spec/countable.rb
rdf-spec-1.1.0.p2 lib/rdf/spec/countable.rb
rdf-spec-1.0.6 lib/rdf/spec/countable.rb