Sha256: bf35159a2ae794f67396caedd2e24e8ed09a507faeeac1d641488bda41ac39fc

Contents?: true

Size: 692 Bytes

Versions: 7

Compression:

Stored size: 692 Bytes

Contents

require 'spec_helper'

describe 'Form with injected commands' do
  subject(:form) { form_class.build(params) }

  let(:params) { { title: 'Task one' } }

  let(:form_class) do
    Class.new(ROM::Model::Form) do
      commands users: :create, tags: :create

      inject_commands_for :tasks

      mappings tasks: :entity

      input do
        set_model_name 'Task'

        attribute :title
      end

      def commit!
        tasks.create[attributes]
      end
    end
  end

  it 'auto-maps result using injected commands' do
    form.save

    value = form.result

    expect(value).to be_a(Task)
    expect(value.id).to_not be(nil)
    expect(value.title).to eql('Task one')
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-rails-0.5.0 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.5.0.rc1 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.5.0.beta1 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.4.0 spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.3.3 spec/dummy/spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.3.2 spec/dummy/spec/integration/form_with_injected_commands_spec.rb
rom-rails-0.3.1 spec/dummy/spec/integration/form_with_injected_commands_spec.rb