Skip to content
Browse files

add very basic specs to mobilized styles.

  • Loading branch information...
1 parent 79c5535 commit 6d75510e1c1289d496f61a19c06ef390711fa0f2 @cowboyd cowboyd committed
Showing with 40 additions and 0 deletions.
  1. +39 −0 spec/mobilized_styles_spec.rb
  2. 0 spec/spec.opts
  3. +1 −0 spec/spec_helper.rb
View
39 spec/mobilized_styles_spec.rb
@@ -0,0 +1,39 @@
+
+require File.dirname(__FILE__) + '/spec_helper'
+
+module ActionView
+ module Helpers
+ module AssetTagHelper
+ STYLESHEETS_DIR = "stylesheets"
+ end
+ end
+end
+
+describe MobilizedStyles do
+
+ before(:each) do
+ @view = mock(:ActionView)
+ @request = mock(:ActionRequest)
+ @view.extend(MobilizedStyles)
+ @view.stub!(:request).and_return(@request)
+ @request.stub!(:user_agent)
+ end
+
+ def ua(str)
+ @request.stub!(:user_agent).and_return(str)
+ end
+
+ it "will include a mobilized css file if it recognizes a string in the user agent" do
+ ua "iphone"
+ File.should_receive(:exist?).with("stylesheets/style_iphone.css").and_return(true)
+ @view.should_receive(:stylesheet_link_tag_without_mobilization).with("style", "style_iphone")
+ @view.stylesheet_link_tag_with_mobilization("style")
+ end
+
+ it "includes mobiziled css files whether or not the original call to stylesheet_link_tag used a file extension" do
+ ua "blackberry"
+ File.should_receive(:exist?).with("stylesheets/style_blackberry.css").and_return(true)
+ @view.should_receive(:stylesheet_link_tag_without_mobilization).with("style.css", "style_blackberry")
+ @view.stylesheet_link_tag_with_mobilization("style.css")
+ end
+end
View
0 spec/spec.opts
No changes.
View
1 spec/spec_helper.rb
@@ -0,0 +1 @@
+require File.dirname(__FILE__) + "/../lib/mobilized_styles"

0 comments on commit 6d75510

Please sign in to comment.
Something went wrong with that request. Please try again.