Skip to content

Instantly share code, notes, and snippets.

@elrayle
Last active August 29, 2015 14:10
Show Gist options
  • Save elrayle/647bd8f3fda3baa9ddd2 to your computer and use it in GitHub Desktop.
Save elrayle/647bd8f3fda3baa9ddd2 to your computer and use it in GitHub Desktop.
new - persist! - destroy - persisted? shows resource as persisted
require 'spec_helper'
describe ActiveTriples::Resource do
describe '#destroy' do
before do
class DummyResource < ActiveTriples::Resource
configure :type => RDF::URI('http://example.org/SomeClass'),
:base_uri => 'http://example.org/dummy/',
:repository => :default
property :title, :predicate => RDF::DC.title
end
end
after do
Object.send(:remove_const, "DummyResource") if Object
end
context "when resource is persisted" do
it "should change persisted marker to false when destroyed" do
r = DummyResource.new('dr123') # create and persist
expect(r).not_to be_persisted
r.persist!
expect(r).to be_persisted
r1 = DummyResource.new('dr123') # read from persistent store
expect(r1).to be_persisted
r.destroy
r2 = DummyResource.new('dr123') # no longer in persistent store, so create
expect(r2).not_to be_persisted
expect(r).not_to be_persisted # TEST FAILS HERE
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment