Sha256: d74dab9baf5405fe340e9ef343cc6df22ab48e90ca448da68a4c30cfa717223d

Contents?: true

Size: 1.92 KB

Versions: 7

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe MediaMagick::Video::Parser do
  describe 'youtube' do
    describe 'valid?' do
      context 'with a valid url' do
        subject { MediaMagick::Video::Parser.new('youtube.com/watch?v=FfUHkPf9D9k') }

        it { should be_valid }
      end

      context 'with a invalid url' do
        subject { MediaMagick::Video::Parser.new('youtube.com') }

        it { should_not be_valid }
      end
    end

    describe '#to_image' do
      it 'should return a file with video image' do
        video = MediaMagick::Video::Parser.new('youtube.com/watch?v=FfUHkPf9D9k')

        video.to_image.should be_instance_of(File)
      end
    end

    describe '#to_html' do
      it 'should return video html' do
        video = MediaMagick::Video::Parser.new('youtube.com/watch?v=FfUHkPf9D9k')

        video.to_html.should eq('<iframe width="560" height="315" src="http://www.youtube.com/embed/FfUHkPf9D9k" frameborder="0" allowfullscreen></iframe>')
      end
    end
  end

  describe 'vimeo' do
    describe 'valid?' do
      context 'with a valid url' do
        subject { MediaMagick::Video::Parser.new('vimeo.com/44539044') }

        it { should be_valid }
      end

      context 'with a invalid url' do
        subject { MediaMagick::Video::Parser.new('vimeo.com') }

        it { should_not be_valid }
      end
    end

    describe '#to_image' do
      it 'should return a file with video image' do
        video = MediaMagick::Video::Parser.new('vimeo.com/44539044')

        video.to_image.should be_instance_of(File)
      end
    end

    describe '#to_html' do
      it 'should return video html' do
        video = MediaMagick::Video::Parser.new('vimeo.com/44539044')

        video.to_html.should eq('<iframe src="http://player.vimeo.com/video/44539044?title=0&byline=0&portrait=0" width="500" height="341" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
media_magick-0.4.1 spec/lib/media_magick/video/parser_spec.rb
media_magick-0.4.0 spec/lib/media_magick/video/parser_spec.rb
media_magick-0.3.3 spec/lib/media_magick/video/parser_spec.rb
media_magick-0.3.2 spec/lib/media_magick/video/parser_spec.rb
media_magick-0.3.0 spec/lib/media_magick/video/parser_spec.rb
media_magick-0.2.0 spec/lib/media_magick/video/parser_spec.rb
media_magick-0.1.1 spec/lib/media_magick/video/parser_spec.rb