Sha256: 8a44b4faf320d1f98f2d755a9c3499ffe68dcc441d5a35ba8f64aa801bad64e6

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

require "analysers_test_helper"
require "rubycritic/analysers/helpers/methods_counter"

describe Rubycritic::MethodsCounter do
  describe "#count" do
    context "when a file contains Ruby code" do
      it "calculates the number of methods" do
        analysed_module = AnalysedModuleDouble.new(:path => "test/samples/methods_count.rb")
        Rubycritic::MethodsCounter.new(analysed_module).count.must_equal 2
      end
    end

    context "when a file is empty" do
      it "returns 0 as the number of methods" do
        analysed_module = AnalysedModuleDouble.new(:path => "test/samples/empty.rb")
        Rubycritic::MethodsCounter.new(analysed_module).count.must_equal 0
      end
    end

    context "when a file is unparsable" do
      it "does not blow up and returns 0 as the number of methods" do
        analysed_module = AnalysedModuleDouble.new(:path => "test/samples/unparsable.rb")
        capture_output_streams do
          Rubycritic::MethodsCounter.new(analysed_module).count.must_equal 0
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rubycritic-2.6.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-2.5.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-2.4.1 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-2.4.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-2.3.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-2.2.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-2.1.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-2.0.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-1.4.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-1.3.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-1.2.1 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-1.2.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-1.1.1 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
rubycritic-1.1.0 test/lib/rubycritic/analysers/helpers/methods_counter_test.rb