Sha256: 87c8d5cbf53651903a4d126b5e9feba41757e1ad51e65f20497b01c12d5435d8

Contents?: true

Size: 1.89 KB

Versions: 12

Compression:

Stored size: 1.89 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe Animoto::Resources::Base do
  
  def define_thing options = {}
    Object.__send__ :remove_const, :Thing if defined?(Thing)
    Object.__send__ :const_set, :Thing, Class.new(Animoto::Resources::Base)
    options.each { |k,v| Thing.__send__(k, v) }
  end

  describe "inferring the content type" do
    it "should be the underscored, lowercase version of the base class name" do
      class Animoto::ThisIsALongAndStupidName < Animoto::Resources::Base; end
      Animoto::ThisIsALongAndStupidName.content_type.should == 'this_is_a_long_and_stupid_name'
    end
  end

  describe "identity mapping" do
    before do
      @url = "https://platform.animoto.com/videos/1"
      @video = Animoto::Resources::Video.new :url => @url
      @body = {
        'response' => {
          'status' => { 'code' => 200 },
          'payload' => {
            'video' => {
              'links' => {
                'download' => "http://animoto.com/videos/1",
                'storyboard' => "https://platform.animoto.com/storyboards/1",
                'self' => @url
              },
              'metadata' => {
                'rendering_parameters' => {
                  'format' => 'h264',
                  'framerate' => 30,
                  'vertical_resolution' => "720p"                  
                }
              }
            }
          }
        }
      }
    end
    
    it "should ensure that two instances instantiated with the same unique identifier will both be the same object" do
      @video.should equal(Animoto::Resources::Video.load(@body))
    end
    
    it "should update the original instance with the initialization parameters of the new one" do
      @video.framerate.should be_nil
      video = Animoto::Resources::Video.load(@body)
      video.framerate.should == 30
      @video.framerate.should == 30
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
animoto-1.5.6 ./spec/animoto/resources/base_spec.rb
animoto-1.5.5 ./spec/animoto/resources/base_spec.rb
animoto-1.5.4 ./spec/animoto/resources/base_spec.rb
animoto-1.5.3 ./spec/animoto/resources/base_spec.rb
animoto-1.5.2 ./spec/animoto/resources/base_spec.rb
animoto-1.5.1 ./spec/animoto/resources/base_spec.rb
animoto-1.5.0 ./spec/animoto/resources/base_spec.rb
animoto-1.3.1 ./spec/animoto/resources/base_spec.rb
animoto-1.3.0 ./spec/animoto/resources/base_spec.rb
animoto-1.2.0 ./spec/animoto/resources/base_spec.rb
animoto-1.1.1 ./spec/animoto/resources/base_spec.rb
animoto-1.1.0 ./spec/animoto/resources/base_spec.rb