Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deliver][spaceship][scan] fix build warnings in rspec #21660

Merged
merged 8 commits into from Nov 24, 2023
Merged
2 changes: 0 additions & 2 deletions .circleci/config.yml
Expand Up @@ -55,8 +55,6 @@ aliases:
name: Set Ruby version
command: | # see https://circleci.com/docs/2.0/testing-ios/#using-ruby
echo "ruby-${_RUBY_VERSION}" > ~/.ruby-version
# https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-shell-command
echo 'chruby ruby-${_RUBY_VERSION}' >> $BASH_ENV

- &bundle_install
run:
Expand Down
5 changes: 3 additions & 2 deletions deliver/spec/app_screenshot_spec.rb
@@ -1,7 +1,10 @@
require 'deliver/app_screenshot'
require 'deliver/setup'
require_relative 'deliver_constants'

describe Deliver::AppScreenshot do
include DeliverConstants

def screen_size_from(path)
path.match(/{([0-9]+)x([0-9]+)}/).captures.map(&:to_i)
end
Expand All @@ -12,8 +15,6 @@ def screen_size_from(path)
end
end

ScreenSize = Deliver::AppScreenshot::ScreenSize

describe "#initialize" do
context "when filename doesn't contain 'iPad Pro (3rd generation)' or 'iPad Pro (4th generation)'" do
it "returns iPad Pro(12.9-inch)" do
Expand Down
5 changes: 5 additions & 0 deletions deliver/spec/deliver_constants.rb
@@ -0,0 +1,5 @@
require 'deliver/app_screenshot'

module DeliverConstants
ScreenSize = Deliver::AppScreenshot::ScreenSize
end
4 changes: 3 additions & 1 deletion deliver/spec/sync_screenshots_spec.rb
@@ -1,12 +1,14 @@
require 'deliver/sync_screenshots'
require 'fakefs/spec_helpers'
require_relative 'deliver_constants'

describe Deliver::SyncScreenshots do
describe '#do_replace_screeshots' do
include DeliverConstants

subject { described_class.new(app: nil, platform: nil) }

DisplayType = Spaceship::ConnectAPI::AppScreenshotSet::DisplayType
ScreenSize = Deliver::AppScreenshot::ScreenSize

before do
# To emulate checksum calculation, return the given path as a checksum
Expand Down
14 changes: 6 additions & 8 deletions scan/spec/error_handler_spec.rb
Expand Up @@ -7,19 +7,21 @@
describe "handle_build_error" do
describe "when parsing parallel test failure output" do
it "does not report a build failure" do
expect(Scan).to receive(:config).and_return({})
output = File.open('./scan/spec/fixtures/parallel_testing_failure.log', &:read)
expect do
Scan::ErrorHandler.handle_build_error(output, log_path)
end.to_not(raise_error(FastlaneCore::Interface::FastlaneBuildFailure))
end.not_to raise_error
end
end

describe "when parsing non-parallel test failure output" do
it "does not report a build failure" do
expect(Scan).to receive(:config).and_return({})
output = File.open('./scan/spec/fixtures/non_parallel_testing_failure.log', &:read)
expect do
Scan::ErrorHandler.handle_build_error(output, log_path)
end.to_not(raise_error(FastlaneCore::Interface::FastlaneBuildFailure))
end.to_not(raise_error)
lacostej marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand All @@ -40,23 +42,19 @@
end

it "mentions log above when not suppressing output", requires_xcodebuild: true do
expect(FastlaneCore::UI).to receive(:build_failure!).with("Error building the application. See the log above.")

output = File.open(output_path, &:read)
expect do
Scan::ErrorHandler.handle_build_error(output, log_path)
end.to(raise_error)
end.to(raise_error(FastlaneCore::Interface::FastlaneBuildFailure, "Error building the application. See the log above."))
end

it "mentions log file when suppressing output", requires_xcodebuild: true do
Scan.config[:suppress_xcode_output] = true

expect(FastlaneCore::UI).to receive(:build_failure!).with("Error building the application. See the log here: '#{log_path}'.")

output = File.open(output_path, &:read)
expect do
Scan::ErrorHandler.handle_build_error(output, log_path)
end.to(raise_error)
end.to(raise_error(FastlaneCore::Interface::FastlaneBuildFailure, "Error building the application. See the log here: '#{log_path}'."))
end
end
end
Expand Down
10 changes: 2 additions & 8 deletions spaceship/spec/provisioning_profile_spec.rb
Expand Up @@ -55,22 +55,16 @@
end

describe '#all via xcode api' do
around(:all) do |example|
switch = ENV['SPACESHIP_AVOID_XCODE_API']
example.run
ENV['SPACESHIP_AVOID_XCODE_API'] = switch
end
lacostej marked this conversation as resolved.
Show resolved Hide resolved

it 'should use the Xcode api to get provisioning profiles and their appIds' do
ENV['SPACESHIP_AVOID_XCODE_API'] = nil
stub_const('ENV', { "SPACESHIP_AVOID_XCODE_API" => nil })
expect(client).to receive(:provisioning_profiles_via_xcode_api).and_call_original
expect(client).not_to(receive(:provisioning_profiles))
expect(client).not_to(receive(:provisioning_profile_details))
Spaceship::ProvisioningProfile.find_by_bundle_id(bundle_id: 'some-fake-id')
end

it 'should use the developer portal api to get provisioning profiles and their appIds' do
ENV['SPACESHIP_AVOID_XCODE_API'] = 'true'
stub_const('ENV', { "SPACESHIP_AVOID_XCODE_API" => 'true' })
expect(client).not_to(receive(:provisioning_profiles_via_xcode_api))
expect(client).to receive(:provisioning_profiles).and_call_original
expect(client).to receive(:provisioning_profile_details).and_call_original.exactly(7).times
Expand Down
10 changes: 9 additions & 1 deletion spaceship/spec/tunes/device_type_spec.rb
@@ -1,5 +1,12 @@
describe Spaceship::Tunes::DeviceType do
describe "type identifiers" do
before(:each) do
# Let's catch those calls to avoid polluting the output
# Note: Warning.warn() has a different signature depending on the Ruby version, hence why we need more than one allow(...)
allow(Warning).to receive(:warn).with(/Spaceship::Tunes::DeviceType has been deprecated./)
allow(Warning).to receive(:warn).with(/Spaceship::Tunes::DeviceType has been deprecated./, { category: nil })
end

it "should be checkable using singleton functions" do
expect(Spaceship::Tunes::DeviceType.exists?("iphone6")).to be_truthy
end
Expand Down Expand Up @@ -38,8 +45,9 @@
'desktop'
]

types = Spaceship::Tunes::DeviceType.types
old_types.each do |identifier|
expect(Spaceship::Tunes::DeviceType.types).to include(identifier)
expect(types).to include(identifier)
end
end
end
Expand Down