spec/integration/valid_spec.rb in goliath-0.9.1 vs spec/integration/valid_spec.rb in goliath-0.9.2

- old
+ new

@@ -1,6 +1,7 @@ require 'spec_helper' +require 'json' require File.join(File.dirname(__FILE__), '../../', 'examples/valid') describe Valid do let(:err) { Proc.new { fail "API request failed" } } @@ -18,5 +19,25 @@ c.response.should == '[:error, "Test identifier missing"]' end end end end + +class ValidationErrorInEndpoint < Goliath::API + def response(env) + raise Goliath::Validation::Error.new(420, 'You Must Chill') + end +end + +describe ValidationErrorInEndpoint do + let(:err) { Proc.new { fail "API request failed" } } + + it 'handles Goliath::Validation::Error correctly' do + with_api(ValidationErrorInEndpoint) do + get_request({}, err) do |c| + c.response.should == '[:error, "You Must Chill"]' + c.response_header.status.should == 420 + end + end + end +end +