<commit_before>require 'spec_helper'

describe ActiveService::Errors do
  api = ActiveService::API.setup :url => "https://api.example.com" do |builder|
    builder.use ActiveService::Middleware::ParseJSON
    builder.adapter :test do |stub|
      stub.get("/BadRequest") { |env| [400, {}, { :errors => "BadRequest" }.to_json] }
      stub.get("/UnauthorizedAccess") { |env| [401, {}, { :errors => "UnauthorizedAccess" }.to_json] }
      stub.get("/ResourceNotFound") { |env| [404, {}, { :errors => "ResourceNotFound" }.to_json] }
      stub.get("/TimeoutError") { |env| [408, {}, { :errors => "TimeoutError" }.to_json] }
      stub.get("/ResourceInvalid") { |env| [422, {}, { :errors => "ResourceInvalid" }.to_json] }
      stub.get("/ClientError") { |env| [467, {}, { :errors => "ClientError" }.to_json] }
      stub.get("/ServerError") { |env| [567, {}, { :errors => "ServerError" }.to_json] }
    end
  end
  context 'when a BadRequest error is raised' do
    it "should raise a BadRequest error" do
      expect {
        error = api.request(:_method => :get, :_path => "BadRequest")
      }.to raise_error { |error|
        error.should be_a(ActiveService::Errors::BadRequest)
        error.body.should include(:errors => "BadRequest")
      }
    end
  end
    context 'when a UnauthorizedAccess error is raised' do
    it "should raise a UnauthorizedAccess error" do
      expect {
        error = api.request(:_method => :get, :_path => "UnauthorizedAccess")
      }.to raise_error { |error|
        error.should be_a(ActiveService::Errors::UnauthorizedAccess)
        error.body.should include(:errors => "UnauthorizedAccess")
      }
    end
  end
    context 'when a ResourceNotFound error is raised' do
    it "should raise a ResourceNotFound error" do
      expect {
        error = api.request(:_method => :get, :_path => "ResourceNotFound")
      }.to raise_error { |error|
        error.should be_a(ActiveService::Errors::ResourceNotFound)
        error.body.should include(:errors => "ResourceNotFound")
      }
    end
  end
    context 'when a TimeoutError error is raised' do
    it "should raise a TimeoutError error" do
      expect {
        error = api.request(:_method => :get, :_path => "TimeoutError")
      }.to raise_error { |error|
        error.should be_a(ActiveService::Errors::ClientError)
        error.body.should include(:errors => "TimeoutError")
      }
    end
  end
    context 'when a ResourceInvalid error is raised' do
    it "should raise a ResourceInvalid error" do
      expect {
        error = api.request(:_method => :get, :_path => "ResourceInvalid")
      }.to raise_error { |error|
        error.should be_a(ActiveService::Errors::ResourceInvalid)
        error.body.should include(:errors => "ResourceInvalid")
      }
    end
  end
    context 'when a ClientError error is raised' do
    it "should raise a ClientError error" do
      expect {
        error = api.request(:_method => :get, :_path => "ClientError")
      }.to raise_error { |error|
        error.should be_a(ActiveService::Errors::ClientError)
        error.body.should include(:errors => "ClientError")
      }
    end
  end
    context 'when a ServerError error is raised' do
    it "should raise a ServerError error" do
      expect {
        error = api.request(:_method => :get, :_path => "ServerError")
      }.to raise_error { |error|
        error.should be_a(ActiveService::Errors::ServerError)
        error.body.should include(:errors => "ServerError")
      }
    end
  end
end<commit_msg>Updates syntax in errors spec<commit_after>require 'spec_helper'

describe ActiveService::Errors do
  api = ActiveService::API.setup :url => "https://api.example.com" do |builder|
    builder.use ActiveService::Middleware::ParseJSON
    builder.adapter :test do |stub|
      stub.get("/BadRequest") { |env| [400, {}, { :errors => "BadRequest" }.to_json] }
      stub.get("/UnauthorizedAccess") { |env| [401, {}, { :errors => "UnauthorizedAccess" }.to_json] }
      stub.get("/ResourceNotFound") { |env| [404, {}, { :errors => "ResourceNotFound" }.to_json] }
      stub.get("/TimeoutError") { |env| [408, {}, { :errors => "TimeoutError" }.to_json] }
      stub.get("/ResourceInvalid") { |env| [422, {}, { :errors => "ResourceInvalid" }.to_json] }
      stub.get("/ClientError") { |env| [467, {}, { :errors => "ClientError" }.to_json] }
      stub.get("/ServerError") { |env| [567, {}, { :errors => "ServerError" }.to_json] }
    end
  end
  context 'when a BadRequest error is raised' do
    it "should raise a BadRequest error" do
      expect do
        error = api.request(:_method => :get, :_path => "BadRequest")
      end.to raise_error do |error|
        error.should be_a(ActiveService::Errors::BadRequest)
        error.body.should include(:errors => "BadRequest")
      end
    end
  end
  context 'when a UnauthorizedAccess error is raised' do
    it "should raise a UnauthorizedAccess error" do
      expect do
        error = api.request(:_method => :get, :_path => "UnauthorizedAccess")
      end.to raise_error do |error|
        error.should be_a(ActiveService::Errors::UnauthorizedAccess)
        error.body.should include(:errors => "UnauthorizedAccess")
      end
    end
  end
  context 'when a ResourceNotFound error is raised' do
    it "should raise a ResourceNotFound error" do
      expect do
        error = api.request(:_method => :get, :_path => "ResourceNotFound")
      end.to raise_error do |error|
        error.should be_a(ActiveService::Errors::ResourceNotFound)
        error.body.should include(:errors => "ResourceNotFound")
      end
    end
  end
  context 'when a TimeoutError error is raised' do
    it "should raise a TimeoutError error" do
      expect do
        error = api.request(:_method => :get, :_path => "TimeoutError")
      end.to raise_error do |error|
        error.should be_a(ActiveService::Errors::ClientError)
        error.body.should include(:errors => "TimeoutError")
      end
    end
  end
  context 'when a ResourceInvalid error is raised' do
    it "should raise a ResourceInvalid error" do
      expect do
        error = api.request(:_method => :get, :_path => "ResourceInvalid")
      end.to raise_error do |error|
        error.should be_a(ActiveService::Errors::ResourceInvalid)
        error.body.should include(:errors => "ResourceInvalid")
      end
    end
  end
  context 'when a ClientError error is raised' do
    it "should raise a ClientError error" do
      expect do
        error = api.request(:_method => :get, :_path => "ClientError")
      end.to raise_error do |error|
        error.should be_a(ActiveService::Errors::ClientError)
        error.body.should include(:errors => "ClientError")
      end
    end
  end
  context 'when a ServerError error is raised' do
    it "should raise a ServerError error" do
      expect do
        error = api.request(:_method => :get, :_path => "ServerError")
      end.to raise_error do |error|
        error.should be_a(ActiveService::Errors::ServerError)
        error.body.should include(:errors => "ServerError")
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13342736248236953, 'fraction_numerical': 0.005923836389280677, 'mean_word_length': 3.0636103151862466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 61, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3056322', 'n_tokens_mistral': 2116, 'n_tokens_neox': 2096, 'n_words': 582}