Sha256: f3460c302b7ffb66ea9fcfd59c98efd6c084609a4764a3296634474c759873c3

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# coding: BINARY

require "flv/tag"
require "stringio"

describe FLV::Tag do
  describe ".read" do
    let(:io) { StringIO.new(string) }

    context "reading a metadata tag" do
      let(:string) { "\x12" }

      it "creates a FLV::Tag::Data" do
        FLV::Tag::Data.should_receive(:new).with(io)
        FLV::Tag.read(io)
      end
    end

    context "reading an audio tag" do
      let(:string) { "\x08" }

      it "creates a FLV::Tag::Data" do
        FLV::Tag::Audio.should_receive(:new).with(io)
        FLV::Tag.read(io)
      end
    end

    context "reading a video tag" do
      let(:string) { "\x09" }

      it "creates a FLV::Tag::Data" do
        FLV::Tag::Video.should_receive(:new).with(io)
        FLV::Tag.read(io)
      end
    end
  end

  describe "tag parsing" do
    let(:string) { "\x00\x00\x0b\xad\xbe\xef\xde\x00\x00\x00hello world\x00\x00\x00\x15" }
    subject { FLV::Tag.new(StringIO.new(string)) }

    its(:length)    { should == 11 }
    its(:timestamp) { should == 0xdeadbeef }
    its(:raw_data)  { should == "hello world" }
    its(:footer)    { should == 21 }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flv-0.1.0 spec/flv/tag_spec.rb