Last active
August 29, 2015 14:10
-
-
Save elrayle/647bd8f3fda3baa9ddd2 to your computer and use it in GitHub Desktop.
new - persist! - destroy - persisted? shows resource as persisted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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