Permalink
Browse files

Removing capybara and adding more tests

  • Loading branch information...
1 parent 3b349a0 commit 779175a49a889556a0f9ee7a08b247341f29fff9 @petebrowne petebrowne committed Aug 23, 2011
Showing with 67 additions and 21 deletions.
  1. +4 −0 lib/mediaelement_rails/engine.rb
  2. +0 −1 mediaelement_rails.gemspec
  3. +63 −20 test/integration/assets_test.rb
View
4 lib/mediaelement_rails/engine.rb 100644 → 100755
@@ -3,5 +3,9 @@
module MediaelementRails
class Engine < Rails::Engine
+ initializer "mediaelement_rails.register_mime_types", :after => "sprockets.environment" do |app|
+ next unless app.config.assets.enabled
+ app.assets.register_mime_type "application/x-silverlight-app", ".xap"
+ end
end
end
View
1 mediaelement_rails.gemspec 100644 → 100755
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
s.add_development_dependency "rake", ">= 0.8.7"
s.add_development_dependency "bundler", "~> 1.0.0"
s.add_development_dependency "rails", ">= 3.1.0.rc6"
- s.add_development_dependency "capybara", "~> 1.0.1"
s.add_development_dependency "turn", "~> 0.8.2"
s.files = `git ls-files`.split("\n")
View
83 test/integration/assets_test.rb 100644 → 100755
@@ -1,33 +1,76 @@
require "test_helper"
-require "capybara/rails"
class AssetsTest < ActionDispatch::IntegrationTest
- include Capybara::DSL
+ test "includes full library" do
+ get "/assets/mediaelement-and-player.js"
+ assert_response :success
+ assert content_type("text/javascript")
+ assert response_includes?("var jQuery = function( selector, context ) {")
+ assert response_includes?("var mejs = mejs || {}")
+ assert response_includes?("mejs.MediaElementPlayer.prototype = {")
+ end
+
+ test "includes only mediaelement" do
+ get "/assets/mediaelement-without-player.js"
+ assert_response :success
+ assert content_type("text/javascript")
+ assert !response_includes?("var jQuery = function( selector, context ) {")
+ assert response_includes?("var mejs = mejs || {}")
+ assert !response_includes?("mejs.MediaElementPlayer.prototype = {")
+ end
+
+ test "includes player stylesheet" do
+ get "/assets/player.css"
+ assert_response :success
+ assert content_type("text/css")
+ assert response_includes?(".mejs-container {")
+ assert response_includes?(".mejs-mediaelement {")
+ end
- test "MediaElement javascript" do
- visit "/assets/mediaelement-and-player.js"
- assert page.has_content?("jQuery JavaScript Library v1.6.2")
- assert page.has_content?("var mejs = mejs || {}")
- assert page.has_content?("mejs.MediaElementPlayer.prototype = {")
+ test "includes player skins stylesheet" do
+ get "/assets/player-skins.css"
+ assert_response :success
+ assert content_type("text/css")
+ assert response_includes?(".mejs-container.mejs-ted {")
+ assert response_includes?(".mejs-container.mejs-wmp {")
end
- test "MediaElement without player javascript" do
- visit "/assets/mediaelement-without-player.js"
- assert page.has_no_content?("jQuery JavaScript Library v1.6.2")
- assert page.has_content?("var mejs = mejs || {}")
- assert page.has_no_content?("mejs.MediaElementPlayer.prototype = {")
+ test "includes flash plugin" do
+ get "/assets/mediaelement_rails/flashmediaelement.swf"
+ assert_response :success
+ assert content_type("application/x-shockwave-flash")
end
- test "MediaElement player stylesheet" do
- visit "/assets/player.css"
- assert page.has_content?(".mejs-container {")
- assert page.has_content?(".mejs-mediaelement {")
+ test "includes silverlight plugin" do
+ get "/assets/mediaelement_rails/silverlightmediaelement.xap"
+ assert_response :success
+ assert content_type("application/x-silverlight-app")
+ end
+
+ {
+ "background.png" => "image/png",
+ "bigplay.png" => "image/png",
+ "controls-ted.png" => "image/png",
+ "controls-wmp-bg.png" => "image/png",
+ "controls-wmp.png" => "image/png",
+ "controls.png" => "image/png",
+ "loading.gif" => "image/gif"
+ }.each do |image, type|
+ test "includes #{image[0..-5]} image" do
+ get "/assets/mediaelement_rails/#{image}"
+ assert_response :success
+ assert content_type(type)
+ end
+ end
+
+ # Returns true if the response includes the given content
+ def response_includes?(content)
+ @response.body.include?(content)
end
- test "MediaElement player skins stylesheet" do
- visit "/assets/player-skins.css"
- assert page.has_content?(".mejs-container.mejs-ted {")
- assert page.has_content?(".mejs-container.mejs-wmp {")
+ # Returns true if the response is of the given content type
+ def content_type(type)
+ @response.content_type == type
end
end

0 comments on commit 779175a

Please sign in to comment.