Sha256: f91d386813d4fd6d5d6ad662545529c3346b0f54fe7ebfaffa71cb3bbef161b3

Contents?: true

Size: 957 Bytes

Versions: 8

Compression:

Stored size: 957 Bytes

Contents

require 'spec_helper'
require 'solve/ruby_solver'

describe Solve::Solver::Serializer do

  let(:graph) do
    Solve::Graph.new.tap do |g|
      g.artifact("A", "1.0.0").depends("B", "1.0.0")
      g.artifact("B", "1.0.0").depends("C", "1.0.0")
      g.artifact("C", "1.0.0")
    end
  end

  let(:demands) { [["A", "1.0.0"]] }

  let(:serializer) { Solve::Solver::Serializer.new }

  it "deserializes a serialized problem to an equivalent problem" do
    problem = Solve::Problem.new(graph, demands)
    serialized = serializer.serialize(problem)
    deserialized = serializer.deserialize(serialized)

    problem.graph.should eql(deserialized.graph)
    problem.demands.should eql(deserialized.demands)
  end

  it "creates a problem from a solver" do
    solver = Solve::RubySolver.new(graph, demands)
    problem = Solve::Problem.from_solver(solver)
    expect(problem.demands).to eq([["A", "= 1.0.0"]])
    expect(problem.graph).to eq(graph)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
solve-3.1.1 spec/unit/solve/solver/serializer_spec.rb
solve-3.1.0 spec/unit/solve/solver/serializer_spec.rb
solve-3.0.1 spec/unit/solve/solver/serializer_spec.rb
solve-3.0.0 spec/unit/solve/solver/serializer_spec.rb
solve-2.0.3 spec/unit/solve/solver/serializer_spec.rb
solve-2.0.2 spec/unit/solve/solver/serializer_spec.rb
solve-2.0.1 spec/unit/solve/solver/serializer_spec.rb
solve-2.0.0 spec/unit/solve/solver/serializer_spec.rb