spec/acceptance/solutions_spec.rb in solve-3.1.1 vs spec/acceptance/solutions_spec.rb in solve-4.0.0

- old
+ new

@@ -1,6 +1,6 @@ -require 'spec_helper' +require "spec_helper" describe "Solutions", :gecode do before do Solve.engine = :gecode @@ -10,32 +10,32 @@ graph = Solve::Graph.new graph.artifact("mysql", "2.0.0") graph.artifact("mysql", "1.2.0") graph.artifact("nginx", "1.0.0").depends("mysql", "= 1.2.0") - result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']]) + result = Solve.it!(graph, [["nginx", "= 1.0.0"], ["mysql"]]) result.should eql("nginx" => "1.0.0", "mysql" => "1.2.0") end it "chooses the best artifact for the demands" do graph = Solve::Graph.new graph.artifact("mysql", "2.0.0") graph.artifact("mysql", "1.2.0") graph.artifact("nginx", "1.0.0").depends("mysql", ">= 1.2.0") - result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']]) + result = Solve.it!(graph, [["nginx", "= 1.0.0"], ["mysql"]]) result.should eql("nginx" => "1.0.0", "mysql" => "2.0.0") end it "raises NoSolutionError when a solution cannot be found" do graph = Solve::Graph.new graph.artifact("mysql", "1.2.0") lambda { - Solve.it!(graph, ['mysql', '>= 2.0.0']) + Solve.it!(graph, ["mysql", ">= 2.0.0"]) }.should raise_error(Solve::Errors::NoSolutionError) end it "find the correct solution when backtracking in variables introduced via demands" do graph = Solve::Graph.new @@ -60,13 +60,12 @@ graph.artifact("A", "1.0.1").depends("B", "> 1.0.0") graph.artifact("A", "1.0.1").depends("C", "= 2.1.0") graph.artifact("A", "1.0.2").depends("B", "> 1.0.0") graph.artifact("A", "1.0.2").depends("C", "= 2.0.0") - result = Solve.it!(graph, [['A', '~> 1.0.0'], ['D', ">= 2.0.0"]]) + result = Solve.it!(graph, [["A", "~> 1.0.0"], ["D", ">= 2.0.0"]]) - result.should eql("A" => "1.0.1", "B" => "2.1.0", "C" => "2.1.0", "D" => "2.1.0") end @@ -157,13 +156,13 @@ graph = Solve::Graph.new graph.artifact("bottom", "1.0.0") graph.artifact("middle", "1.0.0").depends("top", "= 1.0.0").depends("middle") - demands = [["bottom", "1.0.0"],["middle", "1.0.0"]] + demands = [["bottom", "1.0.0"], ["middle", "1.0.0"]] - expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error| + expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error| error.should be_a(Solve::Errors::NoSolutionError) } end it "gives an empty solution when there are no demands" do @@ -204,11 +203,11 @@ result = Solve.it!(graph, demands) result.should eql({ "A" => "0.0.0", "B" => "0.0.0", "C" => "0.0.0", - "D" => "0.0.0"}) + "D" => "0.0.0" }) end it "correctly resolves when a resolution exists but it is not the latest" do graph = Solve::Graph.new @@ -244,11 +243,11 @@ result.should eql({ "get-the-old-one" => "1.0.0", "locked-mid-1" => "1.0.0", "locked-mid-2" => "2.0.0", - "old-bottom" => "2.1.0" + "old-bottom" => "2.1.0", }) end describe "when options[:sorted] is true" do describe "with a simple list of dependencies" do @@ -264,11 +263,11 @@ result = Solve.it!(graph, demands, { :sorted => true }) result.should eql([ ["C", "1.0.0"], ["B", "1.0.0"], - ["A", "1.0.0"] + ["A", "1.0.0"], ]) end end # The order that the demands come in determines the order of artifacts @@ -279,18 +278,18 @@ graph.artifact("B", "1.0.0").depends("A", "= 1.0.0") graph.artifact("A", "1.0.0").depends("C", "= 1.0.0") graph.artifact("C", "1.0.0") - demands = [["A"],["B"]] + demands = [["A"], ["B"]] - result = Solve.it!(graph, demands, { :sorted => true } ) + result = Solve.it!(graph, demands, { :sorted => true } ) result.should eql([ ["C", "1.0.0"], ["A", "1.0.0"], - ["B", "1.0.0"] + ["B", "1.0.0"], ]) end end describe "when the solution is cyclic" do @@ -301,10 +300,10 @@ graph.artifact("B", "1.0.0").depends("C", "= 1.0.0") graph.artifact("C", "1.0.0").depends("A", "= 1.0.0") demands = [["A"]] - expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error| + expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error| error.should be_a(Solve::Errors::UnsortableSolutionError) error.unsorted_solution.should eql({ "A" => "1.0.0", "B" => "1.0.0", "C" => "1.0.0",