Permalink
Browse files

Test for validation error handling

  • Loading branch information...
1 parent 6b0559e commit b7ab2e9bda0e02a8ec488dc569a0d2884edd476a @pengwynn pengwynn committed Oct 28, 2012
Showing with 23 additions and 0 deletions.
  1. +11 −0 spec/fixtures/v3/validation_failed.json
  2. +12 −0 spec/octokit/client_spec.rb
@@ -0,0 +1,11 @@
+{
+ "errors": [
+ {
+ "field": "name",
+ "message": "name is too short (minimum is 1 characters)",
+ "code": "custom",
+ "resource": "Repository"
+ }
+ ],
+ "message": "Validation Failed"
+}
@@ -152,5 +152,17 @@
end
end
+ describe "error handling" do
+
+ it "displays validation errors" do
+ stub_patch("https://foo:bar@api.github.com/repos/pengwynn/api-sandbox").
+ to_return(:body => fixture("v3/validation_failed.json"))
+
+ response = Octokit::Client.new(:login => 'foo', :password => 'bar').update_repository('pengwynn/api-sandbox')
+ expect(response.errors.first.message).to eq('name is too short (minimum is 1 characters)')
+ end
+
+ end
+
end

0 comments on commit b7ab2e9

Please sign in to comment.