Sha256: ffbf4beba8d487968d35604f2cdd4681d6eecbf3295cec4860dd5e63e426eef9

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require "./test/tests_helper"
require "nele"

@custom_translators.call()

describe "StringExt" do

  it("has /translators/ method which returns providers") do
    String.translators.must_equal [ 'ms', 'babelfish', 'foo', 'bar' ]
  end

  it("responses to translate method") do
    "hello".respond_to?(:translate).must_equal true
  end

  it("raises TranslatorInvalidError") do
    lambda { String.translator = "blah" }.must_raise(Nele::TranslatorInvalidError)
  end

  it("raises TranslatorMissingError") do
    String.translator = nil
    lambda { "hello".translate }.must_raise(Nele::TranslatorMissingError)
  end

  it("raises EmptyStringError") do
    lambda { "".translate }.must_raise(Nele::EmptyStringError)
  end

  it("initializes translator instance based on string") do
    String.translator = "bar"
    String.translator.class.must_equal Nele::BarTranslator
  end

  it("initializes translator instance based on symbol") do
    String.translator = :bar
    String.translator.class.must_equal Nele::BarTranslator
  end

  it("sets translator to nil") do
    String.translator = :bar
    String.translator = nil
    String.translator.class.must_equal NilClass
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nele-0.2.2 test/string_test.rb