From 0c8576eceae3d68ae10e29bdc849cc8b3fd30522 Mon Sep 17 00:00:00 2001 From: John Croisant Date: Mon, 7 Feb 2011 14:54:26 -0600 Subject: [PATCH] Added some negative specs for Surface#opacity=. --- spec/surface_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/surface_spec.rb b/spec/surface_spec.rb index 7b7eedb7..36604eb5 100644 --- a/spec/surface_spec.rb +++ b/spec/surface_spec.rb @@ -1292,6 +1292,20 @@ @surface.opacity(2) @surface.opacity.should eql( 1.0 ) end + + invalid_args = { + "true" => true, + "a symbol" => :symbol, + "an array" => [1.0], + "a hash" => {1=>2}, + "some object" => Object.new, + } + + invalid_args.each do |thing, arg| + it "should fail when given #{thing}" do + expect{@surface.opacity(arg)}.to raise_error + end + end end end @@ -1330,4 +1344,17 @@ @surface.opacity.should eql( 1.0 ) end + invalid_args = { + "true" => true, + "a symbol" => :symbol, + "an array" => [1.0], + "a hash" => {1=>2}, + "some object" => Object.new, + } + + invalid_args.each do |thing, arg| + it "should fail when given #{thing}" do + expect{@surface.opacity = arg}.to raise_error + end + end end