Sha256: a761d9847971eb6d10701ee7c344c65b160751d084ae7e6d5f1d7171e75d6024

Contents?: true

Size: 1.35 KB

Versions: 54

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe MagicAddresses::Translator do
  
  class TestAddress < ActiveRecord::Base
    self.table_name = "mgca_addresses"
    mgca_translate :street
  end

  class TestLocation < ActiveRecord::Base
    self.table_name = "mgca_addresses"
  end
  
  describe "Class::Methods" do
    
    it "add search helper" do
      expect( TestAddress.respond_to?(:search) ).to be true
      expect( TestAddress.search("xxx") ).equal? []
      expect( TestLocation.respond_to?(:search) ).to be false
      expect{ TestLocation.search("xxx") }.to raise_error(NoMethodError)
    end
    
  end


  describe "Instance::Methods" do

    let(:berlin){
      TestAddress.create!(name: "Berlin")
    }
    let(:potsdam){
      TestLocation.create!(name: "Potsdam")
    }

    it "add globalize attributes" do
      expect( berlin.respond_to?(:translations) ).to be true
      expect( berlin.respond_to?(:street) ).to be true
      
      expect( potsdam.respond_to?(:translations) ).to be false
      expect( potsdam.respond_to?(:street) ).to be false
    end
    
    it "add globalize attributes only if asked for" do
      expect( berlin.respond_to?(:translations) ).to be true
      expect( berlin.respond_to?(:street) ).to be true
      
      expect( potsdam.respond_to?(:translations) ).to be false
      expect( potsdam.respond_to?(:street) ).to be false
    end

  end


end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
magic_addresses-0.0.44 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.43 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.42 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.41 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.40 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc8 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc7 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc6 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc5 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc4 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc3 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc2 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.39.rc1 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.38 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.38.beta2 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.38.beta1 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.37 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.36 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.35 spec/models/magic_addresses/translator_spec.rb