Sha256: df553a4bfa137c0836ecbd3f8120f8e7c9caa2df21abdab6b7d676ba588fc46d

Contents?: true

Size: 517 Bytes

Versions: 41

Compression:

Stored size: 517 Bytes

Contents

# frozen_string_literal: true

module BetterRecord
  module Rspec
    module Extensions
      def optional_column(factory_name, column_name, &blk)
        describe column_name.to_s do
          let(:record) { build(factory_name) }

          it "is optional" do
            record.__send__"#{column_name}=", nil
            expect(record.valid?).to be true
            expect(record.errors[column_name]).to be_empty
          end

          instance_eval(&blk) if block_given?
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
better_record-0.16.1 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.16.0 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.15.2 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.15.1 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.15.0 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.14.6 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.14.5 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.14.4 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.14.3 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.14.2 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.14.1 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.14.0 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.13.1 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.13.0 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.12.5 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.12.4 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.12.3 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.12.2 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.12.1 lib/better_record/rspec/extensions/optional_column.rb
better_record-0.11.5 lib/better_record/rspec/extensions/optional_column.rb