Sha256: 4323403845e8caf3b643e535813bf55405b080ea7ab95c33d3ce0169202ea2da

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe RailsBestPractices::Core::Check do
  let(:check) { RailsBestPractices::Core::Check.new }

  it "should get empty interesting nodes" do
    check.interesting_nodes.should == []
  end

  it "should match none of interesting files" do
    check.interesting_files.should == []
  end

  context "node_start" do
    it "should call start_if" do
      node = stub(:sexp_type => :if)
      check.should_receive(:send).with("start_if", node)
      check.node_start(node)
    end

    it "should call start_call" do
      node = stub(:sexp_type => :call)
      check.should_receive(:send).with("start_call", node)
      check.node_start(node)
    end
  end

  context "node_end" do
    it "should call end_if" do
      node = stub(:sexp_type => :if)
      check.should_receive(:send).with("end_if", node)
      check.node_end(node)
    end

    it "should call end_call" do
      node = stub(:sexp_type => :call)
      check.should_receive(:send).with("end_call", node)
      check.node_end(node)
    end
  end

  context "callback" do
    it "should add callback to start_call" do
      execute = false
      check.class.add_callback "start_call" do
        execute = true
      end
      node = stub(:sexp_type => :call)
      check.node_start(node)
      execute.should be_true
    end

    it "should ad callbacks to end_call" do
      execute = false
      check.class.add_callback "end_call" do
        execute = true
      end
      node = stub(:sexp_type => :call)
      check.node_end(node)
      execute.should be_true
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
rails_best_practices-gorgeouscode-1.0.0 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.9.0 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.8.0 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.7.2 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.7.1 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.7.0 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.6.0 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.5.3 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.5.2 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.5.1 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.5.0 spec/rails_best_practices/core/check_spec.rb
rails_best_practices-1.4.0 spec/rails_best_practices/core/check_spec.rb