Sha256: 11eb4c68bef7f385306ac4375d91846adfb10e83b6bc90bcba3619d761d2dbe0

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require "helper"

if SimpleCov.usable?
  describe SimpleCov do
    skip "requires the default configuration" if ENV["SIMPLECOV_NO_DEFAULTS"]

    context "profiles" do
      let(:config_class) do
        Class.new do
          include SimpleCov::Configuration

          def load_profile(name)
            configure(&SimpleCov.profiles[name.to_sym])
          end
        end
      end

      let(:config) { config_class.new }

      def filtered?(config, filename)
        path = File.join(SimpleCov.root, filename)
        file = SimpleCov::SourceFile.new(path, [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
        config.filters.any? { |filter| filter.matches?(file) }
      end

      it "provides a sensible test_frameworks profile" do
        config.load_profile(:test_frameworks)
        expect(filtered?(config, "foo.rb")).not_to be
        expect(filtered?(config, "test/foo.rb")).to be
        expect(filtered?(config, "spec/bar.rb")).to be
      end

      it "provides a sensible rails profile" do
        config.load_profile(:rails)
        expect(filtered?(config, "app/models/user.rb")).not_to be
        expect(filtered?(config, "db/schema.rb")).to be
        expect(filtered?(config, "config/environment.rb")).to be
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simplecov-0.15.1 spec/defaults_spec.rb