Sha256: c5ec36e03bbd573ec2441c772dc09fcf2214ad6d50c664d03d9fbe3c1993efbf

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe Analyst::Entities::ClassMethod do

  let(:code) {<<-CODE
      class DefaultCarrier
        def self.register(carrier)
          CarrierRegistry.add(carrier)
        end
      end
    CODE
  }
  let(:parser) { Analyst.for_source(code) }
  let(:klass)  { parser.classes.first }
  let(:method) { klass.cmethods.first }

  describe "#name" do
    it "returns its short name" do
      expect(method.name).to eq("register")
    end
  end

  describe "#full_name" do
    it "returns its fully qualified name" do
      expect(method.full_name).to eq("DefaultCarrier::register")
    end
  end

  context "using `class << self` blocks" do

    let(:code) {<<-CODE
        class BodyBuilder
          class << self
            def generate_tanning_booth
              TanningBooth.new
            end
          end
        end
      CODE
    }

    describe "#name" do
      it "returns its short name" do
        expect(method.name).to eq("generate_tanning_booth")
      end
    end

    describe "#full_name" do
      it "returns its fully qualified name" do
        pending "must resolve out handling of singleton classes"
        expect(method.full_name).to eq("BodyBuilder::generate_tanning_booth")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
analyst-1.2.4 spec/entities/class_method_spec.rb
analyst-1.2.3 spec/entities/class_method_spec.rb
analyst-1.2.2 spec/entities/class_method_spec.rb
analyst-1.2.1 spec/entities/class_method_spec.rb
analyst-1.2.0 spec/entities/class_method_spec.rb
analyst-1.0.1 spec/entities/class_method_spec.rb