Sha256: aa6b799ed8bc5f480855a6742f09250f112b4828a08f3e8719aa4677fa1c347b

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require "simplecov"

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))

require "minitest/autorun"
require "bundler"
Bundler.require
require "inch"
require "inch/cli"

def assert_roles(object, expected, unexpected)
  roles = object.roles.map(&:class)
  unexpected.each do |role|
    refute roles.include?(role), "Should not assign #{role}"
  end
  expected.each do |role|
    assert roles.include?(role), "Should assign #{role}"
  end
end

def count_roles(object, role_class, object_name = nil)
  find_roles(object, role_class, object_name).size
end

def find_roles(object, role_class, object_name = nil)
  object.roles.select do |r|
    r.class == role_class && (object_name.nil? || r.object.name == object_name)
  end
end

def fixture_path(language, name)
  File.join(File.dirname(__FILE__), "fixtures", language.to_s, name.to_s)
end

module Inch
  module Test
    class << self
      attr_accessor :object_providers

      def codebase(language, name)
        Inch::Codebase::Proxy.new language, object_provider(language, name)
      end

      def object_provider(language, name)
        self.object_providers ||= {}
        self.object_providers[name] ||= ::Inch::CodeObject::Provider.parse(fixture_path(language, name))
      end
    end
  end
end

def test_codebase(name)
  codebase = Inch::Test.codebase(:ruby, name)
  codebase
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inch-0.5.0.rc5 test/test_helper.rb
inch-0.5.0.rc4 test/test_helper.rb