Sha256: 3e05996dda67cba5d5a2c7e45a4e1237f160fcca1cc7b9ac2aeedfefca169ea7

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

# encoding: UTF-8
require 'spec_helper'

module Roadie
  describe Stylesheet do
    it "is initialized with a name and CSS" do
      stylesheet = Stylesheet.new("foo.css", "body { color: green; }")
      stylesheet.name.should == "foo.css"
    end

    it "has a list of blocks" do
      stylesheet = Stylesheet.new("foo.css", <<-CSS)
        body { color: green !important; font-size: 200%; }
        a, i { color: red; }
      CSS
      stylesheet.should have(3).blocks
      stylesheet.blocks.map(&:to_s).should == [
        "body{color:green !important;font-size:200%}",
        "a{color:red}",
        "i{color:red}",
      ]
    end

    it "can iterate all inlinable blocks" do
      inlinable = double(inlinable?: true, selector: "good", properties: "props")
      bad = double(inlinable?: false, selector: "bad", properties: "props")

      stylesheet = Stylesheet.new("example.css", "")
      stylesheet.stub blocks: [bad, inlinable, bad]

      stylesheet.each_inlinable_block.to_a.should == [
        ["good", "props"],
      ]
    end

    it "has a string representation of the contents" do
      stylesheet = Stylesheet.new("example.css", "body { color: green;}a{ color: red; font-size: small }")
      stylesheet.to_s.should == "body{color:green}\na{color:red;font-size:small}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roadie-3.0.0.pre1 spec/lib/roadie/stylesheet_spec.rb