spec/generator/arguments_spec.rb in templater-0.1.6 vs spec/generator/arguments_spec.rb in templater-0.2

- old
+ new

@@ -99,11 +99,11 @@ lambda { instance.monkey = nil }.should raise_error(Templater::TooFewArgumentsError) end it "should assign an argument when a block appended to an argument does not throw :invalid" do - @generator_class.argument(0, :monkey) do + @generator_class.argument(0, :monkey) do |argument| 1 + 1 end @generator_class.argument(1, :elephant) do false end @@ -116,18 +116,22 @@ instance.monkey = :harr instance.monkey.should == :harr end it "should raise an error with the throw message, when a block is appended to an argument and throws :invalid" do - @generator_class.argument(0, :monkey) do - throw :invalid, 'this is not a valid monkey, bad monkey!' + @generator_class.argument(0, :monkey) do |argument| + if argument != 'monkey' + throw :invalid, 'this is not a valid monkey, bad monkey!' + end end lambda { @generator_class.new('/tmp', {}, 'blah') }.should raise_error(Templater::ArgumentError, 'this is not a valid monkey, bad monkey!') instance = @generator_class.new('/tmp') lambda { instance.monkey = :anything }.should raise_error(Templater::ArgumentError, 'this is not a valid monkey, bad monkey!') + + lambda { instance.monkey = 'monkey' }.should_not raise_error end end describe Templater::Generator, '.argument as array' do