Skip to content

Commit 5a100f5

Browse files
committed
update rspec tests
1 parent 4d20f7c commit 5a100f5

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

tools/fastlane-plugin/spec/send_build_to_bugsnag_spec.rb

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def run_with args
1616
context 'building an iOS project' do
1717
it 'detects default Info.plist file excluding test dirs' do
1818
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
19-
payload = ::JSON.load(body)
20-
expect(payload['versionName']).to eq '2.0-other'
21-
expect(payload['bundleVersion']).to eq '22'
22-
expect(payload['apiKey']).to eq '12345678901234567890123456789AAA'
19+
args = ::JSON.load(body)
20+
expect(args['versionName']).to eq '2.0-other'
21+
expect(args['bundleVersion']).to eq '22'
22+
expect(args['apiKey']).to eq '12345678901234567890123456789AAA'
2323
end
2424

2525
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
@@ -30,11 +30,11 @@ def run_with args
3030
it 'reads api key from legacy location' do
3131
# the API key is now in `bugsnag.apiKey`, it used to be in 'BugsnagAPIKey',
3232
# test this can be extracted correctly from the `ios_proj_legacy`
33-
expect(BuildAction).to receive(:send_notification) do |url, body|
34-
payload = ::JSON.load(body)
35-
expect(payload['versionName']).to eq '4.0-project'
36-
expect(payload['bundleVersion']).to eq '44'
37-
expect(payload['apiKey']).to eq '12345678901234567890123456789BBB'
33+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
34+
args = ::JSON.load(body)
35+
expect(args['versionName']).to eq '4.0-project'
36+
expect(args['bundleVersion']).to eq '44'
37+
expect(args['apiKey']).to eq '12345678901234567890123456789BBB'
3838
end
3939

4040
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj_legacy')) do
@@ -45,9 +45,9 @@ def run_with args
4545
context 'using default config_file option' do
4646
context 'override API key from config' do
4747
it 'reads API key from the api_key option' do
48-
expect(BuildAction).to receive(:send_notification) do |url, body|
49-
payload = ::JSON.load(body)
50-
expect(payload['apiKey']).to eq '12345678901234567890123456789FFF'
48+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
49+
args = ::JSON.load(body)
50+
expect(args['apiKey']).to eq '12345678901234567890123456789FFF'
5151
end
5252

5353
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
@@ -58,10 +58,10 @@ def run_with args
5858
end
5959

6060
it 'uses input versions from options' do
61-
expect(BuildAction).to receive(:send_notification) do |url, body|
62-
payload = ::JSON.load(body)
63-
expect(payload['versionName']).to eq '8.0.0'
64-
expect(payload['bundleVersion']).to eq '800'
61+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
62+
args = ::JSON.load(body)
63+
expect(args['versionName']).to eq '8.0.0'
64+
expect(args['bundleVersion']).to eq '800'
6565
end
6666

6767
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
@@ -76,11 +76,11 @@ def run_with args
7676

7777
context 'override config_file option' do
7878
it 'reads API key and version info from the config file' do
79-
expect(BuildAction).to receive(:send_notification) do |url, body|
80-
payload = ::JSON.load(body)
81-
expect(payload['versionName']).to eq '3.0-project'
82-
expect(payload['bundleVersion']).to eq '33'
83-
expect(payload['apiKey']).to eq '12345678901234567890123456789DDD'
79+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
80+
args = ::JSON.load(body)
81+
expect(args['versionName']).to eq '3.0-project'
82+
expect(args['bundleVersion']).to eq '33'
83+
expect(args['apiKey']).to eq '12345678901234567890123456789DDD'
8484
end
8585

8686
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
@@ -92,11 +92,11 @@ def run_with args
9292

9393
context 'override API key, and config file' do
9494
it 'uses the input api_key to override a non default config' do
95-
expect(BuildAction).to receive(:send_notification) do |url, body|
96-
payload = ::JSON.load(body)
97-
expect(payload['versionName']).to eq '3.0-project'
98-
expect(payload['bundleVersion']).to eq '33'
99-
expect(payload['apiKey']).to eq '12345678901234567890123456789EEE'
95+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
96+
args = ::JSON.load(body)
97+
expect(args['versionName']).to eq '3.0-project'
98+
expect(args['bundleVersion']).to eq '33'
99+
expect(args['apiKey']).to eq '12345678901234567890123456789EEE'
100100
end
101101

102102
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
@@ -108,11 +108,11 @@ def run_with args
108108
end
109109

110110
it 'uses the input versions to override a non default config' do
111-
expect(BuildAction).to receive(:send_notification) do |url, body|
112-
payload = ::JSON.load(body)
113-
expect(payload['versionName']).to eq '9.0.0'
114-
expect(payload['bundleVersion']).to eq '900'
115-
expect(payload['apiKey']).to eq '12345678901234567890123456789DDD'
111+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
112+
args = ::JSON.load(body)
113+
expect(args['versionName']).to eq '9.0.0'
114+
expect(args['bundleVersion']).to eq '900'
115+
expect(args['apiKey']).to eq '12345678901234567890123456789DDD'
116116
end
117117

118118
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
@@ -126,13 +126,13 @@ def run_with args
126126
end
127127
end
128128

129-
context 'metadata added to payload' do
129+
context 'metadata added to args' do
130130
it "single key:value pair added" do
131-
expect(BuildAction).to receive(:send_notification) do |url, body|
132-
payload = ::JSON.load(body)
133-
expect(payload['versionName']).to eq '4.0-project'
134-
expect(payload['apiKey']).to eq '12345678901234567890123456789DDD'
135-
expect(payload['metadata']).to eq '"test1": "First test"'
131+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
132+
args = ::JSON.load(body)
133+
expect(args['versionName']).to eq '4.0-project'
134+
expect(args['apiKey']).to eq '12345678901234567890123456789DDD'
135+
expect(args['metadata']).to eq '"test1": "First test"'
136136
end
137137

138138
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
@@ -145,11 +145,11 @@ def run_with args
145145
end
146146

147147
it "multiple key:value pairs added" do
148-
expect(BuildAction).to receive(:send_notification) do |url, body|
149-
payload = ::JSON.load(body)
150-
expect(payload['versionName']).to eq '4.0-project'
151-
expect(payload['apiKey']).to eq '12345678901234567890123456789DDD'
152-
expect(payload['metadata']).to eq '"test1": "First test", "test2": "Second test", "test3": "Third test"'
148+
expect(BuildAction).to receive(:send_notification) do |cli_path, body|
149+
args = ::JSON.load(body)
150+
expect(args['versionName']).to eq '4.0-project'
151+
expect(args['apiKey']).to eq '12345678901234567890123456789DDD'
152+
expect(args['metadata']).to eq '"test1": "First test", "test2": "Second test", "test3": "Third test"'
153153
end
154154

155155
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do

0 commit comments

Comments
 (0)