Sha256: 648fa9bedc8acaa6f3b57ea04e7780ded56fb1cdfc2da19ef5799fe1a84f3b2c

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'after_parse callbacks', type: :feature do
  module AfterParseSpec
    class Address
      include HappyMapper
      element :street, String
    end
  end

  after do
    AfterParseSpec::Address.after_parse_callbacks.clear
  end

  it 'callbacks with the newly created object' do
    from_cb = nil
    called = false
    cb1 = proc { |object| from_cb = object }
    cb2 = proc { called = true }
    AfterParseSpec::Address.after_parse(&cb1)
    AfterParseSpec::Address.after_parse(&cb2)

    object = AfterParseSpec::Address.parse fixture_file('address.xml')

    aggregate_failures do
      expect(from_cb).to eq(object)
      expect(called).to eq(true)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokogiri-happymapper-0.8.1 spec/features/after_parse_callbacks_spec.rb