Flesh out channel_depth_spec
RSpec.describe Magick::Image, "#channel_depth" do
- it "works" do
- image = described_class.new(20, 20)
-
- expect { image.channel_depth }.not_to raise_error
- expect { image.channel_depth(Magick::RedChannel) }.not_to raise_error
- expect { image.channel_depth(Magick::RedChannel, Magick::BlueChannel) }.not_to raise_error
- expect { image.channel_depth(Magick::GreenChannel, Magick::OpacityChannel) }.not_to raise_error
- expect { image.channel_depth(Magick::MagentaChannel, Magick::CyanChannel) }.not_to raise_error
- expect { image.channel_depth(Magick::CyanChannel, Magick::BlackChannel) }.not_to raise_error
- expect { image.channel_depth(Magick::GrayChannel) }.not_to raise_error
- expect { image.channel_depth(2) }.to raise_error(TypeError)
- expect(image.channel_depth(Magick::RedChannel)).to be_kind_of(Integer)
+ it "returns the depth for the given channel" do
+ image = build_image
+
+ depth = image.channel_depth(Magick::RedChannel)
+
+ expect(depth).to eq(16)
+ end
+
+ it "returns the depth for all channels when no arguments are passed" do
+ image = build_image
+
+ depth = image.channel_depth
+
+ expect(depth).to eq(16)
+ end
+
+ it "raises an error when the wrong type of argument is passed" do
+ image = build_image
+
+ expect { image.channel_depth("test") }
+ .to raise_error(TypeError, "argument must be a ChannelType value (String given)")
end
end
