Sha256: d15d50b3a5fb0622037b948bcbb82650bb14e89a001c2d6982cde5412ca1bc55

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'
require 'taketo/support/inflections'

include Taketo::Support

describe "Inflections" do
  module Nest1
    module Nest2
      class Thing; end
    end
  end

  describe "#to_singular" do
    it "returns singularized sumbol for klass" do
      expect(Inflections.to_singular(Nest1::Nest2::Thing)).to eq(:thing)
    end

    it "returns singularized sumbol for pluralized symbol" do
      expect(Inflections.to_singular(:things)).to eq(:thing)
    end
  end

  describe "#to_plural" do
    it "returns pluralized sumbol for klass" do
      expect(Inflections.to_plural(Nest1::Nest2::Thing)).to eq(:things)
    end

    it "returns pluralized sumbol for singularized symbol" do
      expect(Inflections.to_plural(:thing)).to eq(:things)
    end
  end

  describe "#to_class" do
    it "returns klass by pluralized symbol" do
      expect(Inflections.to_class(:things, Nest1::Nest2)).to eq(Nest1::Nest2::Thing)
    end

    it "returns klass by singularized symbol" do
      expect(Inflections.to_class(:thing, Nest1::Nest2)).to eq(Nest1::Nest2::Thing)
    end
  end
end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
taketo-0.3.1 spec/lib/taketo/support/inflections_spec.rb
taketo-0.3.0 spec/lib/taketo/support/inflections_spec.rb
taketo-0.2.0 spec/lib/taketo/support/inflections_spec.rb