Sha256: 15dafb84bb3b32286444a9d0a7d3cef6fc5b47eb44a379b4247f1ed97fad2fca

Contents?: true

Size: 754 Bytes

Versions: 7

Compression:

Stored size: 754 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Macros::Contract::Prepopulate do
  subject(:prepopulate_step) { described_class.new(options_key: options_key) }

  class self::AlbumForm < Reform::Form # rubocop:disable Style/ClassAndModuleChildren
    property :title

    def build_errors; end
  end

  let(:album) { mock_model('Album', title: title) }
  let(:contract) { self.class::AlbumForm.new(album) }

  let(:ctx) { { 'contract.default' => contract, options_key => { title: new_title } } }

  let(:options_key) { :params }

  let(:title) { 'Lorem' }
  let(:new_title) { 'Ipsum' }

  it 'expects to prepopulate contract' do
    expect(ctx['contract.default']).to receive(:prepopulate!).with(title: new_title)

    prepopulate_step.call(ctx)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ff-tbl-macros-2.0.2 spec/lib/contract/prepopulate_spec.rb
ff-tbl-macros-2.0.1 spec/lib/contract/prepopulate_spec.rb
ff-tbl-macros-2.0.0 spec/lib/contract/prepopulate_spec.rb
ff-tbl-macros-1.0.2 spec/lib/contract/prepopulate_spec.rb
ff-tbl-macros-1.0.1 spec/lib/contract/prepopulate_spec.rb
ff-tbl-macros-1.0.0 spec/lib/contract/prepopulate_spec.rb
ff-tbl-macros-0.1.8 spec/lib/contract/prepopulate_spec.rb