Sha256: c5c049c4995fd8571efeebb5f73a9b1df3b62086f49ac56bf8d73803804c58f7

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'

module Garb
  module Management
    class FeedTest < MiniTest::Unit::TestCase
      context "a Feed" do
        setup do
          @request = stub
          Request::Data.stubs(:new).returns(@request)
          @feed = Feed.new(Garb::Session.new, '/accounts')
        end

        should "have a parsed response" do
          MultiJson.stubs(:load)
          @feed.stubs(:response).returns(stub(:body => 'response body'))
          @feed.parsed_response

          assert_received(MultiJson, :load) {|e| e.with('response body')}
        end

        should "have entries from the parsed response" do
          @feed.stubs(:parsed_response).returns({'items' => ['entry1', 'entry2']})
          assert_equal ['entry1', 'entry2'], @feed.entries
        end

        should "have an empty array for entries without a response" do
          @feed.stubs(:parsed_response).returns(nil)
          assert_equal [], @feed.entries
        end

        should "have a response from the request" do
          @request.stubs(:send_request)
          @feed.response
          assert_received(@request, :send_request)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
garb-0.9.8 test/unit/garb/management/feed_test.rb
garb-0.9.7 test/unit/garb/management/feed_test.rb