Sha256: 0eae4200a86eef6d4999705e253658a2fb4b1fc8935cae715421f457c201dc7f

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

require 'ar_schema'
require File.expand_path("lib/lolita-translation/builder/active_record_builder")
require File.expand_path("lib/lolita-translation/configuration")
ARSchema.connect!

describe Lolita::Translation::Builder::ActiveRecordBuilder do
  let(:klass) { Lolita::Translation::Builder::ActiveRecordBuilder }
  let(:config){ Lolita::Translation::Configuration.new(Product) }
  before(:each) do
    a_klass = Class.new(ActiveRecord::Base)
    stub_const('Product', a_klass)
  end

  it "should build class with ActiveRecord::Base as superclass" do
    obj = klass.new(Product)
    obj.build
    obj.klass.superclass.should eq(ActiveRecord::Base)
  end

  it "should call class methods on klass" do
    obj = klass.new(Product, config)
    obj.stub(:association_name).and_return(:product)
    obj.build
    obj.klass.reflections.keys.should include(:product)
  end

  it "should update base class" do
    obj = klass.new(Product,config)
    obj.stub(:translations_association_name).and_return(:translations)
    obj.build
    Product.reflections.keys.should include(:translations)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lolita-translation-0.8.4 spec/lolita-translation/builder/active_record_builder_spec.rb
lolita-translation-0.8.3 spec/lolita-translation/builder/active_record_builder_spec.rb
lolita-translation-0.8.2 spec/lolita-translation/builder/active_record_builder_spec.rb
lolita-translation-0.8.1 spec/lolita-translation/builder/active_record_builder_spec.rb
lolita-translation-0.8.0 spec/lolita-translation/builder/active_record_builder_spec.rb
lolita-translation-0.7.4 spec/lolita-translation/builder/active_record_builder_spec.rb