test/test_helper.rb in inch-0.4.6 vs test/test_helper.rb in inch-0.4.7

- old
+ new

@@ -1,20 +1,31 @@ -require 'simplecov' +require "simplecov" -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) -require 'minitest/autorun' -require 'bundler' +require "minitest/autorun" +require "bundler" Bundler.require -require 'inch' +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(name) File.join(File.dirname(__FILE__), "fixtures", name.to_s)