Sha256: 80e07ce7be8160498ade06b5b6f206662ce21597adebce237e212640ef493d96

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require File.expand_path('../test_helper', __FILE__)
module MeducationSDK
  class ResourceTest < Minitest::Test
    def self.test_resource(klass, url)
      define_method :klass do klass end
      define_method :url do url end

      class_eval do
        def test_path
          assert_equal url, klass.path
        end

        def test_generates_find_url
          id = 7
          Loquor::HttpAction::Get.expects(:get).with("#{url}/#{id}", anything())
          klass.find(id)
        end
      end
    end

    {
      "Item::Comment" => Comment,
      "KnowledgeBank::Question" => KnowledgeBankQuestion
    }.each do |meducation_type, sdk_class|
      define_method "test_class_for_#{meducation_type.underscore.gsub("/", "_")}" do
        r = Resource.new({})
        assert_equal sdk_class, r.class_for(meducation_type)
      end
    end

    def test_created_at_is_a_datetime
      resource = Resource.new(created_at: "2014-02-23T23:34:49Z")
      assert resource.created_at.is_a?(DateTime)
      assert_equal DateTime.new(2014, 2, 23, 23, 34, 49), resource.created_at
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meducation_sdk-1.5.1 test/resource_test.rb