Sha256: 20751dc0718fbcc9d3b7beddb8e5f72cad63823c46d8e0ac2b6e40a73e399dbc

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

require "spec_helper"
require "gettext_i18n_rails/haml_parser"

describe GettextI18nRails::HamlParser do
  let(:parser){ GettextI18nRails::HamlParser }

  describe "#target?" do
    it "targets .haml" do
      parser.target?('foo/bar/xxx.haml').should == true
    end

    it "does not target anything else" do
      parser.target?('foo/bar/xxx.erb').should == false
    end
  end

  describe "#parse" do
    it "finds messages in haml" do
      with_file '= _("xxxx")' do |path|
        parser.parse(path, []).should == [
          ["xxxx", "#{path}:1"]
        ]
      end
    end

    it "finds messages with concatenation" do
      with_file '= _("xxxx" + "yyyy" + "zzzz")' do |path|
        parser.parse(path, []).should == [
          ["xxxxyyyyzzzz", "#{path}:1"]
        ]
      end
    end

    it "should parse the 1.9 if ruby_version is 1.9" do
      if RUBY_VERSION =~ /^1\.9/
        with_file '= _("xxxx", x: 1)' do |path|
          parser.parse(path, []).should == [
            ["xxxx", "#{path}:1"]
          ]
        end
      end
    end

    it "does not find messages in text" do
      with_file '_("xxxx")' do |path|
        parser.parse(path, []).should == []
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gettext_i18n_rails-1.0.2 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-1.0.1 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-1.0.0 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-0.10.1 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-0.10.0 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-0.9.4 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-0.9.3 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-0.9.2 spec/gettext_i18n_rails/haml_parser_spec.rb
gettext_i18n_rails-0.9.1 spec/gettext_i18n_rails/haml_parser_spec.rb