Sha256: 59e4edc4acd25a8be57c6fb1a37d1c3187391558992436ba31b2bc72caf8fd22

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

module Pelusa
  describe ClassAnalyzer do
    describe '#analyze' do
      before do
        @lints = [
          stub(new: stub(check: true)),
          stub(new: stub(check: true))
        ]
        @klass    = stub(name: stub(name: "Foo"))
        @analyzer = ClassAnalyzer.new(@klass)
      end

      it 'analyzes a Class node for a series of lints' do
        @analyzer.analyze(@lints).must_equal [true, true]
      end

      describe '#class_name' do
        it 'returns the name of the analyzed class' do
          @analyzer.class_name.must_equal "Foo"
        end
      end

      describe "#type" do
        it "returns the type module for modules" do
          # hacky!
          @klass.stubs(:is_a?).with(Rubinius::ToolSets::Runtime::ToolSet::AST::Class).returns(true)
          @analyzer.type.must_equal "class"
        end

        it "returns the type module for modules" do
          # hacky!
          @klass.stubs(:is_a?).with(Rubinius::ToolSets::Runtime::ToolSet::AST::Class).returns(false)
          @analyzer.type.must_equal "module"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pelusa-0.2.4 test/pelusa/class_analyzer_test.rb