Sha256: edb137325e30b32094c95d25904a459b933bc9cc74c022e64396c714f7166188

Contents?: true

Size: 984 Bytes

Versions: 8

Compression:

Stored size: 984 Bytes

Contents

require 'spec_helper'

describe Fukuzatsu::Summary do

  describe "#complexity" do

    let(:class_source) { File.open("./spec/fixtures/class.rb", "r").readlines }
    let(:class_complexity) { class_source.first.split('complexity:')[1].to_i }

    let(:module_source) { File.open("./spec/fixtures/module.rb", "r").readlines }
    let(:module_complexity) { module_source.first.split('complexity:')[1].to_i }

    let(:procedural_source) { File.open("./spec/fixtures/procedural.rb", "r").readlines }
    let(:procedural_complexity) { procedural_source.first.split('complexity:')[1].to_i }

    it "calculates complexity of a class" do
      summary = Fukuzatsu::Summary.from(content: class_source.join("\n")).first
      expect(summary.complexity).to eq(class_complexity)
    end

    it "calculates complexity of a module" do
      summary = Fukuzatsu::Summary.from(content: module_source.join("\n")).first
      expect(summary.complexity).to eq(module_complexity)
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fukuzatsu-2.3.2 spec/summary_spec.rb
fukuzatsu-2.3.1 spec/summary_spec.rb
fukuzatsu-2.3.0 spec/summary_spec.rb
fukuzatsu-2.2.4 spec/summary_spec.rb
fukuzatsu-2.2.3 spec/summary_spec.rb
fukuzatsu-2.2.2 spec/summary_spec.rb
fukuzatsu-2.2.1 spec/summary_spec.rb
fukuzatsu-2.1.1 spec/summary_spec.rb