Sha256: 29930d431a93636dc47ace6d5bea3dadbff14c2c5a1a2d1b3e9f76aa0301bc23
Contents?: true
Size: 1.36 KB
Versions: 5
Compression:
Stored size: 1.36 KB
Contents
require_relative '../test_helper' require_relative '../resource_test' module MeducationSDK class EcommerceProductTest < ResourceTest test_resource(EcommerceProduct, '/ecommerce_products') def setup super @collection = MeducationSDK::Collection.new({id: 1, slug: "funky_professor"}) end def test_item_calls_sdk_when_known_type product = EcommerceProduct.new(item_id: 3, item_type: "Collection") MeducationSDK::Collection.expects(:find).with(3).returns(@collection) assert_equal @collection, product.item end def test_item_raises_error_when_unknown_type product = EcommerceProduct.new(item_id: 3, item_type: "UnknownType") assert_raises NameError do product.item end end def test_collection_returns_when_item_a_collection product = EcommerceProduct.new(item_id: 3, item_type: "Collection") MeducationSDK::Collection.expects(:find).with(3).returns(@collection) assert_equal @collection, product.collection end def test_collection_raises_error_when_item_not_a_collection media_file = MeducationSDK::MediaFile.new({id: 1}) product = EcommerceProduct.new(item_id: 3, item_type: "MediaFile") MeducationSDK::MediaFile.expects(:find).with(3).returns(media_file) assert_raises MeducationSDKError do product.collection end end end end
Version data entries
5 entries across 5 versions & 1 rubygems