Sha256: dfa2971b8b725d4497388c158b9c01ff6d789d7799caf51bd7c8468f884ffba1

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

require 'rdf/spec'

# To use RDF::Durable to check that a repository maintains information between
# instantiations, add a Proc that creates a repository before each item, and
# clean that up after every run.  Example:
#describe RDF::DataObjects::Repository do
#  context "The SQLite adapter" do
#    before :each do
#      @repository = RDF::DataObjects::Repository.new "sqlite3://:memory:"
#      @load_durable = lambda { RDF::DataObjects::Repository.new "sqlite3:test.db" }
#    end
#
#    after :each do
#      File.delete('test.db') if File.exists?('test.db')
#    end
#
#    it_should_behave_like RDF_Repository
#  end
#end
share_as :RDF_Durable do
  include RDF::Spec::Matchers

  before :each do
    raise '+@load_durable+ must be defined in a before(:each) block' unless instance_variable_get('@load_durable')
    # RDF::Queryable cares about the contents of this file too much to let someone set it
    @filename   = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
  end


  it "should support #durable?" do
    @load_durable.call.should respond_to(:durable?)
    [true,false].member?(@load_durable.call.durable?).should be_true
  end

  it "should support #nondurable?" do
    @load_durable.call.should respond_to(:nondurable?)
    [true,false].member?(@load_durable.call.nondurable?).should be_true
  end

  it "should not be both durable and nondurable" do
    @load_durable.call.nondurable?.should_not == @load_durable.call.durable?
  end

  it "should save contents between instantiations" do
    if @load_durable.call.durable?
      @load_durable.call.load(@filename)
      @load_durable.call.count.should == File.readlines(@filename).size
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-spec-0.3.8 lib/rdf/spec/durable.rb
rdf-spec-0.3.7 lib/rdf/spec/durable.rb
rdf-spec-0.3.5.1 lib/rdf/spec/durable.rb
rdf-spec-0.3.5 lib/rdf/spec/durable.rb