Sha256: f9299ba9ea3d71e60b2fe46065e21d8b5c43c1b3e9b154a1e0abb1cc595def67

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe ActiveGit::Inflector do

  let(:working_path) { '/home/git' }

  it 'Git path' do
    ActiveGit::Inflector.dirname(Country, working_path).should eq "#{working_path}/countries"
  end

  it 'Git path for nested model' do
    ActiveGit::Inflector.dirname(Crm::Customer, working_path).should eq "#{working_path}/crm/customers"
  end

  it 'Git file' do
    country = Country.create! name: 'Argentina'
    ActiveGit::Inflector.filename(country, working_path).should eq "#{working_path}/countries/#{country.id}.json"
  end

  it 'Git file for nested model' do
    customer = Crm::Customer.create! name: 'Monster Inc.'
    ActiveGit::Inflector.filename(customer, working_path).should eq "#{working_path}/crm/customers/#{customer.id}.json"
  end

  it 'Model from filename' do
    ActiveGit::Inflector.model("#{working_path}/countries/1.json", working_path).should be Country
  end

  it 'Model from filename' do
    ActiveGit::Inflector.model("#{working_path}/crm/customers/1.json", working_path).should be Crm::Customer
  end

  it 'Model id' do
    ActiveGit::Inflector.model_id("#{working_path}/crm/customers/1.json").should eq '1'
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_git-0.0.4 spec/inflector_spec.rb