Advertisement
ZaBlanc

Kata 8/25 DLL Spec

Aug 25th, 2011
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.90 KB | None | 0 0
  1. require "rspec"
  2. require "color"
  3.  
  4. describe Color do
  5.   it "should stand alone" do
  6.     r = Color.new("red")
  7.  
  8.     r.color.should == "red"
  9.     r.next.should == nil
  10.     r.previous.should == nil
  11.   end
  12.  
  13.   it "should link between two colors" do
  14.     r = Color.new("red")
  15.     o = Color.new("orange")
  16.  
  17.     r.link_to(o)
  18.  
  19.     r.next.should == o
  20.     r.previous.should == nil
  21.     o.previous.should == r
  22.     o.next.should == nil
  23.   end
  24.  
  25.   it "should link a whole rainbow" do
  26.     r = Color.new("red")
  27.     o = Color.new("orange")
  28.     y = Color.new("yellow")
  29.     g = Color.new("green")
  30.     b = Color.new("blue")
  31.     i = Color.new("indigo")
  32.     v = Color.new("violet")
  33.  
  34.     r.link_to(o).link_to(y).link_to(g).link_to(b).link_to(i).link_to(v)
  35.  
  36.     r.next.next.next.next.next.next.color.should match /violet/
  37.     v.previous.previous.previous.previous.previous.previous.color.should match /red/
  38.   end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement