Sha256: c7dd2b943de74365a6bf0eb24d9336e2e3b3f7c927d8a382aeec293e4494994c
Contents?: true
Size: 1.04 KB
Versions: 15
Compression:
Stored size: 1.04 KB
Contents
require File.join(File.dirname(__FILE__) + '/../../spec_helper') describe RailsBestPractices::Checks::LawOfDemeterCheck do before(:each) do @runner = RailsBestPractices::Core::Runner.new(RailsBestPractices::Checks::LawOfDemeterCheck.new) content = <<-EOF class Invoice < ActiveRecord::Base belongs_to :user end EOF @runner.check('app/models/invoice.rb', content) end it "should law of demeter" do content = <<-EOF <%= @invoice.user.name %> <%= @invoice.user.address %> <%= @invoice.user.cellphone %> EOF @runner.check('app/views/invoices/show.html.erb', content) errors = @runner.errors errors.should_not be_empty errors[0].to_s.should == "app/views/invoices/show.html.erb:1 - law of demeter" end it "should no law of demeter" do content = <<-EOF <%= @invoice.user_name %> <%= @invoice.user_address %> <%= @invoice.user_cellphone %> EOF @runner.check('app/views/invoices/show.html.erb', content) errors = @runner.errors errors.should be_empty end end
Version data entries
15 entries across 15 versions & 1 rubygems