Sha256: 76484c19c71210c818685e79aa073603fbfb5d4a3dea891d106584db30ce9155
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
require 'rdf/spec' require '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 context "when counting items" do it "should respond to #empty?" do @countable.should respond_to(:empty?) end it "should respond to #count and #size" do @countable.should respond_to(*%w(count size)) end it "should implement #empty?" do ([].extend(RDF::Countable)).empty?.should be_true @countable.empty?.should be_false end it "should implement #count and #size" do %w(count size).each do |method| @countable.send(method).should == @statements.size end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rdf-spec-0.2.2 | lib/rdf/spec/countable.rb |
rdf-spec-0.2.1 | lib/rdf/spec/countable.rb |
rdf-spec-0.2.0 | lib/rdf/spec/countable.rb |