Skip to content

Commit

Permalink
Fix the rotate hue tests to return to the same colour
Browse files Browse the repository at this point in the history
  • Loading branch information
wdevauld committed Aug 3, 2011
1 parent 889f15e commit f1bfae0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/colour.rb
Expand Up @@ -27,7 +27,7 @@ def to_s

# Return the complementary colour
def complementary
rotate_hue(180)
rotate_hue(180)[0]
end

# Return two colours spread distance apart opposite
Expand Down
35 changes: 28 additions & 7 deletions spec/support/color_representation.rb
Expand Up @@ -49,17 +49,38 @@
gradient.size.should eql(10)
end

it "should provide a complementary colour"

it "should provide a split complemenatry set of colours"
it "should provide a complementary colour" do
c = green.complementary
c.nil?.should eql(false)
c.hex.should eql(0xFF00FF)
end

it "should apply a block when generating a split complementary set of colours if one is provided"
it "should provide a split complementary set of colours" do
colours = green.split_complementary
colours.size.should eql(2)
colours[0].hex.should eql(0x7F00FF)
colours[1].hex.should eql(0xFF007F)
end

it "should provide a series of colours rotating around the Hue wheel"

it "should apply a block to the colours when generating the colours around the colour wheel if one is provided"
it "should apply a block when generating a split complementary set of colours if one is provided" do
i = 0
#TODO it would be nice to use the .should_recieve(:blah).and_yeild(:check)
# but because this is a shared test, one time we will get RGB, another we get HSV
green.split_complementary do |c|
if c.hex == 0x7F00FF or c.hex == 0xFF007F then
i += 1
end
end
i.should eql(2)
end

it "should generate triadic colours"
it "should provide a series of colours rotating around the Hue wheel" do
colours = green.rotate_hue(degrees = 36, steps = 11)
colours.size.should eql(11)
colours[0].hex.should eql(colours[10].hex)
colours[4].hex.should eql(0xFF00FF)
end
end


0 comments on commit f1bfae0

Please sign in to comment.