Sha256: 8722c80e5f07cee2f01d5bd33859d978603f724843bb61b20119018c2bc915dc

Contents?: true

Size: 576 Bytes

Versions: 1

Compression:

Stored size: 576 Bytes

Contents

require 'spec_helper'

describe 'Form with command supplied validations' do

  subject(:form) { form_class.build(params) }

  let(:params) {{}}

  let(:form_class) do
    Class.new(ROM::Model::Form) do
      inject_commands_for :tasks

      input do
        set_model_name 'Task'

        attribute :title
      end

      def commit!
        tasks.try { tasks.create_task_with_validations.call(attributes) }
      end
    end
  end


  it "copies validation errors from command" do
    form.save

    errors = form.errors
    expect(errors[:title]).to be_present
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-rails-0.8.0 spec/integration/form_with_command_validation_spec.rb