Sha256: 0bf0ebcb475aea9da58c517e033092ddf63455cf727ea19f2a41ae56f256e62b

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
require 'fakeweb'

class DocomoCssController < ApplicationController
  def simple
    html = <<-EOD
      <% content_for(:head, stylesheet_link_tag("docomo_css/simple.css")) %>
      <span>color</span>
    EOD
    render :inline => html, :layout => true
  end

  def external
    html = <<-EOD
      <% content_for(:head, stylesheet_link_tag("http://www.galakei.com/external.css")) %>
      <span>color</span>
    EOD
    render :inline => html, :layout => true
  end

  def japanese
    html = <<-EOD
      <% content_for(:head, stylesheet_link_tag("docomo_css/simple.css")) %>
      ほげ
    EOD
    render :inline => html, :layout => true
  end
end

feature 'inlining of css' do
  scenario 'requesting simple page for docomo', :driver => :docomo do
    parser = CssParser::Parser.new
    parser.add_block!('span { color: red}') 
    Galakei::DocomoCss::InlineStylesheet.stub(:parser) { parser }
    visit '/docomo_css/simple'
    find("span")["style"].should == "color: red;"
    page.should_not have_xpath("//link")
  end

  scenario 'requesting external page for docomo', :driver => :docomo do
    FakeWeb.register_uri(:get, 'http://www.galakei.com/external.css', :body => "span { color: red }")
    visit '/docomo_css/external'
    find("span")["style"].should == "color: red;"
    page.should_not have_xpath("//link")
  end

  %w[au softbank docomo_2_0].each do |carrier|
    scenario "requesting simple page for #{carrier}", :driver => carrier.to_sym do
      visit '/docomo_css/simple'
      find("span")["style"].should be_nil
    end
  end

  scenario 'response contains non-ascii', :driver => :docomo do
    visit '/docomo_css/japanese'
    page.body.should include("ほげ")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
galakei-0.6.2 spec/acceptance/docomo_css_spec.rb
galakei-0.6.1 spec/acceptance/docomo_css_spec.rb
galakei-0.6.0 spec/acceptance/docomo_css_spec.rb