Sha256: 8f7628e2d0cbeabab8257c9ba921bbaac759851959befc974a9293ae78ace0f9
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper_lite' require 'leadlight/link' module Leadlight describe Link do subject { Link.new(service, href, rel, title, options) } let(:service) { stub(:service, get: nil) } let(:href) { '/TEST_PATH' } let(:rel) { 'TEST_REL' } let(:title) { 'TEST_TITLE' } let(:options) { {} } describe '#follow' do it 'calls service.get with the href' do service.should_receive(:get_representation!).with(Addressable::URI.parse(href)) subject.follow end it 'returns the result of the get' do request = stub result = stub service.should_receive(:get_representation!). and_yield(result). and_return(request) subject.follow.should equal(result) end end def self.delegates_to_service(method_name) it "delegates ##{method_name} to the service" do yielded = :nothing args = [:foo, :bar] request = stub(:request) representation = stub(:representation) service.should_receive(method_name). with(subject.href, *args). and_yield(representation). and_return(request) subject.public_send(method_name, *args) do |rep| yielded = rep end.should equal(request) end end delegates_to_service :get delegates_to_service :post delegates_to_service :head delegates_to_service :options delegates_to_service :put delegates_to_service :delete delegates_to_service :patch end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
leadlight-0.0.5 | spec/leadlight/link_spec.rb |
leadlight-0.0.4 | spec/leadlight/link_spec.rb |
leadlight-0.0.3 | spec/leadlight/link_spec.rb |
leadlight-0.0.2 | spec/leadlight/link_spec.rb |