Skip to content

Commit

Permalink
Add undo integration spec
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexParamonov committed May 11, 2014
1 parent 545b347 commit e30f951
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/undo/storage/rails_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def store(uuid, object, options = {})
end

def fetch(uuid, options = {})
raise KeyError, "key #{uuid} not found" unless cache.exist? uuid
unpack cache.read uuid, adapter_options(options)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/undo/storage/rails_cache_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
it "deletes stored data" do
subject.store 123, "hello" => "world"
subject.delete 123
expect(subject.fetch 123).to be_nil
expect { subject.fetch 123 }.to raise_error(KeyError)
end

it "uses Rails.cache by default" do
Expand Down
10 changes: 5 additions & 5 deletions spec/undo/storage/rails_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

describe Undo::Storage::RailsCache do
subject { described_class.new cache }
let(:cache) { double :cache }

it "does not raise when created without arguments" do
expect { described_class.new }.not_to raise_error
end
let(:cache) { double :cache, exist?: true }

it "uses provided cache storage" do
subject = described_class.new cache
Expand All @@ -16,6 +12,10 @@
subject.store "foo", "bar"
end

it "does not raise when created without arguments" do
expect { described_class.new }.not_to raise_error
end

describe "default options" do
subject { described_class.new cache, options }
let(:options) { { additional: :option } }
Expand Down
10 changes: 10 additions & 0 deletions spec/undo/undo_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "spec_helper_rails"
require_relative '../../../undo/integration/shared_undo_integration_examples.rb'

Undo.configure do |config|
config.storage = Undo::Storage::RailsCache.new
end

describe Undo do
include_examples "undo integration"
end

0 comments on commit e30f951

Please sign in to comment.