spec/demo/spec/spec_utils.rb in kojac-0.12.0 vs spec/demo/spec/spec_utils.rb in kojac-0.13.0

- old
+ new

@@ -16,15 +16,26 @@ read_op ] } request.accept = "application/json" post :receive, format: :json, kojac: content - + result = nil + error = nil output = JSON.parse response.body - output['ops'].should be_is_a Array - output['ops'].length.should == 1 - op = output['ops'].first - result = op['results'][op['result_key']] + if output['error'] + response.status.should >= 400 + output.g?('error.errors').should be_a Array + output.g?('error.kind').should be + output['error']['errors'].length.should >= 1 + error = output['error'] + else + response.status.should == 200 + output['ops'].should be_a Array + output['ops'].length.should >= 1 + op = output['ops'].first + result = op['results'][op['result_key']] + end + [result,error] end # from http://openhood.com/rails/rails%203/2010/07/20/add-routes-at-runtime-rails-3/ def draw_routes(&block) begin