Sha256: aec7441049ac20cd327c112bc77fc5757f42cd65df3bfe30883a76ed6e1c4dfd

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

$:.unshift File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib")

require 'i15r/pattern_matcher'
require "spec"

describe I15R::PatternMatchers::TagContentMatcher do

  it "should replace a single word" do
    plain = %(<label for="user-name">Name</label>)
    i18ned = %(<label for="user-name"><%= I18n.t("users.new.name") %></label>)
    I15R::PatternMatchers::TagContentMatcher.run(plain, "users.new").should == i18ned
  end

  it "should replace several words" do
    plain = %(<label for="user-name">Earlier names</label>)
    i18ned = %(<label for="user-name"><%= I18n.t("users.new.earlier_names") %></label>)
    I15R::PatternMatchers::TagContentMatcher.run(plain, "users.new").should == i18ned
  end

  it "should remove punctuation from plain strings" do
    plain = %(<label for="user-name">Got friends? A friend's name</label>)
    i18ned = %(<label for="user-name"><%= I18n.t("users.new.got_friends_a_friends_name") %></label>)
    I15R::PatternMatchers::TagContentMatcher.run(plain, "users.new").should == i18ned
  end

  it "should not remove punctuation outside plain strings" do
    plain = %(<label for="user-name">A friend's name:</label>)
    i18ned = %(<label for="user-name"><%= I18n.t("users.new.a_friends_name") %>:</label>)
    I15R::PatternMatchers::TagContentMatcher.run(plain, "users.new").should == i18ned
  end

  it "should preserve whitespace in the content part of the tag" do
    plain = %(<label for="user-name"> Name </label>)
    i18ned = %(<label for="user-name"> <%= I18n.t("users.new.name") %> </label>)
    I15R::PatternMatchers::TagContentMatcher.run(plain, "users.new").should == i18ned
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i15r-0.3.0 spec/tag_content_matcher_spec.rb