Sha256: 2ebc26ffd60311d8330d1081ae944d7b9cbdba1967c3be08fd77760f9d67d529

Contents?: true

Size: 687 Bytes

Versions: 1

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'after_parse callbacks' 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')
    expect(from_cb).to eq(object)
    expect(called).to eq(true)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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