diff --git a/lib/cache_file_store.rb b/lib/cache_file_store.rb index ad14b273..149788e8 100644 --- a/lib/cache_file_store.rb +++ b/lib/cache_file_store.rb @@ -13,7 +13,7 @@ class CacheFileStore # The serializer must have the 2 methods .load and .dump (Marshal and YAML have them) # YAML is Human Readable, contrary to Marshal which store in a binary format # Marshal does not need any "require" - def initialize(storage_path, serializer = YAML) + def initialize(storage_path, serializer = Marshal) @storage_path = File.expand_path(storage_path) @serializer = serializer diff --git a/spec/lib/browser_spec.rb b/spec/lib/browser_spec.rb index f88e5cbb..e93dec50 100644 --- a/spec/lib/browser_spec.rb +++ b/spec/lib/browser_spec.rb @@ -300,13 +300,13 @@ describe Browser do end end - describe "testing UTF8" do - it "should not throw an encoding exception" do - url = SPEC_FIXTURES_DIR + "/utf8.html" - stub_request(:get, url).to_return(:status => 200, :body => File.read(url)) - response1 = @browser.get(url) - response1.body - end + describe "testing UTF8" do + it "should not throw an encoding exception" do + url = SPEC_FIXTURES_DIR + "/utf8.html" + stub_request(:get, url).to_return(:status => 200, :body => File.read(url)) + response1 = @browser.get(url) + expect { response1.body }.to_not raise_error end end +end diff --git a/spec/lib/cache_file_store_spec.rb b/spec/lib/cache_file_store_spec.rb index d44dd453..44defd43 100644 --- a/spec/lib/cache_file_store_spec.rb +++ b/spec/lib/cache_file_store_spec.rb @@ -23,9 +23,9 @@ describe CacheFileStore do end describe "#serializer" do - it "should return the default serializer : YAML" do - @cache.serializer.should == YAML - @cache.serializer.should_not == Marshal + it "should return the default serializer : Marshal" do + @cache.serializer.should == Marshal + @cache.serializer.should_not == YAML end end @@ -48,21 +48,27 @@ describe CacheFileStore do end end - describe "#write_entry, #read_entry (string)" do - it "should get the same entry" do - cache_timeout = 10 - @cache.write_entry('some_key', 'Hello World !', cache_timeout) - @cache.read_entry('some_key').should == 'Hello World !' - end - end + describe "#write_entry, #read_entry" do - ## TODO write / read for an object - - describe "#write_entry with cache_timeout = 0" do - it "the entry should not be written" do - cache_timeout = 0 - @cache.write_entry('another_key', 'Another Hello World !', cache_timeout) - @cache.read_entry('another_key').should be_nil + after :each do + @cache.write_entry(@key, @data, @timeout) + @cache.read_entry(@key).should === @expected end + + it "should get the correct entry (string)" do + @timeout = 10 + @key = "some_key" + @data = "Hello World !" + @expected = @data + end + + it "should not write the entry" do + @timeout = 0 + @key = "another_key" + @data = "Another Hello World !" + @expected = nil + end + + ## TODO write / read for an object end end