<commit_before># encoding: utf-8

require 'spec_helper'

describe Hyperdrive::Endpoint do
  def app
    Hyperdrive::Endpoint
  end

  before do
    sample_api
  end

  after do
    hyperdrive.send(:reset!)
  end

  it "responds to requests" do
    get '/', {}, default_rack_env(hyperdrive.resources[:thing])
    last_response.successful?.must_equal true
  end
end<commit_msg>specs new error() method available to request blocks in the dsl<commit_after># encoding: utf-8

require 'spec_helper'

describe Hyperdrive::Endpoint do
  def app
    Hyperdrive::Endpoint
  end

  before do
    sample_api
  end

  after do
    hyperdrive.send(:reset!)
  end

  it "responds to requests" do
    get '/', {}, default_rack_env(hyperdrive.resources[:thing])
    last_response.successful?.must_equal true
  end

  it "can raise an HTTPError" do
    hyperdrive do
      resource(:thing) do
        request(:get) do
          error(418, "I'M A TEAPOT")
        end
      end
    end
    ->{ get '/', {}, default_rack_env(hyperdrive.resources[:thing]) }.must_raise Hyperdrive::Errors::HTTPError
  end
end
{'fraction_non_alphanumeric': 0.09935602575896964, 'fraction_numerical': 0.004599816007359705, 'mean_word_length': 3.2666666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, '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': '3496224', 'n_tokens_mistral': 357, 'n_tokens_neox': 343, 'n_words': 95}