Sha256: 2ef8b6dc374bf35b671c2806fa1d9d597d1ae30dcfc34ff27385481a3bc789cd

Contents?: true

Size: 632 Bytes

Versions: 14

Compression:

Stored size: 632 Bytes

Contents

module BetterRecord
  module Rspec
    module Extensions
      def has_valid_factory(factory_name, count = 10)
        it "has a valid factory" do
          records = []
          count = (count.to_i == 0) ? 1 : count.to_i
          count.times do
            test_factory = build(factory_name)
            unless test_factory.valid?
              puts test_factory.errors.full_messages
            end
            expect(test_factory.valid?).to be true
            expect(test_factory.save).to be true
            records << test_factory
          end
          records.each {|f| f.destroy}
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
better_record-0.8.0 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.7.5 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.7.4 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.7.3 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.7.2 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.7.1 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.7.0 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.6.1 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.6.0 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.5.5 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.5.4 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.5.1 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.5.0 lib/better_record/rspec/extensions/has_valid_factory.rb
better_record-0.4.0 lib/better_record/rspec/extensions/has_valid_factory.rb