Sha256: 2b883af68faa1212b5338f4771f7aec64dc60b671f87651aa669c9074cf52b7f

Contents?: true

Size: 858 Bytes

Versions: 3

Compression:

Stored size: 858 Bytes

Contents

module EvelpidonTestHelpers
  module ActiveModel
    module Fixtures
      module Assertions
        # Asserts that all the records for the current model under test are valid.
        #
        # This helper chooses the model name based on the current test name, so for example
        # when the test that is running is named FooTest it will try to load all the records of Foo
        # through Foo.all and then call +assert_valid+ on each one of them.
        def assert_valid_fixtures
          model = self.class.to_s.gsub("Controller", "").gsub("Test", "").constantize
          model.all.each do |fixture|
            assert_valid fixture, fixture.inspect
          end
        end
      end
    end
  end
end

module ActiveSupport
  class TestCase
    include EvelpidonTestHelpers::ActiveModel::Fixtures::Assertions
  end
end if defined?(ActiveModel)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evelpidon_test_helpers-0.3.1 lib/evelpidon_test_helpers/active_model/fixtures.rb
evelpidon_test_helpers-0.3.0 lib/evelpidon_test_helpers/active_model/fixtures.rb
evelpidon_test_helpers-0.2.0 lib/evelpidon_test_helpers/active_model/fixtures.rb