Sha256: 49fd0435b630bb8454e542f13d34338b1d4a41fe3afcf927530fa06d4f01a53a
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
require 'flexmock/test_unit' module MockedFixtures module Mocks module Flexmock def mock_model_with_flexmock(model_class, options_and_stubs={}) all_attributes = options_and_stubs.delete(:all_attributes) add_errors = options_and_stubs.delete(:add_errors) if all_attributes schema = MockedFixtures::SchemaParser.load_schema table = model_class.table_name schema[table][:columns].each { |column| options_and_stubs[column[0].to_sym] = nil unless options_and_stubs.has_key?(column[0].to_sym) } end if add_errors errors = flexmock(Array.new, :count => 0, :on => nil) options_and_stubs.reverse_merge!(:errors => errors) end mock_helper = FlexMock::MockContainerHelper.new id = options_and_stubs[:id] || mock_helper.next_id options_and_stubs.reverse_merge!({ :id => id, :to_param => id.to_s, }) mock = flexmock("#{model_class}_#{id}", options_and_stubs) mock_helper.add_model_methods(mock, model_class, id) mock end end end end Test::Unit::TestCase.send(:include, MockedFixtures::Mocks::Flexmock)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mocked_fixtures-0.1.0 | lib/mocked_fixtures/mocks/flexmock.rb |
mocked_fixtures-0.2.0 | lib/mocked_fixtures/mocks/flexmock.rb |
mocked_fixtures-0.3.0 | lib/mocked_fixtures/mocks/flexmock.rb |