Sha256: f552e3518a6d0dd51001fda0e4b0f45bcafae28aa1119b1e919a52a641fd3cce

Contents?: true

Size: 741 Bytes

Versions: 17

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require 'helper'

class Nanoc::Int::StoreTest < Nanoc::TestCase
  class TestStore < Nanoc::Int::Store
    def data
      @data
    end

    def data=(new_data)
      @data = new_data
    end
  end

  def test_delete_and_reload_on_error
    store = TestStore.new('test.db', 1)

    # Create
    store.load
    store.data = { fun: 'sure' }
    store.store

    # Test stored values
    store = TestStore.new('test.db', 1)
    store.load
    assert_equal({ fun: 'sure' }, store.data)

    # Mess up
    File.open('test.db', 'w') do |io|
      io << 'Damn {}#}%@}$^)@&$&*^#@ broken stores!!!'
    end

    # Reload
    store = TestStore.new('test.db', 1)
    store.load
    assert_equal(nil, store.data)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
nanoc-4.8.11 test/base/test_store.rb
nanoc-4.8.10 test/base/test_store.rb
nanoc-4.8.9 test/base/test_store.rb
nanoc-4.8.8 test/base/test_store.rb
nanoc-4.8.7 test/base/test_store.rb
nanoc-4.8.6 test/base/test_store.rb
nanoc-4.8.5 test/base/test_store.rb
nanoc-4.8.4 test/base/test_store.rb
nanoc-4.8.3 test/base/test_store.rb
nanoc-4.8.2 test/base/test_store.rb
nanoc-4.8.1 test/base/test_store.rb
nanoc-4.8.0 test/base/test_store.rb
nanoc-4.7.14 test/base/test_store.rb
nanoc-4.7.13 test/base/test_store.rb
nanoc-4.7.12 test/base/test_store.rb
nanoc-4.7.11 test/base/test_store.rb
nanoc-4.7.10 test/base/test_store.rb