Sha256: 691217d87ba55c34299d7c215308498550ed856dd83f7549b19f51c0ece0bdc9

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

require 'spec_helper'

describe Response, '.build' do
  subject { object.build(&block) }

  let(:object) { described_class }

  context 'without arguments and block' do
    let(:block)   { nil }

    its(:valid?)  { should be(false)               }
    its(:headers) { should eql({})                 }
    its(:status)  { should be(Response::Undefined) }
    its(:body)    { should be(Response::Undefined) }
  end

  context 'with block' do
    let(:yields) { [] }
    let(:value) { double('Value') }
    let(:block) { lambda { |response| yields << response; value } }

    it 'should return value from block' do
      should be(value)
    end

    it 'should call block with response' do
      subject
      yields.should eql([Response.build])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
response-0.0.4 spec/unit/response/class_methods/build_spec.rb