spec/choice_spec.rb in bindata-1.1.0 vs spec/choice_spec.rb in bindata-1.2.0
- old
+ new
@@ -18,16 +18,16 @@
lambda { BinData::Choice.new(args) }.should raise_error(ArgumentError)
end
it "should fail if a given type is unknown" do
args = {:choices => [:does_not_exist], :selection => 0}
- lambda { BinData::Choice.new(args) }.should raise_error(BinData::UnknownTypeError)
+ lambda { BinData::Choice.new(args) }.should raise_error(BinData::UnRegisteredTypeError)
end
it "should fail if a given type is unknown" do
args = {:choices => {0 => :does_not_exist}, :selection => 0}
- lambda { BinData::Choice.new(args) }.should raise_error(BinData::UnknownTypeError)
+ lambda { BinData::Choice.new(args) }.should raise_error(BinData::UnRegisteredTypeError)
end
it "should fail if :choices Hash has a symbol as key" do
args = {:choices => {:a => :example_single}, :selection => 0}
lambda { BinData::Choice.new(args) }.should raise_error(ArgumentError)
@@ -46,9 +46,20 @@
end
it "should show the current selection" do
@chooser.choice = 3
@data.selection.should == 3
+ end
+
+ it "should not be able to directly change the current selection" do
+ lambda {
+ @data.selection = 3
+ }.should raise_error(NoMethodError)
+ end
+
+ it "should forward #snapshot" do
+ @chooser.choice = 3
+ @data.snapshot.should == 30
end
it "should be able to change the choice" do
@chooser.choice = 3