Sha256: c942165e5c2848704db411b4f350a8e87cc612ec4197f2468e444ac356e22d7a

Contents?: true

Size: 1.6 KB

Versions: 35

Compression:

Stored size: 1.6 KB

Contents

require "yaml"
require "tempfile"
require "spec_helper"
require "expressir/express_exp/parser"
require "expressir/express_exp/cache"

RSpec.describe Expressir::ExpressExp::Cache do
  TEST_VERSION = "0.0.0"

  describe ".to_file" do
    it "exports an object" do
      temp_file = Tempfile.new

      repository = Expressir::Model::Repository.new

      begin
        Expressir::ExpressExp::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)

        size = File.size(temp_file)

        expect(size).to be > 0
      ensure
        temp_file.close
        temp_file.unlink
      end
    end
  end

  describe ".from_file" do
    it "parses a file" do
      temp_file = Tempfile.new

      repository = Expressir::Model::Repository.new

      begin
        Expressir::ExpressExp::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)

        result = Expressir::ExpressExp::Cache.from_file(temp_file, test_overwrite_version: TEST_VERSION)

        expect(result).to be_instance_of(Expressir::Model::Repository)
      ensure
        temp_file.close
        temp_file.unlink
      end
    end

    it "fails parsing a file from a different Expressir version" do
      temp_file = Tempfile.new

      repository = Expressir::Model::Repository.new

      begin
        Expressir::ExpressExp::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)

        expect do
          Expressir::ExpressExp::Cache.from_file(temp_file)
        end.to raise_error(Expressir::ExpressExp::CacheLoadError)
      ensure
        temp_file.close
        temp_file.unlink
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
expressir-0.2.27 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.27-x86_64-linux spec/expressir/express_exp/cache_spec.rb
expressir-0.2.27-x86_64-darwin spec/expressir/express_exp/cache_spec.rb
expressir-0.2.27-x86-mingw32 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.27-x86-linux spec/expressir/express_exp/cache_spec.rb
expressir-0.2.27-x64-mingw32 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.27-arm64-darwin spec/expressir/express_exp/cache_spec.rb
expressir-0.2.26 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.26-x86_64-linux spec/expressir/express_exp/cache_spec.rb
expressir-0.2.26-x86_64-darwin spec/expressir/express_exp/cache_spec.rb
expressir-0.2.26-x86-mingw32 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.26-x86-linux spec/expressir/express_exp/cache_spec.rb
expressir-0.2.26-x64-mingw32 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.26-arm64-darwin spec/expressir/express_exp/cache_spec.rb
expressir-0.2.25 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.25-x86_64-linux spec/expressir/express_exp/cache_spec.rb
expressir-0.2.25-x86_64-darwin spec/expressir/express_exp/cache_spec.rb
expressir-0.2.25-x86-mingw32 spec/expressir/express_exp/cache_spec.rb
expressir-0.2.25-x86-linux spec/expressir/express_exp/cache_spec.rb
expressir-0.2.25-x64-mingw32 spec/expressir/express_exp/cache_spec.rb