Sha256: bebb6b2e5f81b755ac1e2d27b0a08e72963b6f6732445944a1481d2d9669dcc2

Contents?: true

Size: 913 Bytes

Versions: 3

Compression:

Stored size: 913 Bytes

Contents

require 'spec_helper'

describe RailsBestPractices::Prepares::ModelPrepare do
  let(:runner) { RailsBestPractices::Core::Runner.new(:prepares => RailsBestPractices::Prepares::ModelPrepare.new) }

  it "should parse model associations" do
    content =<<-EOF
    class Project < ActiveRecord::Base
      belongs_to              :portfolio
      has_one                 :project_manager
      has_many                :milestones
      has_and_belongs_to_many :categories
    end
    EOF
    runner.prepare('app/models/project.rb', content)
    model_associations = RailsBestPractices::Prepares.model_associations
    model_associations["Project"]["portfolio"].should == :belongs_to
    model_associations["Project"]["project_manager"].should == :has_one
    model_associations["Project"]["milestones"].should == :has_many
    model_associations["Project"]["categories"].should == :has_and_belongs_to_many
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_best_practices-0.7.1 spec/rails_best_practices/prepares/model_prepare_spec.rb
rails_best_practices-0.7.0 spec/rails_best_practices/prepares/model_prepare_spec.rb
rails_best_practices-0.6.7 spec/rails_best_practices/prepares/model_prepare_spec.rb