flowplayer-gem/spec/flowplayer_spec.rb

61 lines
2.0 KiB
Ruby
Raw Normal View History

2011-01-31 22:22:47 +00:00
require 'spec_helper'
describe Flowplayer::Player do
it "should set options from block" do
2011-02-01 21:03:28 +00:00
flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
2011-01-31 22:22:47 +00:00
player.fullscreen true
player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
player.onLoad do
'this.unmute();'
end
end
flow_player.options[:fullscreen].should == true
flow_player.functions[:onLoad].should == 'function() { this.unmute(); }'
flow_player.options[:logo].should be_an(Hash)
end
it "should set the dom_id to 'my_video'" do
2011-02-01 21:03:28 +00:00
flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
2011-01-31 22:22:47 +00:00
player.fullscreen true
end
flow_player.dom_id.should == 'my_video'
end
it "should generate valid options" do
2011-02-01 21:03:28 +00:00
flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
2011-01-31 22:22:47 +00:00
player.fullscreen true
player.logo({:opacity => 0, :fullscreenOnly => true})
player.onLoad do
'this.unmute();'
end
end
flow_player.to_js.should include 'fullscreen'
flow_player.to_js.should match /^\{.+\}$/
flow_player.to_js.should include({:opacity => 0, :fullscreenOnly => true}.to_json)
end
it "should create script tags with options" do
2011-02-01 21:03:28 +00:00
flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
2011-01-31 22:22:47 +00:00
player.fullscreen true
player.logo(:url => nil, :opacity => 0, :fullscreenOnly => true)
player.onLoad do
'this.unmute();'
end
end
2011-02-01 21:03:28 +00:00
["<script", "</script>", "flowplayer(\"my_video\", \"commericial.swf\", #{flow_player.to_js}"].each do |part|
2011-01-31 22:22:47 +00:00
flow_player.script_tags.should include part
end
2011-02-01 21:03:28 +00:00
flow_player.script_tags.should match(/\)\;/)
2011-01-31 22:22:47 +00:00
end
it "should raise exception if passed a setter" do
lambda do
2011-02-01 21:03:28 +00:00
flow_player = Flowplayer::Player.new('my_video', 'commericial.swf') do |player|
2011-01-31 22:22:47 +00:00
player.fullscreen = true
end
end.should raise_error
end
end