Skip to content

Commit

Permalink
Restore storage spec
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranza committed Sep 22, 2015
1 parent bc1c685 commit 7eaf6df
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions spec/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,37 @@
)
end

# context "with a valid gem folder" do

# before do
# @gem_folder = Dir.mktmpdir
# end

# let(:storage) { Gemstash::GemStorage.new(@gem_folder) }
# let(:gem_name) { "my_gem-1.8.1.gem" }
# let(:gem_headers) { Hash.new("CONTENT-TYPE" => "octet/stream") }
# let(:gem_content) { "sentinel content" }

# after do
# FileUtils.remove_entry @gem_folder
# end

# it "returns a valid non-existing gem with a new gem" do
# expect(storage.get(gem_name)).not_to exist
# end

# it "can retrieve a stored gem by name including headers and the content" do
# storage.get(gem_name).save(gem_headers, gem_content)
# cached_gem = storage.get(gem_name)
# expect(cached_gem.content).to eq(gem_content)
# expect(cached_gem.headers).to eq(gem_headers)
# end

# it "can replace the content of the gem" do
# storage.get(gem_name).save(gem_headers, gem_content)
# storage.get(gem_name).save(gem_headers, "new content")
# cached_gem = storage.get(gem_name)
# expect(cached_gem.content).to eq("new content")
# expect(cached_gem.headers).to eq(gem_headers)
# end
# end
context "with a valid gem folder" do
before do
@gem_folder = Dir.mktmpdir
end

let(:storage) { Gemstash::GemStorage.new(@gem_folder) }
let(:gem_name) { "my_gem-1.8.1.gem" }
let(:gem_headers) { Hash.new("CONTENT-TYPE" => "octet/stream") }
let(:gem_content) { "sentinel content" }

after do
FileUtils.remove_entry @gem_folder
end

it "returns a valid non-existing gem with a new gem" do
expect(storage.get(gem_name)).not_to exist
end

it "can retrieve a stored gem by name including headers and the content" do
storage.get(gem_name).save(gem_headers, gem_content)
cached_gem = storage.get(gem_name)
expect(cached_gem.content).to eq(gem_content)
expect(cached_gem.headers).to eq(gem_headers)
end

it "can replace the content of the gem" do
storage.get(gem_name).save(gem_headers, gem_content)
storage.get(gem_name).save(gem_headers, "new content")
cached_gem = storage.get(gem_name)
expect(cached_gem.content).to eq("new content")
expect(cached_gem.headers).to eq(gem_headers)
end
end
end

0 comments on commit 7eaf6df

Please sign in to comment.