diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b0f21ea474..d83f9656d16 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: diff --git a/deliver/spec/app_screenshot_spec.rb b/deliver/spec/app_screenshot_spec.rb index 55b140adc89..183bc8d4723 100644 --- a/deliver/spec/app_screenshot_spec.rb +++ b/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 @@ -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 diff --git a/deliver/spec/deliver_constants.rb b/deliver/spec/deliver_constants.rb new file mode 100644 index 00000000000..f90692fb37f --- /dev/null +++ b/deliver/spec/deliver_constants.rb @@ -0,0 +1,5 @@ +require 'deliver/app_screenshot' + +module DeliverConstants + ScreenSize = Deliver::AppScreenshot::ScreenSize +end diff --git a/deliver/spec/sync_screenshots_spec.rb b/deliver/spec/sync_screenshots_spec.rb index 621fca7efcf..a4c44f013ea 100644 --- a/deliver/spec/sync_screenshots_spec.rb +++ b/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 diff --git a/scan/spec/error_handler_spec.rb b/scan/spec/error_handler_spec.rb index ad3466c569a..b49078e109e 100644 --- a/scan/spec/error_handler_spec.rb +++ b/scan/spec/error_handler_spec.rb @@ -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) end end @@ -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 diff --git a/spaceship/spec/provisioning_profile_spec.rb b/spaceship/spec/provisioning_profile_spec.rb index 38f6ed79a94..0ab1e1a4a69 100644 --- a/spaceship/spec/provisioning_profile_spec.rb +++ b/spaceship/spec/provisioning_profile_spec.rb @@ -55,14 +55,8 @@ 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 - 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)) @@ -70,7 +64,7 @@ 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 diff --git a/spaceship/spec/tunes/device_type_spec.rb b/spaceship/spec/tunes/device_type_spec.rb index 4ad0d21db29..2f029159921 100644 --- a/spaceship/spec/tunes/device_type_spec.rb +++ b/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 @@ -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