Sha256: b91c8411a28692d64fb35fda1f6bd0c6f16f14b78880c588f32da34d25f13f1a

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe CssFontFaceRule do

  let(:css_text) do 
    "@font-face {
      font-family: \"Bitstream Vera Serif Bold\";
      src: url(\"http://example.com/fonts/VeraSeBd.ttf\");
    }" 
  end

  let(:rule) do 
    CssFontFaceRule.new(:css_text => css_text)
  end

  describe "#style" do 
    it "returns the css style declaration for the rule" do 
      style = rule.style

      expect(style).to be_kind_of(CssStyleDeclaration)
      expect(style.length).to eq 2
    end
  end

  describe "#type" do 
    it "shows the type of style rule" do 
      expect(rule.type).to eq CssRule::FONT_FACE_RULE
    end
  end

  describe ".matches_rule?" do 
    it "should match text starting with @font-face" do 
      matches = CssFontFaceRule.matches_rule?(css_text)
      expect(matches).to eq true
    end
    
    it "should not match text without at-rule" do 
      matches = CssFontFaceRule.matches_rule?("a:link { color: #357ad1; }")
      expect(matches).to eq false
    end

    it "should not match text without font-face" do 
      matches = CssFontFaceRule.matches_rule?("@import url(\"import1.css\");")
      expect(matches).to eq false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stylesheet-0.1.8 spec/css_font_face_rule_spec.rb
stylesheet-0.1.7 spec/css_font_face_rule_spec.rb
stylesheet-0.1.6 spec/css_font_face_rule_spec.rb