Sha256: 02f4b3b326b23269a24a2135e22c1a2e2fd5deb1ccf6fa2d7b23d2c9a14a6cae
Contents?: true
Size: 1.42 KB
Versions: 7
Compression:
Stored size: 1.42 KB
Contents
require 'rdf/spec' share_as :RDF_Countable do include RDF::Spec::Matchers before :each do raise '+@countable+ must be defined in a before(:each) block' unless instance_variable_get('@countable') @filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt')) @statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a if @countable.empty? if @countable.respond_to?(:<<) @statements.each { |statement| @countable << statement } else raise "+@countable+ must respond to #<< or be pre-populated with the statements in #{@filename} in a before(:each) block" end end end describe "when counting items" do it "responds to #empty?" do @countable.should respond_to(:empty?) end it "responds to #count and #size" do @countable.should respond_to(:count, :size) end it "implements #empty?" do ([].extend(RDF::Countable)).empty?.should be_true ([42].extend(RDF::Countable)).empty?.should be_false @countable.empty?.should be_false end it "implements #count and #size" do %w(count size).each do |method| @countable.send(method).should == @statements.size end end it "returns countable enumerators" do @countable.to_enum.should be_countable @countable.enum_for.should be_countable @countable.enum_for(:each).should be_countable end end end
Version data entries
7 entries across 7 versions & 1 rubygems