From 2def44f62eacfeec9624b9595a1793576c15b0f4 Mon Sep 17 00:00:00 2001 From: Alex Dubovskoy Date: Sat, 7 Jun 2014 19:47:11 +0400 Subject: [PATCH] cleanup --- spec/lib/topo_sort_spec.rb | 50 +++++++++----------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/spec/lib/topo_sort_spec.rb b/spec/lib/topo_sort_spec.rb index 8b57f57..869707e 100644 --- a/spec/lib/topo_sort_spec.rb +++ b/spec/lib/topo_sort_spec.rb @@ -4,72 +4,44 @@ it "should sort nothing" do nodes = {} sorted = TopoSort.sort(nodes) - sorted.should == [] + expect(sorted).to match_array([]) end it "should sort one node without dependencies" do - nodes = { - a: nil - } + nodes = { :a => nil } sorted = TopoSort.sort(nodes) - sorted.should == [:a] + expect(sorted).to match_array([:a]) end it "should sort several nodes without dependencies" do - nodes = { - a: nil, - b: nil, - c: nil - } + nodes = { :a => nil, :b => nil, :c => nil } sorted = TopoSort.sort(nodes) - sorted.should == [:a, :b, :c] + expect(sorted).to match_array([:a, :b, :c]) end it "should sort several nodes with one that has dependency" do - nodes = { - a: nil, - b: :c, - c: nil - } + nodes = { :a => nil, :b => :c, :c => nil } sorted = TopoSort.sort(nodes) - sorted.should == [:a, :c, :b] + expect(sorted).to match_array([:a, :c, :b]) end it "should sort several nodes with several nodes that have dependency" do - nodes = { - a: nil, - b: :c, - c: :f, - d: :a, - e: :b, - f: nil - } + nodes = { :a => nil, :b => :c, :c => :f, :d => :a, :e => :b, :f => nil } sorted = TopoSort.sort(nodes) - sorted.should == [:a, :f, :c, :b, :d, :e] + expect(sorted).to match_array([:a, :f, :c, :b, :d, :e]) end it "should raise error when node depends on themselve" do - nodes = { - a: nil, - b: nil, - c: :c - } + nodes = { :a => nil, :b => nil, :c => :c } expect { TopoSort.sort(nodes) }.to raise_error(TopoSort::SelfDependency, /sort failed: detected self-dependency/) end it "should raise error when circular dependency is presented" do - nodes = { - a: nil, - b: :c, - c: :f, - d: :a, - e: nil, - f: :b - } + nodes = { :a => nil, :b => :c, :c => :f, :d => :a, :e => nil, :f => :b } expect { TopoSort.sort(nodes) }.to raise_error(TopoSort::Cyclic, /sort failed: detected cyclic dependency/) end end