Sha256: 7ad4ebc043ff49dc755cfcb04fc5d6b112d200535881b238b955e9fe38d27f85

Contents?: true

Size: 1.44 KB

Versions: 12

Compression:

Stored size: 1.44 KB

Contents

require "spec_helper"

describe AwesomeTranslations::ModelInspector do
  let(:user_inspector) { AwesomeTranslations::ModelInspector.model_classes.find { |model_inspector| model_inspector.clazz == User } }
  let(:model_classes) { AwesomeTranslations::ModelInspector.model_classes.map(&:clazz).select { |clazz| !clazz.name.end_with?("::Translation") } }

  it "#model_classes" do
    require "jquery-rails"

    expect(model_classes.to_a.sort { |class1, class2| class1.name <=> class2.name }).to eq [Role, User]
  end

  it "#engines" do
    expected = [AwesomeTranslations::Engine, BootstrapBuilders::Engine, Haml::Rails::Engine, Jquery::Rails::Engine, MoneyRails::Engine]
    expect(AwesomeTranslations::ModelInspector.engines.map(&:class).sort { |class1, class2| class1.name <=> class2.name }).to eq expected
  end

  it "#class_key" do
    expect(user_inspector.class_key).to eq "activerecord.models.user"
  end

  it "#class_key_one" do
    expect(user_inspector.class_key_one).to eq "activerecord.models.user.one"
  end

  it "#class_key_other" do
    expect(user_inspector.class_key_other).to eq "activerecord.models.user.other"
  end

  it "#attribute_key" do
    expect(user_inspector.attribute_key("first_name")).to eq "activerecord.attributes.user.first_name"
  end

  it "#snake_name" do
    expect(user_inspector.snake_name).to eq "user"
  end

  it "#attributes" do
    expect(user_inspector.attributes.map(&:name).to_a).to eq %w(id email password age)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
awesome_translations-0.0.40 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.39 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.38 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.37 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.36 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.35 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.34 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.33 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.32 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.31 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.30 spec/lib/model_inspector_spec.rb
awesome_translations-0.0.29 spec/lib/model_inspector_spec.rb