Skip to content

Commit 6041911

Browse files
committed
Fixup specs and add RSpec run into CI
Minor ruby-3 kwarg issues, api changes and Symbol/String confusions wrt Hash keys. The single issue in the code is `FacebookAds::ServerSide::Event`, where normalization is not performed when it should be. Fixes 02c4351 Fixes 38f9a07 Fixes #194
1 parent cbbe949 commit 6041911

File tree

7 files changed

+25
-20
lines changed

7 files changed

+25
-20
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ jobs:
1818
ruby-version: ${{ matrix.version }}
1919
bundler-cache: true
2020

21+
- name: Run RSpec
22+
continue-on-error: ${{ matrix.ruby == 'head' }}
23+
run: bundle exec rspec
24+
2125
- name: Gem build
2226
run: gem build *.gemspec

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require spec_helper

lib/facebook_ads/ad_objects/server_side/event.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,10 @@ def normalize
411411
hash['messaging_channel'] = messaging_channel
412412
end
413413
unless original_event_data.nil?
414-
hash['original_event_data'] = original_event_data
414+
hash['original_event_data'] = original_event_data.normalize
415415
end
416416
unless attribution_data.nil?
417-
hash['attribution_data'] = attribution_data
417+
hash['attribution_data'] = attribution_data.normalize
418418
end
419419
hash
420420
end

spec/lib/facebook_ads/ad_objects/server_side/attribution_data_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
)
4040

4141
expect(attribution_data.normalize).to eq({
42-
'scope': scope,
43-
'visit_time': visit_time,
44-
'ad_id': ad_id,
45-
'adset_id': adset_id,
46-
'campaign_id': campaign_id,
47-
'attr_window': attr_window,
48-
'attribution_share': attribution_share,
49-
'attribution_model': attribution_model,
42+
'scope' => scope,
43+
'visit_time' => visit_time,
44+
'ad_id' => ad_id,
45+
'adset_id' => adset_id,
46+
'campaign_id' => campaign_id,
47+
'attr_window' => attr_window,
48+
'attribution_share' => attribution_share,
49+
'attribution_model' => attribution_model,
5050
})
5151
end
5252

spec/lib/facebook_ads/ad_objects/server_side/event_request_async_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
messages: 'message3',
4343
fbtrace_id: 'fbtrace123',
4444
}
45-
expected_response = FacebookAds::ServerSide::EventResponse.new(response)
45+
expected_response = FacebookAds::ServerSide::EventResponse.new(**response)
4646
expect(mock_ads_pixel).to receive_message_chain('events.create').with(expected_params).and_return(response)
47-
expect(FacebookAds::AdsPixel).to receive(:get).with(event_request_async.pixel_id).and_return(mock_ads_pixel)
47+
expect(FacebookAds::AdsPixel).to receive(:get).with(event_request_async.pixel_id, nil).and_return(mock_ads_pixel)
4848
promise = event_request_async.execute
4949
response = promise.value!
5050

spec/lib/facebook_ads/ad_objects/server_side/event_request_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@
136136
messages: 'message3',
137137
fbtrace_id: 'fbtrace123',
138138
}
139-
expected_response = FacebookAds::ServerSide::EventResponse.new(response)
139+
expected_response = FacebookAds::ServerSide::EventResponse.new(**response)
140140
expect(mock_ads_pixel).to receive_message_chain('events.create').with(expected_params).and_return(response)
141-
expect(FacebookAds::AdsPixel).to receive(:get).with(event_request.pixel_id).and_return(mock_ads_pixel)
141+
expect(FacebookAds::AdsPixel).to receive(:get).with(event_request.pixel_id, nil).and_return(mock_ads_pixel)
142142
response = event_request.execute
143143

144144
expect(response).to eq(expected_response)
@@ -159,9 +159,9 @@
159159
messages: 'message3',
160160
fbtrace_id: 'fbtrace123',
161161
}
162-
expected_response = FacebookAds::ServerSide::EventResponse.new(response)
162+
expected_response = FacebookAds::ServerSide::EventResponse.new(**response)
163163
expect(mock_ads_pixel).to receive_message_chain('events.create').with(expected_params).and_return(response)
164-
expect(FacebookAds::AdsPixel).to receive(:get).with(event_request.pixel_id).and_return(mock_ads_pixel)
164+
expect(FacebookAds::AdsPixel).to receive(:get).with(event_request.pixel_id, nil).and_return(mock_ads_pixel)
165165
response = event_request.execute
166166

167167
expect(response).to eq(expected_response)

spec/lib/facebook_ads/ad_objects/server_side/user_data_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
allow(FacebookAds::ServerSide::Util).to receive(:normalize) do |input, field_type|
4242
"#{field_type}_#{input}-normalized"
4343
end
44-
user_data = FacebookAds::ServerSide::UserData.new(attrs)
44+
user_data = FacebookAds::ServerSide::UserData.new(**attrs)
4545
normalized = user_data.normalize
4646

4747
expect(normalized).to eq(
@@ -83,7 +83,7 @@
8383
allow(FacebookAds::ServerSide::Util).to receive(:normalize_array) do |input, field_type|
8484
input + [field_type]
8585
end
86-
user_data = FacebookAds::ServerSide::UserData.new(attrs)
86+
user_data = FacebookAds::ServerSide::UserData.new(**attrs)
8787
normalized = user_data.normalize
8888

8989
expect(normalized).to eq(
@@ -216,8 +216,8 @@
216216
expect(user_data1).to eq(user_data2)
217217
expect(user_data1.hash).to eq(user_data2.hash)
218218

219-
user_data1 = FacebookAds::ServerSide::UserData.new(attrs)
220-
user_data2 = FacebookAds::ServerSide::UserData.new(attrs)
219+
user_data1 = FacebookAds::ServerSide::UserData.new(**attrs)
220+
user_data2 = FacebookAds::ServerSide::UserData.new(**attrs)
221221
expect(user_data1).to eq(user_data2)
222222
expect(user_data1.hash).to eq(user_data2.hash)
223223
end

0 commit comments

Comments
 (0)