Sha256: 4e210811201b3313c7c2e3a04af209f9b8915dc4b6a59ef3e35a25e43b5347d8

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require 'net/http'
require File.expand_path('../fixtures/classes', __FILE__)

describe "Net::HTTPHeader#each_value" do
  before(:each) do
    @headers = NetHTTPHeaderSpecs::Example.new
    @headers["My-Header"] = "test"
    @headers.add_field("My-Other-Header", "a")
    @headers.add_field("My-Other-Header", "b")
  end

  describe "when passed a block" do
    it "yields each header entry's joined values" do
      res = []
      @headers.each_value do |value|
        res << value
      end
      res.sort.should == ["a, b", "test"]
    end
  end

  describe "when passed no block" do
    ruby_version_is "" ... "1.8.7" do
      it "raises a LocalJumpError" do
        lambda { @headers.each_value }.should raise_error(LocalJumpError)
      end
    end

    # TODO: This should return an Enumerator and not raise an Error
    ruby_version_is "1.8.7" do
      ruby_bug "http://redmine.ruby-lang.org/issues/show/447", "1.8.7" do
        it "returns an Enumerator" do
          enumerator = @headers.each_value
          enumerator.should be_an_instance_of(enumerator_class)

          res = []
          enumerator.each do |key|
            res << key
          end
          res.sort.should == ["a, b", "test"]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysl-net-http-1.0.1 spec/httpheader/each_value_spec.rb
rubysl-net-http-2.0.4 spec/httpheader/each_value_spec.rb
rubysl-net-http-1.0.0 spec/httpheader/each_value_spec.rb