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.34 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.33 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.32 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.31 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.30 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.29 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.28 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.27 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.26 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.25 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.24 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.23 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.22 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.21 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.20 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.19 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.18 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.17 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.16 spec/models/magic_addresses/translator_spec.rb
magic_addresses-0.0.15 spec/models/magic_addresses/translator_spec.rb