Sha256: cc4406669aaf1758ca6e7c694768991cf36bb6323770ca1d082ceaac38d1c69b

Contents?: true

Size: 872 Bytes

Versions: 20

Compression:

Stored size: 872 Bytes

Contents

RSpec.describe HTTP::Response::IoBody do
  subject(:body) { described_class.new StringIO.new("Hello, World!") }

  it "has the content" do
    expect(subject.to_s).to eq "Hello, World!"
  end

  context "when body empty" do
    subject(:body) { described_class.new StringIO.new("") }

    it "returns responds to empty? with true" do
      expect(subject).to be_empty
    end
  end

  describe "#readpartial" do
    context "with size given" do
      it "returns only that amount" do
        expect(body.readpartial(4)).to eq "Hell"
      end
    end

    context "without size given" do
      it "returns parts of the content" do
        expect(body.readpartial).to eq "Hello, World!"
      end
    end
  end

  describe "#each" do
    it "yields successive parts of the content" do
      expect { |b| body.each(&b) }.to yield_with_args "Hello, World!"
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
http-0.8.14 spec/lib/http/response/io_body_spec.rb
http-0.8.13 spec/lib/http/response/io_body_spec.rb
http-0.8.12 spec/lib/http/response/io_body_spec.rb
http-0.8.11 spec/lib/http/response/io_body_spec.rb
http-0.8.10 spec/lib/http/response/io_body_spec.rb
http-0.8.9 spec/lib/http/response/io_body_spec.rb
http-0.8.8 spec/lib/http/response/io_body_spec.rb
http-0.8.7 spec/lib/http/response/io_body_spec.rb
http-0.8.6 spec/lib/http/response/io_body_spec.rb
http-0.8.5 spec/lib/http/response/io_body_spec.rb
http-0.8.4 spec/lib/http/response/io_body_spec.rb
http-0.8.3 spec/lib/http/response/io_body_spec.rb
http-0.8.2 spec/lib/http/response/io_body_spec.rb
http-0.8.1 spec/lib/http/response/io_body_spec.rb
http-0.8.0 spec/lib/http/response/io_body_spec.rb
http-0.8.0.pre5 spec/lib/http/response/io_body_spec.rb
http-0.8.0.pre4 spec/lib/http/response/io_body_spec.rb
http-0.8.0.pre3 spec/lib/http/response/io_body_spec.rb
http-0.8.0.pre2 spec/lib/http/response/io_body_spec.rb
http-0.8.0.pre spec/lib/http/response/io_body_spec.rb