Sha256: f15c343e43fb7e12f704078ac7512ddafa3fd426d76188c39daf82f973ff6f5a

Contents?: true

Size: 966 Bytes

Versions: 22

Compression:

Stored size: 966 Bytes

Contents

require "spec_helper"
require "tempfile"

describe Invoker::Power::HttpResponse do
  before do
    @http_response = Invoker::Power::HttpResponse.new()
  end

  it "should allow user to send a file" do
    begin
      file = Tempfile.new("error.html")
      file_content = "Error message"
      file.write(file_content)
      file.close

      @http_response.use_file_as_body(file.path)
      expect(@http_response.body).to eq(file_content)
      expect(@http_response.http_string).to include(file_content)
    ensure
      file.unlink
    end
  end

  it "should allow user to set headers" do
    @http_response["Content-Type"] = "text/html"
    expect(@http_response.header["Content-Type"]).to eq("text/html")
    expect(@http_response.http_string).to include("Content-Type")
  end

  it "should allow user to set status" do
    @http_response.status = 503
    expect(@http_response.http_string).to include(Invoker::Power::HttpResponse::STATUS_MAPS[503])
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
invoker-1.0.4 spec/invoker/power/http_response_spec.rb
invoker-1.0.3 spec/invoker/power/http_response_spec.rb