Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamajvillalobos/580a89f7c88f04ac9eea6feeca31447d to your computer and use it in GitHub Desktop.
Save iamajvillalobos/580a89f7c88f04ac9eea6feeca31447d to your computer and use it in GitHub Desktop.
require 'rails_helper'
module Transformation::MultiFamily
describe TransformApartmentComplex, '.execute' do
it "puts an apartment_complex_transformer in the context" do
location_urn = { 'my-location-urn' }
etl_config = create_multi_family_etl_config
apartment_complex_transformer = double(ApartmentComplexTransformer)
ctx = create_default_ctx_hash(etl_config)
expect(ApartmentComplexTransformer).to receive(:new).with(
external_id: location_urn,
floorplans: floorplan_transformers,
floorplan_categories: floorplan_categories,
show_unit_number: true,
amenities: amenities,
call_to_actions: call_to_actions,
offer_terms: offer_terms,
no_unit_fallback_form: "form.url",
).and_return(apartment_complex_transformer)
resulting_ctx = described_class.execute(ctx)
expect(resulting_ctx.apartment_complex_transformer).
to eq(apartment_complex_transformer)
end
def create_multi_family_etl_config(location_urn)
MultiFamilyEtlConfig.new(
location_uid: 'location_uid',
show_unit_number: true,
location_setting_uid: create_location_setting(location_urn).uid
fallback_form_url: "form.url",
)
end
def create_location_setting(location_urn)
create(:location_setting, { location_urn: location_urn })
end
def create_default_ctx_hash(etl_config)
{
etl_config: etl_config,
floorplan_transformers: [double],
floorplan_categories: [double],
amenities: [double],
call_to_actions: [double],
offer_terms: [double]
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment