class TestMatcherSupport::ActiveSupport::TestCase
Public Instance Methods
must_belong_to(parent_model)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 43 def must_belong_to(parent_model) subject.reflect_on_all_associations(:belongs_to).map(&:name).must_include parent_model end
must_have_column(column, type=nil)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 8 def must_have_column(column, type=nil) subject.column_names.must_include column.to_s if type.nil? subject.columns_hash[column.to_s].type.must_equal :string else subject.columns_hash[column.to_s].type.must_equal type end end
must_have_index(index)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 21 def must_have_index(index) connection = ActiveRecord::Base.connection indexes = connection.indexes(subject.table_name).collect(&:columns) if index.class == Symbol indexes.must_include [index.to_s] else indexes.must_include(index.map &:to_s) end end
must_have_many(child_model)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 55 def must_have_many(child_model) subject.reflect_on_all_associations(:has_many).map(&:name).must_include child_model end
must_have_multiple_index(index)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 31 def must_have_multiple_index(index) connection = ActiveRecord::Base.connection connection.indexes(subject.table_name) .collect(&:columns.to_sym) .must_include(index.map &:to_s) end
must_have_one(model)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 47 def must_have_one(model) subject.reflect_on_all_associations(:has_one).map(&:name).must_include model end
originables_fixture(fixture_name)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 63 def originables_fixture(fixture_name) eval("#{subject.table_name}(fixture_name.to_sym)") end
subject()
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 4 def subject subject ||= self.class.name.split("::").first.constantize end
table_name()
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 67 def table_name subject.table_name end
wont_belong_to(parent_model)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 51 def wont_belong_to(parent_model) subject.reflections[parent_model.to_sym].macro.wont_equal :belongs_to end
wont_have_column(column, type)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 17 def wont_have_column(column, type) subject.columns_hash[column.to_s].type.wont_equal type end
wont_have_index(index)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 38 def wont_have_index(index) connection = ActiveRecord::Base.connection connection.indexes(subject).collect(&:columns).wont_include([index]) end
wont_have_many(model)
click to toggle source
# File lib/generators/installer/templates/support/test_matcher_support.rb, line 59 def wont_have_many(model) subject.reflections[child_model].macro.wont_equal :has_many end