Skip to content

Instantly share code, notes, and snippets.

@danielsdeleo
Created September 22, 2009 02:12
Show Gist options
  • Select an option

  • Save danielsdeleo/190733 to your computer and use it in GitHub Desktop.

Select an option

Save danielsdeleo/190733 to your computer and use it in GitHub Desktop.
it "accepts a block for a callback (hook) attribute" do
block = lambda { p :noop }
lambda {@resource.send(:validate_callback_attribute, &block)}.should_not raise_error
end
it "accepts a proc for a callback (hook) attribute" do
proc = lambda { p :noop }
lambda {@resource.send(:validate_callback_attribute, proc)}.should_not raise_error
end
it "accepts a hash of the form :eval => 'filename' for a callback attribute" do
lambda {@resource.send(:validate_callback_attribute, {:eval => 'filename'})}.should_not raise_error
end
it "accepts a hash of the form :recipe => 'filename' for a callback attribute" do
lambda {@resource.send(:validate_callback_attribute, {:recipe => 'filename'})}.should_not raise_error
end
it "rejects a hash with a key other than :recipe or :eval for a callback attribute" do
lambda {@resource.send(:validate_callback_attribute, {:fail=>:me})}.should raise_error(ArgumentError)
end
it "rejects a hash with more than one key for a callback attribute" do
lambda {@resource.send(:validate_callback_attribute, {:recipe=>"r",:eval=>"code"})}.should raise_error(ArgumentError)
end
it "rejects a hash with a non-string value for a callback attribute" do
lambda {@resource.send(:validate_callback_attribute, {:eval => 42})}.should raise_error(ArgumentError)
end
it "rejects an value that is not in [Hash,Proc,Block] for a callback attribute" do
lambda {@resource.send(:validate_callback_attribute, "ucanhaz fail")}.should raise_error(ArgumentError)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment