Sha256: b1eb9de027da21d8468c99463c846386910d497f9395a699576e6870bb40ebaf

Contents?: true

Size: 906 Bytes

Versions: 12

Compression:

Stored size: 906 Bytes

Contents

require File.expand_path('../../test_helper', __FILE__)

module Loquor
  class ApiCall::ShowTest < Minitest::Test

    class NormalResource < Resource
      self.path = '/normal'
    end

    class CachedResource < Resource
      self.path = '/cached'
      self.cache = true      
    end

    def test_request_correct_path
      show = ApiCall::Show.new(NormalResource, 42)
      Loquor.expects(:get).with('/normal/42').returns({}.to_json)
      show.execute
    end
    
    def test_request_correct_path_for_cachable_resources
      show = ApiCall::Show.new(CachedResource, 42)
      Loquor.expects(:get).with('/cached/42', cache=true).returns({}.to_json)
      show.execute
    end

    def test_response_is_a_representation
      show = ApiCall::Show.new(Resource, 1)
      Loquor.stubs(get: {foo: 'bar'}.to_json)
      response = show.execute
      assert response.is_a?(Resource)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
loquor-1.4.0 test/api_calls/show_test.rb
loquor-1.3.0 test/api_calls/show_test.rb
loquor-1.2.1 test/api_calls/show_test.rb
loquor-1.2.0 test/api_calls/show_test.rb
loquor-1.1.1 test/api_calls/show_test.rb
loquor-1.1.0 test/api_calls/show_test.rb
loquor-1.0.0 test/api_calls/show_test.rb
loquor-0.9.0 test/api_calls/show_test.rb
loquor-0.8.0 test/api_calls/show_test.rb
loquor-0.7.0 test/api_calls/show_test.rb
loquor-0.6.0 test/api_calls/show_test.rb
loquor-0.5.4 test/api_calls/show_test.rb