repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/onesignal_spec.rb | fastlane/spec/actions_specs/onesignal_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe 'onesignal' do
let(:app_id) { 'id123' }
let(:app_name) { 'My App' }
before :each do
stub_const('ENV', { 'ONE_SIGNAL_AUTH_KEY' => 'auth-123' })
end
context 'when params are valid' do
before :each do
allow(FastlaneCore::UI).to receive(:success).with('Driving the lane \'test\' ๐')
end
context 'and is create' do
before :each do
stub_request(:post, 'https://api.onesignal.com/apps').to_return(status: 200, body: '{}')
end
it 'outputs success message' do
expect(FastlaneCore::UI).to receive(:message).with("Parameter App name: #{app_name}")
expect(FastlaneCore::UI).to receive(:success).with('Successfully created new OneSignal app')
Fastlane::FastFile.new.parse("lane :test do
onesignal(app_name: '#{app_name}')
end").runner.execute(:test)
end
end
context 'and is update' do
before :each do
stub_request(:put, "https://api.onesignal.com/apps/#{app_id}").to_return(status: 200, body: '{}')
end
it 'outputs success message' do
expect(FastlaneCore::UI).to receive(:message).with("Parameter App ID: #{app_id}")
expect(FastlaneCore::UI).to receive(:success).with('Successfully updated OneSignal app')
Fastlane::FastFile.new.parse("lane :test do
onesignal(app_id: '#{app_id}')
end").runner.execute(:test)
end
context 'with name' do
it 'outputs success message' do
expect(FastlaneCore::UI).to receive(:message).with("Parameter App ID: #{app_id}")
expect(FastlaneCore::UI).to receive(:message).with("Parameter App name: #{app_name}")
expect(FastlaneCore::UI).to receive(:success).with('Successfully updated OneSignal app')
Fastlane::FastFile.new.parse("lane :test do
onesignal(app_id: '#{app_id}', app_name: '#{app_name}')
end").runner.execute(:test)
end
end
end
end
context 'when params are not valid' do
it 'outputs error message' do
expect do
Fastlane::FastFile.new.parse('lane :test do
onesignal()
end').runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to eq('Please specify the `app_id` or the `app_name` parameters!')
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/create_app_on_managed_play_store_spec.rb | fastlane/spec/actions_specs/create_app_on_managed_play_store_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "create_app_on_managed_play_store" do
let(:json_key_path) { File.expand_path("./fastlane/spec/fixtures/google_play/google_play.json") }
let(:json_key_data) { File.open(json_key_path, 'rb').read }
let(:mock_client) { Object.new }
describe "without :json_key or :json_key_data" do
it "without :json_key or :json_key_data - could not find file" do
expect(UI).to receive(:interactive?).and_return(true)
expect(UI).to receive(:important).with("To not be asked about this value, you can specify it using 'json_key'")
expect(UI).to receive(:input).with(anything).and_return("not_a_file")
expect do
Fastlane::FastFile.new.parse("lane :test do
create_app_on_managed_play_store()
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, /Could not find service account json file at path/)
end
it "without :json_key or :json_key_data - crashes in a not an interactive place" do
expect(UI).to receive(:interactive?).and_return(false)
expect do
Fastlane::FastFile.new.parse("lane :test do
create_app_on_managed_play_store()
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, "Could not load Google authentication. Make sure it has been added as an environment variable in 'json_key' or 'json_key_data'")
end
end
describe "with :json_key or :json_key_data" do
let(:app_title) { "App Title" }
let(:language) { "en_US" }
let(:developer_account_id) { "123456789" }
let(:apk) { "apk.apk" }
before(:each) do
allow(PlaycustomappClient).to receive(:make_from_config).with(anything).and_return(mock_client)
end
it "without :app_title" do
expect do
Fastlane::FastFile.new.parse("lane :test do
create_app_on_managed_play_store(
json_key: '#{json_key_path}'
)
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, "No value found for 'app_title'")
end
it "without :developer_account_id" do
expect do
Fastlane::FastFile.new.parse("lane :test do
create_app_on_managed_play_store(
json_key: '#{json_key_path}',
app_title: '#{app_title}'
)
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, "No value found for 'developer_account_id'")
end
it "without :apk" do
expect do
Fastlane::FastFile.new.parse("lane :test do
create_app_on_managed_play_store(
json_key: '#{json_key_path}',
app_title: '#{app_title}',
developer_account_id: '#{developer_account_id}',
apk: nil
)
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, "No value found for 'apk'")
end
describe "with :apk" do
before(:each) do
expect(File).to receive(:exist?).with('apk.apk').and_return(true)
allow(File).to receive(:exist?).with(anything).and_call_original
end
it "success" do
expect(mock_client).to receive(:create_app).with({
app_title: app_title,
language_code: language,
developer_account: developer_account_id,
apk_path: apk
})
Fastlane::FastFile.new.parse("lane :test do
create_app_on_managed_play_store(
json_key: '#{json_key_path}',
app_title: '#{app_title}',
developer_account_id: '#{developer_account_id}',
apk: '#{apk}'
)
end").runner.execute(:test)
end
it "failure with invalid :language" do
expect do
Fastlane::FastFile.new.parse("lane :test do
create_app_on_managed_play_store(
json_key: '#{json_key_path}',
app_title: '#{app_title}',
developer_account_id: '#{developer_account_id}',
apk: '#{apk}',
language: 'fast_lang'
)
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, /Please enter one of the available languages/)
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/pilot_spec.rb | fastlane/spec/actions_specs/pilot_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "pilot Integration" do
it "can use a generated changelog as release notes" do
values = Fastlane::FastFile.new.parse("lane :test do
# changelog_from_git_commits sets this lane context variable
Actions.lane_context[SharedValues::FL_CHANGELOG] = 'autogenerated changelog'
pilot
end").runner.execute(:test)
expect(values[:changelog]).to eq('autogenerated changelog')
end
it "prefers an explicitly specified changelog value" do
values = Fastlane::FastFile.new.parse("lane :test do
# changelog_from_git_commits sets this lane context variable
Actions.lane_context[SharedValues::FL_CHANGELOG] = 'autogenerated changelog'
pilot(changelog: 'custom changelog')
end").runner.execute(:test)
expect(values[:changelog]).to eq('custom changelog')
end
it "defaults distribute_only to false" do
values = Fastlane::FastFile.new.parse("lane :test do
pilot
end").runner.execute(:test)
expect(values[:distribute_only]).to eq(false)
end
it "allows setting of distribute_only to true" do
values = Fastlane::FastFile.new.parse("lane :test do
pilot(distribute_only: true)
end").runner.execute(:test)
expect(values[:distribute_only]).to eq(true)
end
describe "Test `apple_id` parameter" do
it "raises an error if `apple_id` is set to email address" do
expect do
options = {
username: "username@example.com",
apple_id: "username@example.com"
}
pilot_config = FastlaneCore::Configuration.create(Pilot::Options.available_options, options)
end.to raise_error("`apple_id` value is incorrect. The correct value should be taken from Apple ID property in the App Information section in App Store Connect.")
end
it "raises an error if `apple_id` is set to bundle identifier" do
expect do
options = {
username: "username@example.com",
apple_id: "com.bundle.identifier"
}
pilot_config = FastlaneCore::Configuration.create(Pilot::Options.available_options, options)
end.to raise_error("`apple_id` value is incorrect. The correct value should be taken from Apple ID property in the App Information section in App Store Connect.")
end
it "passes when `apple_id` is correct" do
options = {
username: "username@example.com",
apple_id: "123456789"
}
pilot_config = FastlaneCore::Configuration.create(Pilot::Options.available_options, options)
expect(pilot_config[:apple_id]).to eq('123456789')
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/ensure_xcode_version_spec.rb | fastlane/spec/actions_specs/ensure_xcode_version_spec.rb | describe Fastlane::Actions::EnsureXcodeVersionAction do
describe "matching versions" do
describe "strictly with minor version 8.0" do
let(:different_response) { "Xcode 7.3\nBuild version 34a893" }
let(:matching_response) { "Xcode 8.0\nBuild version 8A218a" }
let(:matching_response_extra_output) { "Couldn't verify that spaceship is up to date\nXcode 8.0\nBuild version 8A218a" }
it "is successful when the version matches" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.0')
end").runner.execute(:test)
end
it "matches even when there is extra output" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response_extra_output)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.0')
end").runner.execute(:test)
end
it "presents an error when the version does not match" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(different_response)
expect(UI).to receive(:user_error!).with("Selected Xcode version doesn't match your requirement.\nExpected: Xcode 8.0\nActual: Xcode 7.3\n")
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.0')
end").runner.execute(:test)
end
it "properly compares versions, not just strings" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8')
end").runner.execute(:test)
end
describe "loads a .xcode-version file if it exists" do
let(:xcode_version_path) { ".xcode-version" }
before do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response)
expect(Dir).to receive(:glob).with(".xcode-version").and_return([xcode_version_path])
end
it "succeeds if the numbers match" do
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
expect(File).to receive(:read).with(xcode_version_path).and_return("8.0")
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version
end").runner.execute(:test)
end
it "fails if the numbers don't match" do
expect(UI).to receive(:user_error!).with("Selected Xcode version doesn't match your requirement.\nExpected: Xcode 9.0\nActual: Xcode 8.0\n")
expect(File).to receive(:read).with(xcode_version_path).and_return("9.0")
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version
end").runner.execute(:test)
end
end
end
describe "strictly with patch version 8.0.1" do
let(:different_response) { "Xcode 7.3\nBuild version 34a893" }
let(:matching_response) { "Xcode 8.0.1\nBuild version 8A218a" }
let(:matching_response_extra_output) { "Couldn't verify that spaceship is up to date\nXcode 8.0.1\nBuild version 8A218a" }
it "is successful when the version matches" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.0.1')
end").runner.execute(:test)
end
it "matches even when there is extra output" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response_extra_output)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.0.1')
end").runner.execute(:test)
end
it "presents an error when the version does not match" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(different_response)
expect(UI).to receive(:user_error!).with("Selected Xcode version doesn't match your requirement.\nExpected: Xcode 8.0\nActual: Xcode 7.3\n")
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.0')
end").runner.execute(:test)
end
end
describe "loosely with 8.1.2" do
let(:different_response) { "Xcode 7.3\nBuild version 34a893" }
let(:matching_response) { "Xcode 8.1.2\nBuild version 8A218a" }
let(:matching_response_extra_output) { "Couldn't verify that spaceship is up to date\nXcode 8.1.2\nBuild version 8A218a" }
it "is successful when the version matches with patch" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.1.2', strict: false)
end").runner.execute(:test)
end
it "is successful when the version matches with minor" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.1', strict: false)
end").runner.execute(:test)
end
it "is successful when the version matches with major" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8', strict: false)
end").runner.execute(:test)
end
it "matches even when there is extra output" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(matching_response_extra_output)
expect(UI).to receive(:success).with(/Driving the lane/)
expect(UI).to receive(:success).with(/Selected Xcode version is correct/)
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.1', strict: false)
end").runner.execute(:test)
end
it "presents an error when the version does not match" do
expect(Fastlane::Actions::EnsureXcodeVersionAction).to receive(:sh).and_return(different_response)
expect(UI).to receive(:user_error!).with("Selected Xcode version doesn't match your requirement.\nExpected: Xcode 8.0\nActual: Xcode 7.3\n")
result = Fastlane::FastFile.new.parse("lane :test do
ensure_xcode_version(version: '8.0')
end").runner.execute(:test)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/upload_symbols_to_crashlytics_spec.rb | fastlane/spec/actions_specs/upload_symbols_to_crashlytics_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "upload_symbols_to_crashlytics" do
before :each do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
end
it "uploads dSYM files with app_id" do
binary_path = './spec/fixtures/screenshots/screenshot1.png'
dsym_path = './spec/fixtures/dSYM/Themoji.dSYM'
app_id = '0:000000000000:ios:0f0000000ff0ff0'
command = []
command << File.expand_path(File.join("fastlane", binary_path)).shellescape
command << "-ai #{app_id}"
command << "-p ios"
command << File.expand_path(File.join("fastlane", dsym_path)).shellescape
expect(Fastlane::Actions).to receive(:sh).with(command.join(" "), log: false)
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_path: 'fastlane/#{dsym_path}',
app_id: '#{app_id}',
binary_path: 'fastlane/#{binary_path}')
end").runner.execute(:test)
end
it "uploads dSYM files with api_token" do
binary_path = './spec/fixtures/screenshots/screenshot1.png'
dsym_path = './spec/fixtures/dSYM/Themoji.dSYM'
gsp_path = './spec/fixtures/plist/With Space.plist'
command = []
command << File.expand_path(File.join("fastlane", binary_path)).shellescape
command << "-a something123"
command << "-p ios"
command << File.expand_path(File.join("fastlane", dsym_path)).shellescape
expect(Fastlane::Actions).to receive(:sh).with(command.join(" "), log: false)
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_path: 'fastlane/#{dsym_path}',
api_token: 'something123',
binary_path: 'fastlane/#{binary_path}')
end").runner.execute(:test)
end
it "uploads dSYM files with gsp_path" do
binary_path = './spec/fixtures/screenshots/screenshot1.png'
dsym_path = './spec/fixtures/dSYM/Themoji.dSYM'
gsp_path = './spec/fixtures/plist/With Space.plist'
command = []
command << File.expand_path(File.join("fastlane", binary_path)).shellescape
command << "-gsp #{File.expand_path(File.join('fastlane', gsp_path)).shellescape}"
command << "-p ios"
command << File.expand_path(File.join("fastlane", dsym_path)).shellescape
expect(Fastlane::Actions).to receive(:sh).with(command.join(" "), log: false)
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_path: 'fastlane/#{dsym_path}',
gsp_path: 'fastlane/#{gsp_path}',
binary_path: 'fastlane/#{binary_path}')
end").runner.execute(:test)
end
it "uploads dSYM files with auto-finding gsp_path" do
binary_path = './spec/fixtures/screenshots/screenshot1.png'
dsym_path = './spec/fixtures/dSYM/Themoji.dSYM'
gsp_path = './spec/fixtures/plist/GoogleService-Info.plist'
command = []
command << File.expand_path(File.join("fastlane", binary_path)).shellescape
command << "-gsp #{File.expand_path(File.join('fastlane', gsp_path)).shellescape}"
command << "-p ios"
command << File.expand_path(File.join("fastlane", dsym_path)).shellescape
expect(Fastlane::Actions).to receive(:sh).with(command.join(" "), log: false)
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_path: 'fastlane/#{dsym_path}',
binary_path: 'fastlane/#{binary_path}')
end").runner.execute(:test)
end
it "uploads dSYM files with platform and debug params" do
dsym_path = './spec/fixtures/dSYM/Themoji.dSYM'
binary_path = './spec/fixtures/screenshots/screenshot1.png'
gsp_path = './spec/fixtures/plist/GoogleService-Info.plist'
command = []
command << File.expand_path(File.join("fastlane", binary_path)).shellescape
command << "-d"
command << "-gsp #{File.expand_path(File.join('fastlane', gsp_path)).shellescape}"
command << "-p tvos"
command << File.expand_path(File.join("fastlane", dsym_path)).shellescape
expect(Fastlane::Actions).to receive(:sh).with(command.join(" "), log: true)
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_path: 'fastlane/#{dsym_path}',
binary_path: 'fastlane/#{binary_path}',
platform: 'appletvos',
debug: true)
end").runner.execute(:test)
end
it "raises exception if no api access is given" do
allow(Fastlane::Actions::UploadSymbolsToCrashlyticsAction).to receive(:find_gsp_path).and_return(nil)
binary_path = './spec/fixtures/screenshots/screenshot1.png'
dsym_path = './spec/fixtures/dSYM/Themoji.dSYM'
expect do
result = Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_path: 'fastlane/#{dsym_path}',
binary_path: 'fastlane/#{binary_path}')
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end
it "raises exception if given gsp_path is not found" do
gsp_path = './spec/fixtures/plist/_Not Exist_.plist'
expect do
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
gsp_path: 'fastlane/#{gsp_path}',
api_token: 'something123')
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end
context "with dsym_paths" do
before :each do
# dsym_path option to be nil
ENV[Fastlane::Actions::SharedValues::DSYM_OUTPUT_PATH.to_s] = nil
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::DSYM_PATHS] = nil
allow(Dir).to receive(:[]).and_return([])
end
it "uploads dSYM files with gsp_path" do
binary_path = './spec/fixtures/screenshots/screenshot1.png'
dsym_1_path = './spec/fixtures/dSYM/Themoji.dSYM'
dsym_2_path = './spec/fixtures/dSYM/Themoji2.dSYM'
gsp_path = './spec/fixtures/plist/With Space.plist'
command = []
command << File.expand_path(File.join("fastlane", binary_path)).shellescape
command << "-gsp #{File.expand_path(File.join('fastlane', gsp_path)).shellescape}"
command << "-p ios"
command_1 = command + [File.expand_path(File.join("fastlane", dsym_1_path)).shellescape]
command_2 = command + [File.expand_path(File.join("fastlane", dsym_2_path)).shellescape]
expect(Fastlane::Actions).to receive(:sh).with(command_1.join(" "), log: false)
expect(Fastlane::Actions).to receive(:sh).with(command_2.join(" "), log: false)
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_paths: ['fastlane/#{dsym_1_path}', 'fastlane/#{dsym_2_path}'],
gsp_path: 'fastlane/#{gsp_path}',
binary_path: 'fastlane/#{binary_path}')
end").runner.execute(:test)
end
it "raises exception if a dsym_paths not found" do
binary_path = './spec/fixtures/screenshots/screenshot1.png'
dsym_1_path = './spec/fixtures/dSYM/Themoji.dSYM'
dsym_not_here_path = './spec/fixtures/dSYM/Themoji_not_here.dSYM'
gsp_path = './spec/fixtures/plist/With Space.plist'
expect do
Fastlane::FastFile.new.parse("lane :test do
upload_symbols_to_crashlytics(
dsym_paths: ['fastlane/#{dsym_1_path}', 'fastlane/#{dsym_not_here_path}'],
gsp_path: 'fastlane/#{gsp_path}',
binary_path: 'fastlane/#{binary_path}')
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/carthage_spec.rb | fastlane/spec/actions_specs/carthage_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Carthage Integration" do
it "raises an error if command is invalid" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'thisistest'
)
end").runner.execute(:test)
end.to raise_error("Please pass a valid command. Use one of the following: build, bootstrap, update, archive")
end
it "raises an error if platform is invalid" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'thisistest'
)
end").runner.execute(:test)
end.to raise_error("Please pass a valid platform. Use one of the following: all, iOS, Mac, tvOS, watchOS")
end
it "default use case is bootstrap" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "sets the command to build" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: 'build')
end").runner.execute(:test)
expect(result).to eq("carthage build")
end
it "sets the command to bootstrap" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: 'bootstrap')
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "sets the command to update" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: 'update')
end").runner.execute(:test)
expect(result).to eq("carthage update")
end
it "sets the command to archive" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: 'archive')
end").runner.execute(:test)
expect(result).to eq("carthage archive")
end
it "adds use-ssh flag to command if use_ssh is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_ssh: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --use-ssh")
end
it "doesn't add a use-ssh flag to command if use_ssh is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_ssh: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "adds use-submodules flag to command if use_submodules is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_submodules: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --use-submodules")
end
it "doesn't add a use-submodules flag to command if use_submodules is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_submodules: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "adds use-netrc flag to command if use_netrc is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_netrc: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --use-netrc")
end
it "doesn't add a use-netrc flag to command if use_netrc is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_netrc: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "adds no-use-binaries flag to command if use_binaries is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_binaries: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --no-use-binaries")
end
it "doesn't add a no-use-binaries flag to command if use_binaries is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_binaries: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "adds no-checkout flag to command if no_checkout is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
no_checkout: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --no-checkout")
end
it "adds no-build flag to command if no_build is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
no_build: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --no-build")
end
it "does not add a no-build flag to command if no_build is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
no_build: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "adds no-skip-current flag to command if no_skip_current is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'build',
no_skip_current: true
)
end").runner.execute(:test)
expect(result).to eq("carthage build --no-skip-current")
end
it "doesn't add a no-skip-current flag to command if no_skip_current is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'build',
no_skip_current: false
)
end").runner.execute(:test)
expect(result).to eq("carthage build")
end
it "adds verbose flag to command if verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
verbose: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --verbose")
end
it "does not add a verbose flag to command if verbose is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
verbose: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "sets the platform to all" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'all'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --platform all")
end
it "sets the platform to iOS" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'iOS'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --platform iOS")
end
it "sets the platform to (downcase) ios" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'ios'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --platform ios")
end
it "sets the platform to Mac" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'Mac'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --platform Mac")
end
it "sets the platform to tvOS" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'tvOS'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --platform tvOS")
end
it "sets the platform to watchOS" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'watchOS'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --platform watchOS")
end
it "can be set to multiple the platforms" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
platform: 'iOS,Mac'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --platform iOS,Mac")
end
it "sets the configuration to Release" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
configuration: 'Release'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --configuration Release")
end
it "raises an error if configuration is empty" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(
configuration: ' '
)
end").runner.execute(:test)
end.to raise_error("Please pass a valid build configuration. You can review the list of configurations for this project using the command: xcodebuild -list")
end
it "sets the toolchain to Swift_2_3" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
toolchain: 'com.apple.dt.toolchain.Swift_2_3'
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --toolchain com.apple.dt.toolchain.Swift_2_3")
end
it "sets the project directory to other" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(project_directory: 'other')
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --project-directory other")
end
it "sets the project directory to other and the toolchain to Swift_2_3" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(toolchain: 'com.apple.dt.toolchain.Swift_2_3', project_directory: 'other')
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --toolchain com.apple.dt.toolchain.Swift_2_3 --project-directory other")
end
it "does not add a cache_builds flag to command if cache_builds is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
cache_builds: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "add a cache_builds flag to command if cache_builds is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
cache_builds: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --cache-builds")
end
it "does not add a use_xcframeworks flag to command if use_xcframeworks is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_xcframeworks: false
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "add a use_xcframeworks flag to command if use_xcframeworks is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
use_xcframeworks: true
)
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --use-xcframeworks")
end
it "does not add a archive flag to command if archive is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'build',
archive: false
)
end").runner.execute(:test)
expect(result).to eq("carthage build")
end
it "add a archive flag to command if archive is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'build',
archive: true
)
end").runner.execute(:test)
expect(result).to eq("carthage build --archive")
end
it "does not set the project directory if none is provided" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap")
end
it "use custom derived data" do
path = "../derived data"
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
derived_data: '#{path}'
)
end").runner.execute(:test)
expect(result).to \
eq("carthage bootstrap --derived-data #{path.shellescape}")
end
it "use custom executable" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
executable: 'custom_carthage'
)
end").runner.execute(:test)
expect(result).to \
eq("custom_carthage bootstrap")
end
it "updates with a single dependency" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'update',
dependencies: ['TestDependency']
)
end").runner.execute(:test)
expect(result).to \
eq("carthage update TestDependency")
end
it "updates with multiple dependencies" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'update',
dependencies: ['TestDependency1', 'TestDependency2']
)
end").runner.execute(:test)
expect(result).to \
eq("carthage update TestDependency1 TestDependency2")
end
it "builds with a single dependency" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'build',
dependencies: ['TestDependency']
)
end").runner.execute(:test)
expect(result).to \
eq("carthage build TestDependency")
end
it "builds with multiple dependencies" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'build',
dependencies: ['TestDependency1', 'TestDependency2']
)
end").runner.execute(:test)
expect(result).to \
eq("carthage build TestDependency1 TestDependency2")
end
it "bootstraps with a single dependency" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'bootstrap',
dependencies: ['TestDependency']
)
end").runner.execute(:test)
expect(result).to \
eq("carthage bootstrap TestDependency")
end
it "bootstraps with multiple dependencies" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(
command: 'bootstrap',
dependencies: ['TestDependency1', 'TestDependency2']
)
end").runner.execute(:test)
expect(result).to \
eq("carthage bootstrap TestDependency1 TestDependency2")
end
it "works with no parameters" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage
end").runner.execute(:test)
end.not_to(raise_error)
end
it "works with valid parameters" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(
use_ssh: true,
use_submodules: true,
use_binaries: false,
platform: 'iOS'
)
end").runner.execute(:test)
end.not_to(raise_error)
end
it "works with cache_builds" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(
use_ssh: true,
use_submodules: true,
use_binaries: false,
cache_builds: true,
platform: 'iOS'
)
end").runner.execute(:test)
end.not_to(raise_error)
end
it "works with new resolver" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(
use_ssh: true,
use_submodules: true,
use_binaries: false,
cache_builds: true,
platform: 'iOS',
new_resolver: true
)
end").runner.execute(:test)
end.not_to(raise_error)
end
context "when specify framework" do
let(:command) { 'archive' }
context "when command is archive" do
it "adds one framework" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', frameworks: ['myframework'])
end").runner.execute(:test)
expect(result).to eq("carthage archive myframework")
end
it "adds multiple frameworks" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', frameworks: ['myframework', 'myframework2'])
end").runner.execute(:test)
expect(result).to eq("carthage archive myframework myframework2")
end
end
context "when command is update" do
let(:command) { 'update' }
it "raises an exception" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', frameworks: ['myframework', 'myframework2'])
end").runner.execute(:test)
end.to raise_error("Frameworks option is available only for 'archive' command.")
end
end
context "when command is build" do
let(:command) { 'build' }
it "raises an exception" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', frameworks: ['myframework', 'myframework2'])
end").runner.execute(:test)
end.to raise_error("Frameworks option is available only for 'archive' command.")
end
end
context "when command is bootstrap" do
let(:command) { 'bootstrap' }
it "raises an exception" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', frameworks: ['myframework', 'myframework2'])
end").runner.execute(:test)
end.to raise_error("Frameworks option is available only for 'archive' command.")
end
end
end
context "when specify output" do
let(:command) { 'archive' }
context "when command is archive" do
it "adds the output option" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', output: 'bla.framework.zip')
end").runner.execute(:test)
expect(result).to eq("carthage archive --output bla.framework.zip")
end
end
context "when command is update" do
let(:command) { 'update' }
it "raises an exception" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', output: 'bla.framework.zip')
end").runner.execute(:test)
end.to raise_error("Output option is available only for 'archive' command.")
end
end
context "when command is build" do
let(:command) { 'build' }
it "raises an exception" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', output: 'bla.framework.zip')
end").runner.execute(:test)
end.to raise_error("Output option is available only for 'archive' command.")
end
end
context "when command is bootstrap" do
let(:command) { 'bootstrap' }
it "raises an exception" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', output: 'bla.framework.zip')
end").runner.execute(:test)
end.to raise_error("Output option is available only for 'archive' command.")
end
end
end
context "when specify log_path" do
context "when command is archive" do
let(:command) { 'archive' }
it "--log-path option is not present" do
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', log_path: 'bla.log')
end").runner.execute(:test)
end.to raise_error("Log path option is available only for 'build', 'bootstrap', and 'update' command.")
end
end
context "when command is update" do
let(:command) { 'update' }
it "--log-path option is present" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', log_path: 'bla.log')
end").runner.execute(:test)
expect(result).to eq("carthage update --log-path bla.log")
end
end
context "when command is build" do
let(:command) { 'build' }
it "--log-path option is present" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', log_path: 'bla.log')
end").runner.execute(:test)
expect(result).to eq("carthage build --log-path bla.log")
end
end
context "when command is bootstrap" do
let(:command) { 'bootstrap' }
it "--log-path option is present" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', log_path: 'bla.log')
end").runner.execute(:test)
expect(result).to eq("carthage bootstrap --log-path bla.log")
end
end
context "when specify derived_data" do
context "when command is archive" do
let(:command) { 'archive' }
it "--derived-data option should not be present, even if ENV is set" do
# Stub the environment variable specifying the derived data path
stub_const('ENV', { 'FL_CARTHAGE_DERIVED_DATA' => './derived_data' })
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}')
end").runner.execute(:test)
expect(result).to eq("carthage archive")
end
end
end
context "when --use-xcframeworks option is present with valid command" do
it "adds the use_xcframeworks option" do
['update', 'build', 'bootstrap'].each do |command|
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', use_xcframeworks: true)
end").runner.execute(:test)
expect(result).to eq("carthage #{command} --use-xcframeworks")
end
end
end
end
context "when specify archive" do
context "when command is build" do
let(:command) { 'build' }
it "adds the archive option" do
result = Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', archive: true)
end").runner.execute(:test)
expect(result).to eq("carthage build --archive")
end
end
context "when archive option is present with invalid command" do
it "raises an exception" do
['archive', 'update', 'bootstrap'].each do |command|
expect do
Fastlane::FastFile.new.parse("lane :test do
carthage(command: '#{command}', archive: true)
end").runner.execute(:test)
end.to raise_error("Archive option is available only for 'build' command.")
end
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/ensure_env_vars_spec.rb | fastlane/spec/actions_specs/ensure_env_vars_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe 'ensure_env_vars' do
context 'when param is valid' do
before :each do
allow(FastlaneCore::UI).to receive(:success).with('Driving the lane \'test\' ๐')
end
context 'and env var is set' do
before :each do
allow(ENV).to receive(:[]).and_return('valid')
end
it 'outputs success message' do
expect(FastlaneCore::UI).to receive(:success).with('Environment variable \'FIRST\' is set!')
Fastlane::FastFile.new.parse('lane :test do
ensure_env_vars(env_vars: [\'FIRST\'])
end').runner.execute(:test)
end
end
context 'and env vars are set' do
before :each do
allow(ENV).to receive(:[]).and_return('valid')
end
it 'outputs success message' do
expect(FastlaneCore::UI).to receive(:success).with('Environment variables \'FIRST\', \'SECOND\' are set!')
Fastlane::FastFile.new.parse('lane :test do
ensure_env_vars(env_vars: [\'FIRST\', \'SECOND\'])
end').runner.execute(:test)
end
end
context 'and env var is not set' do
it 'outputs error message' do
expect do
Fastlane::FastFile.new.parse('lane :test do
ensure_env_vars(env_vars: [\'MISSING\'])
end').runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to eq('Missing environment variable(s) \'MISSING\'')
end
end
end
context 'and multiple env vars are not set' do
it 'outputs error message' do
expect do
Fastlane::FastFile.new.parse('lane :test do
ensure_env_vars(env_vars: [\'MISSING_FIRST\', \'MISSING_SECOND\'])
end').runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to eq('Missing environment variable(s) \'MISSING_FIRST\', \'MISSING_SECOND\'')
end
end
end
context 'and env var is empty' do
before :each do
allow(ENV).to receive(:[]).and_return(' ')
end
it 'outputs error message' do
expect do
Fastlane::FastFile.new.parse('lane :test do
ensure_env_vars(env_vars: [\'MISSING\'])
end').runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to eq('Missing environment variable(s) \'MISSING\'')
end
end
end
end
context 'when param is not valid' do
context 'because no env var is passed' do
it 'outputs error message' do
expect do
Fastlane::FastFile.new.parse('lane :test do
ensure_env_vars(env_vars: [])
end').runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to eq('Specify at least one environment variable name')
end
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/delete_keychain_spec.rb | fastlane/spec/actions_specs/delete_keychain_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Delete keychain Integration" do
before :each do
allow(File).to receive(:file?).and_return(false)
end
it "works with keychain name found locally" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
keychain = File.expand_path('test.keychain')
allow(File).to receive(:file?).and_return(false)
allow(File).to receive(:file?).with(keychain).and_return(true)
result = Fastlane::FastFile.new.parse("lane :test do
delete_keychain ({
name: 'test.keychain'
})
end").runner.execute(:test)
expect(result).to eq("security delete-keychain #{keychain}")
end
it "works with keychain name found in ~/Library/Keychains" do
keychain = File.expand_path('~/Library/Keychains/test.keychain')
allow(File).to receive(:file?).and_return(false)
allow(File).to receive(:file?).with(keychain).and_return(true)
result = Fastlane::FastFile.new.parse("lane :test do
delete_keychain ({
name: 'test.keychain'
})
end").runner.execute(:test)
expect(result).to eq("security delete-keychain #{keychain}")
end
it "works with keychain name found in ~/Library/Keychains with -db" do
keychain = File.expand_path('~/Library/Keychains/test.keychain-db')
allow(File).to receive(:file?).and_return(false)
allow(File).to receive(:file?).with(keychain).and_return(true)
result = Fastlane::FastFile.new.parse("lane :test do
delete_keychain ({
name: 'test.keychain'
})
end").runner.execute(:test)
expect(result).to eq("security delete-keychain #{keychain}")
end
it "works with keychain name that contain spaces and `\"`" do
keychain = File.expand_path('" test ".keychain')
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
allow(File).to receive(:file?).with(keychain).and_return(true)
result = Fastlane::FastFile.new.parse("lane :test do
delete_keychain ({
name: '\" test \".keychain'
})
end").runner.execute(:test)
expect(result).to eq(%(security delete-keychain #{keychain.shellescape}))
end
it "works with absolute keychain path" do
allow(File).to receive(:exist?).and_return(false)
allow(File).to receive(:exist?).with('/projects/test.keychain').and_return(true)
allow(File).to receive(:file?).with('/projects/test.keychain').and_return(true)
result = Fastlane::FastFile.new.parse("lane :test do
delete_keychain ({
keychain_path: '/projects/test.keychain'
})
end").runner.execute(:test)
expect(result).to eq("security delete-keychain /projects/test.keychain")
end
it "shows an error message if the keychain can't be found" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
expect do
Fastlane::FastFile.new.parse("lane :test do
delete_keychain ({
name: 'test.keychain'
})
end").runner.execute(:test)
end.to raise_error(/Could not locate the provided keychain/)
end
it "shows an error message if neither :name nor :keychain_path is given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
delete_keychain
end").runner.execute(:test)
end.to raise_error('You either have to set :name or :keychain_path')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/setup_jenkins_spec.rb | fastlane/spec/actions_specs/setup_jenkins_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Setup Jenkins Integration" do
before :each do
# Clean all used environment variables
Fastlane::Actions::SetupJenkinsAction::USED_ENV_NAMES + Fastlane::Actions::SetupJenkinsAction.available_options.map(&:env_name).each do |key|
ENV.delete(key)
end
end
it "doesn't work outside CI" do
stub_const("ENV", {})
expect(UI).to receive(:important).with("Not executed by Continuous Integration system.")
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins
end").runner.execute(:test)
expect(ENV["BACKUP_XCARCHIVE_DESTINATION"]).to be_nil
expect(ENV["DERIVED_DATA_PATH"]).to be_nil
expect(ENV["FL_CARTHAGE_DERIVED_DATA"]).to be_nil
expect(ENV["FL_SLATHER_BUILD_DIRECTORY"]).to be_nil
expect(ENV["GYM_BUILD_PATH"]).to be_nil
expect(ENV["GYM_CODE_SIGNING_IDENTITY"]).to be_nil
expect(ENV["GYM_DERIVED_DATA_PATH"]).to be_nil
expect(ENV["GYM_OUTPUT_DIRECTORY"]).to be_nil
expect(ENV["GYM_RESULT_BUNDLE"]).to be_nil
expect(ENV["SCAN_DERIVED_DATA_PATH"]).to be_nil
expect(ENV["SCAN_OUTPUT_DIRECTORY"]).to be_nil
expect(ENV["SCAN_RESULT_BUNDLE"]).to be_nil
expect(ENV["XCODE_DERIVED_DATA_PATH"]).to be_nil
expect(ENV["MATCH_KEYCHAIN_NAME"]).to be_nil
expect(ENV["MATCH_KEYCHAIN_PASSWORD"]).to be_nil
expect(ENV["MATCH_READONLY"]).to be_nil
end
it "works when forced" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
stub_const("ENV", {})
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins(
force: true
)
end").runner.execute(:test)
pwd = Dir.pwd
output = File.expand_path(File.join(pwd, "./output"))
derived_data = File.expand_path(File.join(pwd, "./derivedData"))
expect(ENV["BACKUP_XCARCHIVE_DESTINATION"]).to eq(output)
expect(ENV["DERIVED_DATA_PATH"]).to eq(derived_data)
expect(ENV["FL_CARTHAGE_DERIVED_DATA"]).to eq(derived_data)
expect(ENV["FL_SLATHER_BUILD_DIRECTORY"]).to eq(derived_data)
expect(ENV["GYM_BUILD_PATH"]).to eq(output)
expect(ENV["GYM_CODE_SIGNING_IDENTITY"]).to be_nil
expect(ENV["GYM_DERIVED_DATA_PATH"]).to eq(derived_data)
expect(ENV["GYM_OUTPUT_DIRECTORY"]).to eq(output)
expect(ENV["GYM_RESULT_BUNDLE"]).to eq("YES")
expect(ENV["SCAN_DERIVED_DATA_PATH"]).to eq(derived_data)
expect(ENV["SCAN_OUTPUT_DIRECTORY"]).to eq(output)
expect(ENV["SCAN_RESULT_BUNDLE"]).to eq("YES")
expect(ENV["XCODE_DERIVED_DATA_PATH"]).to eq(derived_data)
end
it "works inside CI" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
stub_const("ENV", { "JENKINS_URL" => "123" })
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins
end").runner.execute(:test)
pwd = Dir.pwd
output = File.expand_path(File.join(pwd, "output"))
derived_data = File.expand_path(File.join(pwd, "derivedData"))
expect(ENV["BACKUP_XCARCHIVE_DESTINATION"]).to eq(output)
expect(ENV["DERIVED_DATA_PATH"]).to eq(derived_data)
expect(ENV["FL_CARTHAGE_DERIVED_DATA"]).to eq(derived_data)
expect(ENV["FL_SLATHER_BUILD_DIRECTORY"]).to eq(derived_data)
expect(ENV["GYM_BUILD_PATH"]).to eq(output)
expect(ENV["GYM_CODE_SIGNING_IDENTITY"]).to be_nil
expect(ENV["GYM_DERIVED_DATA_PATH"]).to eq(derived_data)
expect(ENV["GYM_OUTPUT_DIRECTORY"]).to eq(output)
expect(ENV["GYM_RESULT_BUNDLE"]).to eq("YES")
expect(ENV["SCAN_DERIVED_DATA_PATH"]).to eq(derived_data)
expect(ENV["SCAN_OUTPUT_DIRECTORY"]).to eq(output)
expect(ENV["SCAN_RESULT_BUNDLE"]).to eq("YES")
expect(ENV["XCODE_DERIVED_DATA_PATH"]).to eq(derived_data)
end
describe "under CI" do
before :each do
stub_const("ENV", { "JENKINS_URL" => "123" })
end
it "disable keychain unlock" do
keychain_path = Tempfile.new("foo").path
ENV["KEYCHAIN_PATH"] = keychain_path
expect(UI).to receive(:message).with(/Set output directory path to:/)
expect(UI).to receive(:message).with(/Set derived data path to:/)
expect(UI).to receive(:message).with("Set result bundle.")
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins(
unlock_keychain: false
)
end").runner.execute(:test)
expect(ENV["MATCH_KEYCHAIN_NAME"]).to be_nil
expect(ENV["MATCH_KEYCHAIN_PASSWORD"]).to be_nil
expect(ENV["MATCH_READONLY"]).to be_nil
end
it "unlock keychain" do
allow(Fastlane::Actions::UnlockKeychainAction).to receive(:run).and_return(nil)
keychain_path = Tempfile.new("foo").path
ENV["KEYCHAIN_PATH"] = keychain_path
expect(UI).to receive(:message).with("Unlocking keychain: \"#{keychain_path}\".")
expect(UI).to receive(:message).with(/Set output directory path to:/)
expect(UI).to receive(:message).with(/Set derived data path to:/)
expect(UI).to receive(:message).with("Set result bundle.")
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins(
keychain_password: 'password'
)
end").runner.execute(:test)
expect(ENV["MATCH_KEYCHAIN_NAME"]).to eq(keychain_path)
expect(ENV["MATCH_KEYCHAIN_PASSWORD"]).to eq("password")
expect(ENV["MATCH_READONLY"]).to eq("true")
end
it "does not setup match if previously set" do
ENV["MATCH_KEYCHAIN_NAME"] = keychain_name = "keychain_name"
ENV["MATCH_KEYCHAIN_PASSWORD"] = keychain_password = "keychain_password"
ENV["MATCH_READONLY"] = "false"
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins
end").runner.execute(:test)
expect(ENV["MATCH_KEYCHAIN_NAME"]).to eq(keychain_name)
expect(ENV["MATCH_KEYCHAIN_PASSWORD"]).to eq(keychain_password)
expect(ENV["MATCH_READONLY"]).to eq("false")
end
it "set code signing identity" do
ENV["CODE_SIGNING_IDENTITY"] = "Code signing"
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins
end").runner.execute(:test)
expect(ENV["GYM_CODE_SIGNING_IDENTITY"]).to eq("Code signing")
end
it "disable setting code signing identity" do
ENV["CODE_SIGNING_IDENTITY"] = "Code signing"
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins(
set_code_signing_identity: false
)
end").runner.execute(:test)
expect(ENV["GYM_CODE_SIGNING_IDENTITY"]).to be_nil
end
it "set output directory" do
tmp_path = Dir.mktmpdir
directory = "#{tmp_path}/output/directory"
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins(
output_directory: '#{directory}'
)
end").runner.execute(:test)
expect(ENV["BACKUP_XCARCHIVE_DESTINATION"]).to eq(directory)
expect(ENV["GYM_BUILD_PATH"]).to eq(directory)
expect(ENV["GYM_OUTPUT_DIRECTORY"]).to eq(directory)
expect(ENV["SCAN_OUTPUT_DIRECTORY"]).to eq(directory)
end
it "set derived data" do
tmp_path = Dir.mktmpdir
directory = "#{tmp_path}/derived_data"
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins(
derived_data_path: '#{directory}'
)
end").runner.execute(:test)
expect(ENV["DERIVED_DATA_PATH"]).to eq(directory)
expect(ENV["FL_CARTHAGE_DERIVED_DATA"]).to eq(directory)
expect(ENV["FL_SLATHER_BUILD_DIRECTORY"]).to eq(directory)
expect(ENV["GYM_DERIVED_DATA_PATH"]).to eq(directory)
expect(ENV["SCAN_DERIVED_DATA_PATH"]).to eq(directory)
expect(ENV["XCODE_DERIVED_DATA_PATH"]).to eq(directory)
end
it "disable result bundle path" do
Fastlane::FastFile.new.parse("lane :test do
setup_jenkins(
result_bundle: false
)
end").runner.execute(:test)
expect(ENV["GYM_RESULT_BUNDLE"]).to be_nil
expect(ENV["SCAN_RESULT_BUNDLE"]).to be_nil
end
end
after :all do
# Clean all used environment variables
Fastlane::Actions::SetupJenkinsAction::USED_ENV_NAMES + Fastlane::Actions::SetupJenkinsAction.available_options.map(&:env_name).each do |key|
ENV.delete(key)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/gcovr_spec.rb | fastlane/spec/actions_specs/gcovr_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Gcovr Integration" do
let(:file_utils) { class_double("FileUtils").as_stubbed_const }
it "works with all parameters" do
result = Fastlane::FastFile.new.parse("lane :test do
gcovr({
object_directory: 'object_directory_value',
output: 'output_value',
keep: true,
delete: true,
filter: 'filter_value',
exclude: 'exclude_value',
gcov_filter: 'gcov_filter_value',
gcov_exclude: 'gcov_exclude_value',
root: 'root_value',
xml: true,
xml_pretty: true,
html: true,
html_details: true,
html_absolute_paths: true,
branches: true,
sort_uncovered: true,
sort_percentage: true,
gcov_executable: 'gcov_executable_value',
exclude_unreachable_branches: true,
use_gcov_files: true,
print_summary: true
})
end").runner.execute(:test)
expect(result).to eq("gcovr --object-directory \"object_directory_value\" -o \"output_value\" " \
"-k -d -f \"filter_value\" -e \"exclude_value\" --gcov-filter \"gcov_filter_value\"" \
" --gcov-exclude \"gcov_exclude_value\" -r \"root_value\" -x --xml-pretty --html --html-details" \
" --html-absolute-paths -b -u -p --gcov-executable \"gcov_executable_value\" --exclude-unreachable-branches" \
" -g -s")
end
context "output directory does not exist" do
let(:output_dir) { "./code-coverage" }
it "creates the output directory" do
expect(file_utils).to receive(:mkpath).with(output_dir)
Fastlane::FastFile.new.parse("lane :test do
gcovr({
output: '#{output_dir}/report.html'
})
end").runner.execute(:test)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/danger_spec.rb | fastlane/spec/actions_specs/danger_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "danger integration" do
before :each do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
end
it "default use case" do
result = Fastlane::FastFile.new.parse("lane :test do
danger
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
end
it "no bundle exec" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(use_bundle_exec: false)
end").runner.execute(:test)
expect(result).to eq("danger")
end
it "appends verbose" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(verbose: true)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --verbose")
end
it "sets github token" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(github_api_token: '1234')
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
expect(ENV['DANGER_GITHUB_API_TOKEN']).to eq("1234")
end
it "sets github enterprise host" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(github_enterprise_host: 'test.de')
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
expect(ENV['DANGER_GITHUB_HOST']).to eq("test.de")
end
it "sets github enterprise api base url" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(github_enterprise_api_base_url: 'https://test.de/api/v3')
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
expect(ENV['DANGER_GITHUB_API_BASE_URL']).to eq("https://test.de/api/v3")
end
it "appends danger_id" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(danger_id: 'unit-tests')
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --danger_id=unit-tests")
end
it "appends dangerfile" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(dangerfile: 'test/OtherDangerfile')
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --dangerfile=test/OtherDangerfile")
end
it "appends fail-on-errors flag when set" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(fail_on_errors: true)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --fail-on-errors=true")
end
it "does not append fail-on-errors flag when unset" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(fail_on_errors: false)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
end
it "appends new-comment flag when set" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(new_comment: true)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --new-comment")
end
it "does not append new-comment flag when unset" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(new_comment: false)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
end
it "appends remove-previous-comments flag when set" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(remove_previous_comments: true)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --remove-previous-comments")
end
it "does not append remove-previous-comments flag when unset" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(remove_previous_comments: false)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
end
it "appends base" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(base: 'master')
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --base=master")
end
it "appends head" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(head: 'master')
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --head=master")
end
it "appends fail-if-no-pr flag when set" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(fail_if_no_pr: true)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger --fail-if-no-pr=true")
end
it "does not append fail-if-no-pr flag when unset" do
result = Fastlane::FastFile.new.parse("lane :test do
danger(fail_if_no_pr: false)
end").runner.execute(:test)
expect(result).to eq("bundle exec danger")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/sigh_spec.rb | fastlane/spec/actions_specs/sigh_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "sigh Action" do
before do
require 'sigh'
@profile_path = "/tmp/something"
expect(Sigh::Manager).to receive(:start).and_return(@profile_path)
end
it "properly stores the resulting path in the lane environment" do
ENV["SIGH_UUID"] = "uuid"
ENV["SIGH_NAME"] = "name"
result = Fastlane::FastFile.new.parse("lane :test do
sigh
end").runner.execute(:test)
expect(result).to eq('uuid')
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_PATH]).to eq(@profile_path)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_PATHS]).to eq([@profile_path])
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_TYPE]).to eq("app-store")
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_UUID]).to eq("uuid")
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_NAME]).to eq("name")
end
describe "The different profile types" do
it "development" do
Fastlane::FastFile.new.parse("lane :test do
sigh(development: true)
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_TYPE]).to eq("development")
end
it "ad-hoc" do
Fastlane::FastFile.new.parse("lane :test do
sigh(adhoc: true)
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_TYPE]).to eq("ad-hoc")
end
it "enterprise" do
ENV["SIGH_PROFILE_ENTERPRISE"] = "1"
Fastlane::FastFile.new.parse("lane :test do
sigh(adhoc: true)
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_TYPE]).to eq("enterprise")
ENV.delete("SIGH_PROFILE_ENTERPRISE")
end
it "developer-id" do
Fastlane::FastFile.new.parse("lane :test do
sigh(developer_id: true)
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_TYPE]).to eq("developer-id")
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/zip_spec.rb | fastlane/spec/actions_specs/zip_spec.rb | describe Fastlane do
describe Fastlane::Actions::ZipAction do
describe "zip" do
it "sets default values for optional include and exclude parameters" do
params = { path: "Test.app" }
action = Fastlane::Actions::ZipAction::Runner.new(params)
expect(action.include).to eq([])
expect(action.exclude).to eq([])
end
end
end
describe Fastlane::FastFile do
before do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
@fixtures_path = "./fastlane/spec/fixtures/actions/zip"
@path = @fixtures_path + "/file.txt"
@output_path_with_zip = @fixtures_path + "/archive_file.zip"
@output_path_without_zip = @fixtures_path + "/archive_file"
end
describe "zip" do
it "generates a valid zip command" do
expect(Fastlane::Actions).to receive(:sh).with("zip", "-r", "#{File.expand_path(@path)}.zip", "file.txt")
result = Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@path}')
end").runner.execute(:test)
end
it "generates a valid zip command without verbose output" do
expect(Fastlane::Actions).to receive(:sh).with("zip", "-rq", "#{File.expand_path(@path)}.zip", "file.txt")
result = Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@path}', verbose: false)
end").runner.execute(:test)
end
it "generates an output path given no output path" do
result = Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@path}', output_path: '#{@path}')
end").runner.execute(:test)
expect(result).to eq(File.absolute_path("#{@path}.zip"))
end
it "generates an output path with zip extension (given zip extension)" do
result = Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@path}', output_path: '#{@output_path_with_zip}')
end").runner.execute(:test)
expect(result).to eq(File.absolute_path(@output_path_with_zip))
end
it "generates an output path with zip extension (not given zip extension)" do
result = Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@path}', output_path: '#{@output_path_without_zip}')
end").runner.execute(:test)
expect(result).to eq(File.absolute_path(@output_path_with_zip))
end
it "encrypts the contents of the zip archive using a password" do
password = "5O#RUKp0Zgop"
expect(Fastlane::Actions).to receive(:sh).with("zip", "-rq", "-P", password, "#{File.expand_path(@path)}.zip", "file.txt")
result = Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@path}', verbose: false, password: '#{password}')
end").runner.execute(:test)
end
it "archives a directory" do
expect(Fastlane::Actions).to receive(:sh).with("zip", "-r", "#{File.expand_path(@fixtures_path)}.zip", "zip")
result = Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@fixtures_path}')
end").runner.execute(:test)
end
it "invokes Actions.sh in a way which escapes arguments" do
path_basename = "My Folder (New)"
path = File.expand_path(File.join(@fixtures_path, path_basename))
output_path = File.expand_path(File.join(@fixtures_path, "My Folder (New).zip"))
password = "#Test Password"
exclude_pattern = path_basename + "/**/*.md"
expect(Fastlane::Actions).to receive(:sh).with('zip', '-r', '-P', password, output_path, path_basename, '-x', exclude_pattern).and_call_original
# With sh_helper, this is the best way to check the **escaped** shell output is to check the command it prints.
# Actions.sh will only escape inputs in some conditions, and its tricky to make sure that it was invoked in a way that did escape it.
expect(Fastlane::UI).to receive(:command).with("zip -r -P #{password.shellescape} #{output_path.shellescape} #{path_basename.shellescape} -x #{exclude_pattern.shellescape}")
Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{path}', output_path: '#{output_path}', password: '#{password}', exclude: ['**/*.md'])
end").runner.execute(:test)
end
it "supports excluding specific files or directories" do
expect(Fastlane::Actions).to receive(:sh).with("zip", "-r", "#{File.expand_path(@fixtures_path)}.zip", "zip", "-x", "zip/.git/*", "zip/README.md")
Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@fixtures_path}', exclude: ['.git/*', 'README.md'])
end").runner.execute(:test)
end
it "supports including specific files or directories" do
expect(Fastlane::Actions).to receive(:sh).with("zip", "-r", "#{File.expand_path(@fixtures_path)}.zip", "zip", "-i", "zip/**/*.rb")
Fastlane::FastFile.new.parse("lane :test do
zip(path: '#{@fixtures_path}', include: ['**/*.rb'])
end").runner.execute(:test)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/automatic_code_signing_spec.rb | fastlane/spec/actions_specs/automatic_code_signing_spec.rb | require "xcodeproj"
# 771D79501D9E69C900D840FA = demo
# 77C503031DD3175E00AC8FF0 = today
describe Fastlane do
describe "Automatic Code Signing" do
before :each do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
end
it "enable_automatic_code_signing" do
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Automatic'")
result = Fastlane::FastFile.new.parse("lane :test do
enable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', team_id: 'XXXX')
end").runner.execute(:test)
expect(result).to eq(true)
project = Xcodeproj::Project.open("./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj")
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Automatic")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Automatic")
expect(root_attrs["771D79501D9E69C900D840FA"]["DevelopmentTeam"]).to eq("XXXX")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["DevelopmentTeam"]).to eq("XXXX")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq("Automatic")
end
end
end
it "disable_automatic_code_signing for specific target" do
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Manual'")
expect(UI).to receive(:success).with("\t * today")
expect(UI).to receive(:deprecated).with("The `automatic_code_signing` action has been deprecated,")
expect(UI).to receive(:deprecated).with("Please use `update_code_signing_settings` action instead.")
expect(UI).to receive(:important).with("Skipping demo not selected (today)")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', targets: ['today'])
end").runner.execute(:test)
expect(result).to eq(false)
project = Xcodeproj::Project.open("./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj")
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Automatic")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Manual")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq(target.name == 'today' ? "Manual" : "Automatic")
end
end
end
it "disable_automatic_code_signing" do
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Manual'")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj')
end").runner.execute(:test)
expect(result).to eq(false)
project = Xcodeproj::Project.open("./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj")
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Manual")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq("Manual")
end
end
end
it "sets team id" do
# G3KGXDXQL9
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Manual'")
expect(UI).to receive(:deprecated).with("The `automatic_code_signing` action has been deprecated,")
expect(UI).to receive(:deprecated).with("Please use `update_code_signing_settings` action instead.")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: demo")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: today")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', team_id: 'G3KGXDXQL9')
end").runner.execute(:test)
expect(result).to eq(false)
project = Xcodeproj::Project.open("./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj")
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["771D79501D9E69C900D840FA"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq("Manual")
end
end
end
it "sets code sign identity" do
temp_dir = Dir.tmpdir
FileUtils.copy_entry('./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', temp_dir)
# G3KGXDXQL9
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Manual'")
expect(UI).to receive(:deprecated).with("The `automatic_code_signing` action has been deprecated,")
expect(UI).to receive(:deprecated).with("Please use `update_code_signing_settings` action instead.")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: demo")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: today")
expect(UI).to receive(:important).with("Set Code Sign identity to: iPhone Distribution for target: demo")
expect(UI).to receive(:important).with("Set Code Sign identity to: iPhone Distribution for target: today")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: '#{temp_dir}', team_id: 'G3KGXDXQL9', code_sign_identity: 'iPhone Distribution')
end").runner.execute(:test)
expect(result).to eq(false)
project = Xcodeproj::Project.open(temp_dir.to_s)
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["771D79501D9E69C900D840FA"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq("Manual")
end
target.build_configuration_list.get_setting("CODE_SIGN_IDENTITY").map do |build_config, value|
expect(value).to eq("iPhone Distribution")
end
next unless target.name == 'demo'
target.build_configuration_list.get_setting("CODE_SIGN_IDENTITY[sdk=iphoneos*]").map do |build_config, value|
expect(value).to eq("iPhone Distribution")
end
end
end
it "sets profile name" do
# G3KGXDXQL9
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Manual'")
expect(UI).to receive(:deprecated).with("The `automatic_code_signing` action has been deprecated,")
expect(UI).to receive(:deprecated).with("Please use `update_code_signing_settings` action instead.")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: demo")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: today")
expect(UI).to receive(:important).with("Set Provisioning Profile name to: Mindera for target: demo")
expect(UI).to receive(:important).with("Set Provisioning Profile name to: Mindera for target: today")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', team_id: 'G3KGXDXQL9', profile_name: 'Mindera')
end").runner.execute(:test)
expect(result).to eq(false)
project = Xcodeproj::Project.open("./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj")
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["771D79501D9E69C900D840FA"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq("Manual")
end
target.build_configuration_list.get_setting("PROVISIONING_PROFILE_SPECIFIER").map do |build_config, value|
expect(value).to eq("Mindera")
end
end
end
it "sets profile uuid" do
# G3KGXDXQL9
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Manual'")
expect(UI).to receive(:deprecated).with("The `automatic_code_signing` action has been deprecated,")
expect(UI).to receive(:deprecated).with("Please use `update_code_signing_settings` action instead.")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: demo")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: today")
expect(UI).to receive(:important).with("Set Provisioning Profile UUID to: 1337 for target: demo")
expect(UI).to receive(:important).with("Set Provisioning Profile UUID to: 1337 for target: today")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', team_id: 'G3KGXDXQL9', profile_uuid: '1337')
end").runner.execute(:test)
expect(result).to eq(false)
project = Xcodeproj::Project.open("./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj")
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["771D79501D9E69C900D840FA"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq("Manual")
end
target.build_configuration_list.get_setting("PROVISIONING_PROFILE").map do |build_config, value|
expect(value).to eq("1337")
end
end
end
it "sets bundle identifier" do
# G3KGXDXQL9
allow(UI).to receive(:success)
expect(UI).to receive(:success).with("Successfully updated project settings to use Code Sign Style = 'Manual'")
expect(UI).to receive(:deprecated).with("The `automatic_code_signing` action has been deprecated,")
expect(UI).to receive(:deprecated).with("Please use `update_code_signing_settings` action instead.")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: demo")
expect(UI).to receive(:important).with("Set Team id to: G3KGXDXQL9 for target: today")
expect(UI).to receive(:important).with("Set Bundle identifier to: com.fastlane.mindera.cosigner for target: demo")
expect(UI).to receive(:important).with("Set Bundle identifier to: com.fastlane.mindera.cosigner for target: today")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', team_id: 'G3KGXDXQL9', bundle_identifier: 'com.fastlane.mindera.cosigner')
end").runner.execute(:test)
expect(result).to eq(false)
project = Xcodeproj::Project.open("./fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj")
root_attrs = project.root_object.attributes["TargetAttributes"]
expect(root_attrs["771D79501D9E69C900D840FA"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["ProvisioningStyle"]).to eq("Manual")
expect(root_attrs["771D79501D9E69C900D840FA"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
expect(root_attrs["77C503031DD3175E00AC8FF0"]["DevelopmentTeam"]).to eq("G3KGXDXQL9")
project.targets.each do |target|
target.build_configuration_list.get_setting("CODE_SIGN_STYLE").map do |build_config, value|
expect(value).to eq("Manual")
end
target.build_configuration_list.get_setting("PRODUCT_BUNDLE_IDENTIFIER").map do |build_config, value|
expect(value).to eq("com.fastlane.mindera.cosigner")
end
end
end
it "targets not found notice" do
allow(UI).to receive(:important)
expect(UI).to receive(:deprecated).with("The `automatic_code_signing` action has been deprecated,")
expect(UI).to receive(:deprecated).with("Please use `update_code_signing_settings` action instead.")
expect(UI).to receive(:important).with("None of the specified targets has been modified")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic_code_signing.xcodeproj', targets: ['not_found'])
end").runner.execute(:test)
expect(result).to eq(false)
end
it "raises exception on old projects" do
expect(UI).to receive(:user_error!).with("Seems to be a very old project file format - please open your project file in a more recent version of Xcode")
result = Fastlane::FastFile.new.parse("lane :test do
disable_automatic_code_signing(path: './fastlane/spec/fixtures/xcodeproj/automatic-code-signing-old.xcodeproj')
end").runner.execute(:test)
expect(result).to eq(false)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/app_store_connect_api_key_spec.rb | fastlane/spec/actions_specs/app_store_connect_api_key_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "App Store Connect API Key" do
let(:fake_api_key_p8_path) { File.absolute_path("./spaceship/spec/connect_api/fixtures/asc_key.p8") }
let(:fake_api_key_json_path) { "./spaceship/spec/connect_api/fixtures/asc_key.json" }
let(:fake_api_key_in_house_json_path) { "./spaceship/spec/connect_api/fixtures/asc_key_in_house.json" }
let(:key_id) { "D484D98393" }
let(:issuer_id) { "32423-234234-234324-234" }
it "with key_filepath" do
hash = {
key_id: key_id,
issuer_id: issuer_id,
key: File.binread(fake_api_key_p8_path),
is_key_content_base64: false,
duration: 500,
in_house: false
}
expect(Spaceship::ConnectAPI::Token).to receive(:create).with(hash).and_return("some fake token")
expect(Spaceship::ConnectAPI).to receive(:token=).with("some fake token")
result = Fastlane::FastFile.new.parse("lane :test do
app_store_connect_api_key(
key_id: '#{key_id}',
issuer_id: '#{issuer_id}',
key_filepath: '#{fake_api_key_p8_path}',
)
end").runner.execute(:test)
expect(result).to eq(hash)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY]).to eq(hash)
end
describe "with key_content" do
let(:key_content) { File.binread(fake_api_key_p8_path).gsub("\r", '') }
it "with plain text" do
hash = {
key_id: key_id,
issuer_id: issuer_id,
key: key_content,
is_key_content_base64: false,
duration: 200,
in_house: true
}
expect(Spaceship::ConnectAPI::Token).to receive(:create).with(hash).and_return("some fake token")
expect(Spaceship::ConnectAPI).to receive(:token=).with("some fake token")
result = Fastlane::FastFile.new.parse("lane :test do
app_store_connect_api_key(
key_id: '#{key_id}',
issuer_id: '#{issuer_id}',
key_content: '#{key_content}',
duration: 200,
in_house: true
)
end").runner.execute(:test)
expect(result).to eq(hash)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY]).to eq(hash)
end
it "with base64 encoded" do
hash = {
key_id: key_id,
issuer_id: issuer_id,
key: key_content,
is_key_content_base64: true,
duration: 200,
in_house: true
}
expect(Spaceship::ConnectAPI::Token).to receive(:create).with(hash).and_return("some fake token")
expect(Spaceship::ConnectAPI).to receive(:token=).with("some fake token")
result = Fastlane::FastFile.new.parse("lane :test do
app_store_connect_api_key(
key_id: '#{key_id}',
issuer_id: '#{issuer_id}',
key_content: '#{key_content}',
is_key_content_base64: true,
duration: 200,
in_house: true
)
end").runner.execute(:test)
expect(result).to eq(hash)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY]).to eq(hash)
end
end
it "raise error when no key_filepath or key_content" do
expect do
Fastlane::FastFile.new.parse("lane :test do
app_store_connect_api_key(
key_id: '#{key_id}',
issuer_id: '#{issuer_id}'
)
end").runner.execute(:test)
end.to raise_error(/:key_content or :key_filepath is required/)
end
it "raise error when duration is higher than 20 minutes" do
expect do
Fastlane::FastFile.new.parse("lane :test do
app_store_connect_api_key(
key_id: 'foo',
issuer_id: 'bar',
key_content: 'derp',
duration: 1300
)
end").runner.execute(:test)
end.to raise_error("The duration can't be more than 1200 (20 minutes) and the value entered was '1300'")
end
it "doesn't create and set api token if 'set_spaceship_token' input option is FALSE" do
expect(Spaceship::ConnectAPI::Token).not_to receive(:create)
expect(Spaceship::ConnectAPI).not_to receive(:token=)
result = Fastlane::FastFile.new.parse("lane :test do
app_store_connect_api_key(
key_id: '#{key_id}',
issuer_id: '#{issuer_id}',
key_filepath: '#{fake_api_key_p8_path}',
set_spaceship_token: false
)
end").runner.execute(:test)
hash = {
key_id: key_id,
issuer_id: issuer_id,
key: File.binread(fake_api_key_p8_path),
is_key_content_base64: false,
duration: 500,
in_house: false
}
expect(result).to eq(hash)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY]).to eq(hash)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/install_xcode_plugin_spec.rb | fastlane/spec/actions_specs/install_xcode_plugin_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "install_xcode_plugin" do
it "downloads plugin using argument-safe curl invocation" do
tmp_home = Dir.mktmpdir
stub_const('ENV', ENV.to_hash.merge('HOME' => tmp_home))
plugins_path = "#{tmp_home}/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
url = "https://example.com/plugin.zip; touch /tmp/fastlane_pwned"
expect(FileUtils).to receive(:mkdir_p).with(plugins_path)
expect(Fastlane::Action).to receive(:sh).with("curl", "-L", "-s", "-o", kind_of(String), url)
expect(Fastlane::Action).to receive(:sh).with("unzip", "-qo", kind_of(String), "-d", plugins_path)
Fastlane::FastFile.new.parse("lane :test do
install_xcode_plugin(url: '#{url}')
end").runner.execute(:test)
ensure
FileUtils.remove_entry(tmp_home) if tmp_home && File.directory?(tmp_home)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/restore_file_spec.rb | fastlane/spec/actions_specs/restore_file_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Backup file Integration" do
tmp_path = Dir.mktmpdir
let(:test_path) { "#{tmp_path}/tests/fastlane" }
let(:file_path) { "file.txt" }
let(:backup_path) { "#{file_path}.back" }
let(:file_content) { Time.now.to_s }
before do
FileUtils.mkdir_p(test_path)
File.write(File.join(test_path, file_path), file_content)
end
describe "when use action after `backup_file` action" do
before do
Fastlane::FastFile.new.parse("lane :test do
backup_file path: '#{File.join(test_path, file_path)}'
end").runner.execute(:test)
File.write(File.join(test_path, file_path), file_content.reverse)
end
it "should be restore file" do
Fastlane::FastFile.new.parse("lane :test do
restore_file path: '#{File.join(test_path, file_path)}'
end").runner.execute(:test)
restored_file = File.read(File.join(test_path, file_path))
expect(restored_file).to include(file_content)
expect(File).not_to(exist(File.join(test_path, backup_path)))
end
end
describe "when use action without `backup_file` action" do
it "should raise error" do
expect do
Fastlane::FastFile.new.parse("lane :test do
restore_file path: '#{File.join(test_path, file_path)}'
end").runner.execute(:test)
end.to raise_error("Could not find file '#{File.join(test_path, backup_path)}'")
end
end
after do
File.delete(File.join(test_path, backup_path)) if File.exist?(File.join(test_path, backup_path))
File.delete(File.join(test_path, file_path))
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/say_spec.rb | fastlane/spec/actions_specs/say_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Say Integration" do
describe "saying" do
it "works with array" do
expect(Fastlane::Actions).to receive(:sh)
.with('say \'Hi Felix Good Job\'')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say(['Hi Felix', 'Good Job'])
end").runner.execute(:test)
expect(result).to eq('say \'Hi Felix Good Job\'')
end
it "works with string" do
expect(Fastlane::Actions).to receive(:sh)
.with('say \'Hi Josh Good Job\'')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say('Hi Josh Good Job')
end").runner.execute(:test)
expect(result).to eq('say \'Hi Josh Good Job\'')
end
it "works with options array" do
expect(Fastlane::Actions).to receive(:sh)
.with('say \'Hi Felix Good Job\'')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say(text: ['Hi Felix', 'Good Job'])
end").runner.execute(:test)
expect(result).to eq('say \'Hi Felix Good Job\'')
end
it "works with options string" do
expect(Fastlane::Actions).to receive(:sh)
.with('say \'Hi Josh Good Job\'')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say(text: 'Hi Josh Good Job')
end").runner.execute(:test)
expect(result).to eq('say \'Hi Josh Good Job\'')
end
end
describe "muted" do
before do
stub_const('ENV', { 'SAY_MUTE' => 'true' })
end
it "works with array" do
expect(Fastlane::UI).to receive(:message)
.with('Hi Felix Good Job')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say(['Hi Felix', 'Good Job'])
end").runner.execute(:test)
expect(result).to eq('Hi Felix Good Job')
end
it "works with string" do
expect(Fastlane::UI).to receive(:message)
.with('Hi Josh Good Job')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say('Hi Josh Good Job')
end").runner.execute(:test)
expect(result).to eq('Hi Josh Good Job')
end
it "works with options array" do
expect(Fastlane::UI).to receive(:message)
.with('Hi Felix Good Job')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say(text: ['Hi Felix', 'Good Job'])
end").runner.execute(:test)
expect(result).to eq('Hi Felix Good Job')
end
it "works with options string" do
expect(Fastlane::UI).to receive(:message)
.with('Hi Josh Good Job')
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
say(text: 'Hi Josh Good Job')
end").runner.execute(:test)
expect(result).to eq('Hi Josh Good Job')
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/cocoapods_spec.rb | fastlane/spec/actions_specs/cocoapods_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Cocoapods Integration" do
before :each do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
end
describe "#pod_version_at_least" do
describe "pod version 1.6" do
let(:params) { {} }
before :each do
allow(Fastlane::Actions::CocoapodsAction).to receive(:pod_version).and_return("1.6.0")
end
it "returns false for at least 1.7" do
expect(Fastlane::Actions::CocoapodsAction.pod_version_at_least("1.7", params)).to be(false)
end
it "returns false for at least 1.10" do
expect(Fastlane::Actions::CocoapodsAction.pod_version_at_least("1.10", params)).to be(false)
end
end
describe "pod version 1.10" do
let(:params) { {} }
before :each do
allow(Fastlane::Actions::CocoapodsAction).to receive(:pod_version).and_return("1.10.0")
end
it "returns false for at least 1.7" do
expect(Fastlane::Actions::CocoapodsAction.pod_version_at_least("1.7", params)).to be(true)
end
it "returns false for at least 1.10" do
expect(Fastlane::Actions::CocoapodsAction.pod_version_at_least("1.10", params)).to be(true)
end
end
end
it "default use case" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install")
end
it "default use case with no bundle exec" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(use_bundle_exec: false)
end").runner.execute(:test)
expect(result).to eq("pod install")
end
it "adds no-clean to command if clean is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
clean: false
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --no-clean")
end
it "adds no-integrate to command if integrate is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
integrate: false
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --no-integrate")
end
it "adds repo-update to command if repo_update is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
repo_update: true
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --repo-update")
end
it "add clean_install to command if clean_install is set to true, and pod version is 1.7 and over" do
allow(Fastlane::Actions::CocoapodsAction).to receive(:pod_version).and_return('1.7')
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
clean_install: true
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --clean-install")
end
describe "allow_root" do
it "skips allow_root to command if allow_root is set to true, and pod version is 1.1 and over" do
allow(Fastlane::Actions::CocoapodsAction).to receive(:pod_version).and_return('1.1')
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
allow_root: false
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install")
end
it "add allow_root to command if allow_root is set to true, and pod version is 1.10 and over" do
allow(Fastlane::Actions::CocoapodsAction).to receive(:pod_version).and_return('1.10')
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
allow_root: true
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --allow-root")
end
end
it "does not add clean_install to command if clean_install is set to true, and pod version is less than 1.7" do
allow(Fastlane::Actions::CocoapodsAction).to receive(:pod_version).and_return('1.6')
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
clean_install: true
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install")
end
it "adds silent to command if silent is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
silent: true
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --silent")
end
it "adds verbose to command if verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
verbose: true
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --verbose")
end
it "adds no-ansi to command if ansi is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
ansi: false
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --no-ansi")
end
it "adds deployment to command if deployment is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
deployment: true
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install --deployment")
end
it "changes directory if podfile is set to the Podfile path" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
podfile: 'Project/Podfile'
)
end").runner.execute(:test)
expect(result).to eq("cd 'Project' && bundle exec pod install")
end
it "changes directory if podfile is set to a directory" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
podfile: 'Project'
)
end").runner.execute(:test)
expect(result).to eq("cd 'Project' && bundle exec pod install")
end
it "adds error_callback to command" do
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
error_callback: lambda { |result| puts 'failure' }
)
end").runner.execute(:test)
expect(result).to eq("bundle exec pod install")
end
it "error_callback is executed on failure" do
error_callback = double('error_callback')
allow(Fastlane::Actions).to receive(:sh_control_output) {
expect(Fastlane::Actions).to have_received(:sh_control_output).with(kind_of(String),
hash_including(error_callback: error_callback))
}
end
it "retries with --repo-update on error if try_repo_update_on_error is true" do
allow(Fastlane::Actions).to receive(:sh_control_output) { |command, params|
if command == 'bundle exec pod install'
error_callback = params[:error_callback]
error_callback.call('error')
end
}
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
try_repo_update_on_error: true
)
end").runner.execute(:test)
expect(Fastlane::Actions).to have_received(:sh_control_output).with("bundle exec pod install", hash_including(print_command: true)).ordered
expect(Fastlane::Actions).to have_received(:sh_control_output).with("bundle exec pod install --repo-update", hash_including(print_command: true)).ordered
end
it 'doesnt retry with --repo-update if there were no errors' do
allow(Fastlane::Actions).to receive(:sh_control_output) {}
result = Fastlane::FastFile.new.parse("lane :test do
cocoapods(
try_repo_update_on_error: true
)
end").runner.execute(:test)
expect(Fastlane::Actions).to have_received(:sh_control_output).with("bundle exec pod install", hash_including(print_command: true)).ordered
expect(Fastlane::Actions).to_not(have_received(:sh_control_output).with("bundle exec pod install --repo-update", hash_including(print_command: true)).ordered)
end
it "calls error_callback if retry with --repo-update finished with error" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return('.')
allow(Fastlane::Actions).to receive(:sh_control_output) { |_, params|
error_callback = params[:error_callback]
error_callback.call('error')
}
expect do
Fastlane::FastFile.new.parse("lane :test do
cocoapods(
try_repo_update_on_error: true,
error_callback: lambda { |r| raise r }
)
end").runner.execute(:test)
end.to raise_error('error')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/create_keychain_spec.rb | fastlane/spec/actions_specs/create_keychain_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Create keychain Integration" do
context "with name and password options" do
it "works when keychain doesn't exist" do
allow(Fastlane::Actions::CreateKeychainAction).to receive(:list_keychains).and_return(
# first time
[File.expand_path('~/Library/Keychains/login.keychain-db')],
# after creation
[File.expand_path('~/Library/Keychains/login.keychain-db'), File.expand_path('~/Library/Keychains/test.keychain')]
)
allow(Fastlane::Actions::CreateKeychainAction).to receive(:resolved_keychain_path).and_return(
nil,
File.expand_path('~/Library/Keychains/test.keychain')
)
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
})
end").runner.execute(:test)
expect(result.size).to eq(3)
expect(result[0]).to eq('security create-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[1]).to start_with('security set-keychain-settings')
expect(result[1]).to include('-t 300')
expect(result[1]).to_not(include('-l'))
expect(result[1]).to_not(include('-u'))
expect(result[1]).to include('~/Library/Keychains/test.keychain')
expect(result[2]).to start_with("security list-keychains -s")
expect(result[2]).to end_with(File.expand_path('~/Library/Keychains/test.keychain').to_s)
end
it "work when keychain already exist" do
allow(Fastlane::Actions::CreateKeychainAction).to receive(:list_keychains).and_return(
[File.expand_path('~/Library/Keychains/login.keychain-db'), File.expand_path('~/Library/Keychains/test.keychain')]
)
allow(Fastlane::Actions::CreateKeychainAction).to receive(:resolved_keychain_path).and_return(
File.expand_path('~/Library/Keychains/test.keychain')
)
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
})
end").runner.execute(:test)
expect(result.size).to eq(1)
expect(result[0]).to start_with('security set-keychain-settings')
expect(result[0]).to include('-t 300')
expect(result[0]).to_not(include('-l'))
expect(result[0]).to_not(include('-u'))
expect(result[0]).to include('~/Library/Keychains/test.keychain')
end
it "works with a password that contain spaces or `\"`" do
password = "\"test password\""
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: '#{password}',
})
end").runner.execute(:test)
expect(result.size).to eq(3)
expect(result[0]).to eq(%(security create-keychain -p #{password.shellescape} ~/Library/Keychains/test.keychain))
end
it "works with keychain-settings" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
timeout: 600,
lock_when_sleeps: true,
lock_after_timeout: true,
})
end").runner.execute(:test)
expect(result.size).to eq(3)
expect(result[0]).to eq('security create-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[1]).to start_with('security set-keychain-settings')
expect(result[1]).to include('-t 600')
expect(result[1]).to include('-l')
expect(result[1]).to include('-u')
expect(result[1]).to include('~/Library/Keychains/test.keychain')
end
it "works with default_keychain" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
default_keychain: true,
})
end").runner.execute(:test)
expect(result.size).to eq(4)
expect(result[0]).to eq('security create-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[1]).to eq('security default-keychain -s ~/Library/Keychains/test.keychain')
expect(result[2]).to start_with('security set-keychain-settings')
expect(result[2]).to include('-t 300')
expect(result[2]).to_not(include('-l'))
expect(result[2]).to_not(include('-u'))
expect(result[2]).to include('~/Library/Keychains/test.keychain')
end
it "works with unlock" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
unlock: true,
})
end").runner.execute(:test)
expect(result.size).to eq(4)
expect(result[0]).to eq('security create-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[1]).to eq('security unlock-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[2]).to start_with('security set-keychain-settings')
expect(result[2]).to include('-t 300')
expect(result[2]).to_not(include('-l'))
expect(result[2]).to_not(include('-u'))
expect(result[2]).to include('~/Library/Keychains/test.keychain')
end
it "works with 'timeout: 0' to specify 'no timeout', skips -t param" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
unlock: true,
timeout: 0
})
end").runner.execute(:test)
expect(result.size).to eq(4)
expect(result[0]).to eq('security create-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[1]).to eq('security unlock-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[2]).to start_with('security set-keychain-settings')
expect(result[2]).to_not(include('-t'))
expect(result[2]).to_not(include('-l'))
expect(result[2]).to_not(include('-u'))
expect(result[2]).to include('~/Library/Keychains/test.keychain')
end
it "works with all params" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
default_keychain: true,
unlock: true,
timeout: 600,
lock_when_sleeps: true,
lock_after_timeout: true,
add_to_search_list: false,
})
end").runner.execute(:test)
expect(result.size).to eq(4)
expect(result[0]).to eq('security create-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[1]).to eq('security default-keychain -s ~/Library/Keychains/test.keychain')
expect(result[2]).to eq('security unlock-keychain -p testpassword ~/Library/Keychains/test.keychain')
expect(result[3]).to start_with('security set-keychain-settings')
expect(result[3]).to include('-t 600')
expect(result[3]).to include('-l')
expect(result[3]).to include('-u')
expect(result[3]).to include('~/Library/Keychains/test.keychain')
end
it "sets the correct keychain path" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
name: 'test.keychain',
password: 'testpassword',
default_keychain: true,
})
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::KEYCHAIN_PATH]).to eq('~/Library/Keychains/test.keychain')
end
end
context "with path and password options" do
it "successfully creates the keychain" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
path: '/tmp/test.keychain',
password: 'testpassword',
default_keychain: true,
unlock: true,
timeout: 600,
lock_when_sleeps: true,
lock_after_timeout: true,
add_to_search_list: false,
})
end").runner.execute(:test)
expect(result.size).to eq(4)
expect(result[0]).to eq('security create-keychain -p testpassword /tmp/test.keychain')
expect(result[1]).to eq('security default-keychain -s /tmp/test.keychain')
expect(result[2]).to eq('security unlock-keychain -p testpassword /tmp/test.keychain')
expect(result[3]).to start_with('security set-keychain-settings')
expect(result[3]).to include('-t 600')
expect(result[3]).to include('-l')
expect(result[3]).to include('-u')
expect(result[3]).to include('/tmp/test.keychain')
end
it "sets the correct keychain path" do
result = Fastlane::FastFile.new.parse("lane :test do
create_keychain ({
path: '/tmp/test.keychain',
password: 'testpassword',
default_keychain: true,
})
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::KEYCHAIN_PATH]).to eq('/tmp/test.keychain')
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/appstore_spec.rb | fastlane/spec/actions_specs/appstore_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "AppStore Action" do
it "is an alias for the deliver action" do
result = Fastlane::FastFile.new.parse("lane :test do
appstore(skip_metadata: true)
end").runner.execute(:test)
expect(result[:skip_metadata]).to eq(true)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/github_api_spec.rb | fastlane/spec/actions_specs/github_api_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "github_api" do
let(:response_body) { File.read("./fastlane/spec/fixtures/requests/github_create_file_response.json") }
let(:user_agent) { 'fastlane-github_api' }
let(:headers) do
{
'Authorization' => 'Basic MTIzNDU2Nzg5',
'Host' => 'api.github.com:443',
'User-Agent' => user_agent
}
end
let(:headers_bearer) do
{
'Authorization' => 'Bearer 123456789',
'Host' => 'api.github.com:443',
'User-Agent' => user_agent
}
end
context 'successful' do
context 'with api_token' do
before do
stub_request(:put, "https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md").
with(headers: headers).
to_return(status: 200, body: response_body, headers: {})
end
context 'with a hash body' do
it 'correctly submits to github api' do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: {
path: 'TEST_FILE.md',
message: 'File committed',
content: 'VGVzdCBDb250ZW50Cg==\n',
branch: 'test-branch'
}
)
end
").runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
end
context 'with an array body' do
it 'correctly submits to github api' do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: %w(foo bar),
)
end
").runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
end
context 'with raw JSON body' do
it 'correctly submits to github api' do
result = Fastlane::FastFile.new.parse(%{
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: '{
"path":"TEST_FILE.md",
"message":"File committed",
"content":"VGVzdCBDb250ZW50Cg==\\\\n",
"branch":"test-branch"
}'
)
end
}).runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
end
it 'allows calling as a block for success from other actions' do
expect do
Fastlane::FastFile.new.parse(%{
lane :test do
Fastlane::Actions::GithubApiAction.run(
server_url: 'https://api.github.com',
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: '{
"path":"TEST_FILE.md",
"message":"File committed",
"content":"VGVzdCBDb250ZW50Cg==\\\\n",
"branch":"test-branch"
}'
) do |result|
UI.user_error!("Success block triggered with \#{result[:body]}")
end
end
}).runner.execute(:test)
end.to(
raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to match("Success block triggered with #{response_body}")
end
)
end
context 'optional params' do
let(:response_body) { File.read("./fastlane/spec/fixtures/requests/github_upload_release_asset_response.json") }
let(:headers) do
{
'Authorization' => 'Basic MTIzNDU2Nzg5',
'Host' => 'uploads.github.com:443',
'User-Agent' => user_agent
}
end
before do
stub_request(:post, "https://uploads.github.com/repos/fastlane/fastlane/releases/1/assets?name=TEST_FILE.md").
with(body: "test raw content of file",
headers: headers).
to_return(status: 200, body: response_body, headers: {})
end
context 'full url and raw body' do
it 'allows overrides and sends raw full values' do
result = Fastlane::FastFile.new.parse(%{
lane :test do
github_api(
api_token: '123456789',
http_method: 'POST',
url: 'https://uploads.github.com/repos/fastlane/fastlane/releases/1/assets?name=TEST_FILE.md',
raw_body: 'test raw content of file'
)
end
}).runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
end
context 'overridable headers' do
let(:headers) do
{
'Authorization' => 'custom',
'Host' => 'uploads.github.com:443',
'User-Agent' => 'fastlane-custom-user-agent',
'Content-Type' => 'text/plain'
}
end
it 'allows calling with custom headers and override auth' do
result = Fastlane::FastFile.new.parse(%{
lane :test do
github_api(
api_token: '123456789',
http_method: 'POST',
headers: {
'Content-Type' => 'text/plain',
'Authorization' => 'custom',
'User-Agent' => 'fastlane-custom-user-agent'
},
url: 'https://uploads.github.com/repos/fastlane/fastlane/releases/1/assets?name=TEST_FILE.md',
raw_body: 'test raw content of file'
)
end
}).runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
end
end
context "url isn't set" do
context "path is set, server_url isn't set" do
it "uses default server_url" do
expect do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md'
)
end
").runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:html_url]).to eq("https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md")
end
end
end
context "path and server_url are set" do
it "correctly submits by building the full url from server_url and path" do
expect do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
server_url: 'https://api.github.com'
)
end
").runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:html_url]).to eq("https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md")
end
end
end
end
context "url is set" do
context "path and server_url are set" do
it "correctly submits using the path and server_url instead of the url" do
expect do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
url: 'https://api.github.com/repos/fastlane/fastlane/contents/NONEXISTENT_TEST_FILE.md',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
server_url: 'https://api.github.com'
)
end
").runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:html_url]).to eq("https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md")
expect(result[:html_url]).to_not(eq("https://api.github.com/repos/fastlane/fastlane/contents/NONEXISTENT_TEST_FILE.md"))
end
end
end
context "path and server_url aren't set" do
it "correctly submits using the full url" do
expect do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
url: 'https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md'
)
end
").runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:html_url]).to eq("https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md")
end
end
end
context 'secure is set' do
it 'correctly submits without ssl verification' do
Excon.defaults[:ssl_verify_peer] = true
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
secure: false
)
end
").runner.execute(:test)
expect(Excon.defaults[:ssl_verify_peer]).to eq(false)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
it 'correctly submits with ssl verification' do
Excon.defaults[:ssl_verify_peer] = false
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
secure: true
)
end
").runner.execute(:test)
expect(Excon.defaults[:ssl_verify_peer]).to eq(true)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
it 'correctly submits using default verification' do
Excon.defaults[:ssl_verify_peer] = false
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md'
)
end
").runner.execute(:test)
expect(Excon.defaults[:ssl_verify_peer]).to eq(true)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
end
end
end
context 'with api_bearer' do
before do
stub_request(:put, "https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md").
with(headers: headers_bearer).
to_return(status: 200, body: response_body, headers: {})
end
context 'with a hash body' do
it 'correctly submits to github api' do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_bearer: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: {
path: 'TEST_FILE.md',
message: 'File committed',
content: 'VGVzdCBDb250ZW50Cg==\n',
branch: 'test-branch'
}
)
end
").runner.execute(:test)
expect(result[:status]).to eq(200)
expect(result[:body]).to eq(response_body)
expect(result[:json]).to eq(JSON.parse(response_body))
end
end
end
end
context 'failures' do
let(:error_response_body) { '{"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}' }
before do
stub_request(:put, "https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md").
with(headers: {
'Authorization' => 'Basic MTIzNDU2Nzg5',
'Host' => 'api.github.com:443',
'User-Agent' => 'fastlane-github_api'
}).
to_return(status: 401, body: error_response_body, headers: {})
end
it "raises on error by default" do
expect do
Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: {
path: 'TEST_FILE.md',
message: 'File committed',
content: 'VGVzdCBDb250ZW50Cg==\n',
branch: 'test-branch'
}
)
end
").runner.execute(:test)
end.to(
raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to match("GitHub responded with 401")
end
)
end
it "allows custom error handling by status code" do
expect do
Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: {
path: 'TEST_FILE.md',
message: 'File committed',
content: 'VGVzdCBDb250ZW50Cg==\n',
branch: 'test-branch'
},
error_handlers: {
401 => proc {|result|
UI.user_error!(\"Custom error handled for 401 \#{result[:body]}\")
},
404 => proc do |result|
UI.message('not found')
end
}
)
end
").runner.execute(:test)
end.to(
raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to match("Custom error handled for 401 #{error_response_body}")
end
)
end
it "allows custom error handling for all other errors" do
expect do
Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: {
path: 'TEST_FILE.md',
message: 'File committed',
content: 'VGVzdCBDb250ZW50Cg==\n',
branch: 'test-branch'
},
error_handlers: {
'*' => proc do |result|
UI.user_error!(\"Custom error handled for all errors\")
end,
404 => proc do |result|
UI.message('not found')
end
}
)
end
").runner.execute(:test)
end.to(
raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to match("Custom error handled for all errors")
end
)
end
it "doesn't raise on custom error handling" do
result = Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
path: 'repos/fastlane/fastlane/contents/TEST_FILE.md',
body: {
path: 'TEST_FILE.md',
message: 'File committed',
content: 'VGVzdCBDb250ZW50Cg==\n',
branch: 'test-branch'
},
error_handlers: {
401 => proc do |result|
UI.message(\"error handled\")
end
}
)
end
").runner.execute(:test)
expect(result[:status]).to eq(401)
expect(result[:body]).to eq(error_response_body)
expect(result[:json]).to eq(JSON.parse(error_response_body))
end
context "url isn't set" do
context "path isn't set, server_url is set" do
it "raises" do
expect do
Fastlane::FastFile.new.parse("
lane :test do
github_api(
api_token: '123456789',
http_method: 'PUT',
server_url: 'https://api.github.com'
)
end
").runner.execute(:test)
end.to(
raise_error(FastlaneCore::Interface::FastlaneError) do |error|
expect(error.message).to match("Please provide either `server_url` (e.g. https://api.github.com) and 'path' or full 'url' for GitHub API endpoint")
end
)
end
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/swiftlint_spec.rb | fastlane/spec/actions_specs/swiftlint_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "SwiftLint" do
let(:swiftlint_gem_version) { Gem::Version.new('0.11.0') }
let(:output_file) { "swiftlint.result.json" }
let(:config_file) { ".swiftlint-ci.yml" }
before :each do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(swiftlint_gem_version)
end
context "default use case" do
it "default use case" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
end
context "when specify strict option" do
it "adds strict option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
strict: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --strict")
end
it "omits strict option if swiftlint does not support it" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.9.1'))
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
strict: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
it "adds strict option for custom executable" do
CUSTOM_EXECUTABLE_NAME = "custom_executable"
# Override the already overridden swiftlint_version method to check
# that the correct executable is being passed in as a parameter.
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version) { |params|
expect(params[:executable]).to eq(CUSTOM_EXECUTABLE_NAME)
swiftlint_gem_version
}
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
strict: true,
executable: '#{CUSTOM_EXECUTABLE_NAME}'
)
end").runner.execute(:test)
expect(result).to eq("#{CUSTOM_EXECUTABLE_NAME} lint --strict")
end
end
context "when specify false for strict option" do
it "doesn't add strict option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
strict: false
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
end
context "when specify output_file options" do
it "adds redirect file to command" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
output_file: '#{output_file}'
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint > #{output_file}")
end
end
context "when specify config_file options" do
it "adds config option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
config_file: '#{config_file}'
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --config #{config_file}")
end
end
context "when specify output_file, config_file and strict options" do
it "adds config option, strict option and redirect file" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
strict: true,
output_file: '#{output_file}',
config_file: '#{config_file}'
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --strict --config #{config_file} > #{output_file}")
end
end
context "when specify path options" do
it "adds path option" do
path = "./spec/fixtures"
result = Fastlane::FastFile.new.parse("
lane :test do
swiftlint(
path: '#{path}'
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --path #{path}")
end
it "adds invalid path option" do
path = "./non/existent/path"
expect do
Fastlane::FastFile.new.parse("lane :test do
swiftlint(
path: '#{path}'
)
end").runner.execute(:test)
end.to raise_error(/Couldn't find path '.*#{path}'/)
end
end
context "the `ignore_exit_status` option" do
context "by default" do
it 'should raise if swiftlint completes with a non-zero exit status' do
allow(FastlaneCore::UI).to receive(:important)
expect(FastlaneCore::UI).to receive(:important).with(/If you want fastlane to continue anyway/)
# This is simulating the exception raised if the return code is non-zero
expect(Fastlane::Actions).to receive(:sh).and_raise("fake error")
expect(FastlaneCore::UI).to receive(:user_error!).with(/SwiftLint finished with errors/).and_call_original
expect do
Fastlane::FastFile.new.parse("lane :test do
swiftlint
end").runner.execute(:test)
end.to raise_error(/SwiftLint finished with errors/)
end
end
context "when enabled" do
it 'should not raise if swiftlint completes with a non-zero exit status' do
allow(FastlaneCore::UI).to receive(:important)
expect(FastlaneCore::UI).to receive(:important).with(/fastlane will continue/)
# This is simulating the exception raised if the return code is non-zero
expect(Fastlane::Actions).to receive(:sh).and_raise("fake error")
expect(FastlaneCore::UI).to_not(receive(:user_error!))
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(ignore_exit_status: true)
end").runner.execute(:test)
end
end
context "when disabled" do
it 'should raise if swiftlint completes with a non-zero exit status' do
allow(FastlaneCore::UI).to receive(:important)
expect(FastlaneCore::UI).to receive(:important).with(/If you want fastlane to continue anyway/)
# This is simulating the exception raised if the return code is non-zero
expect(Fastlane::Actions).to receive(:sh).and_raise("fake error")
expect(FastlaneCore::UI).to receive(:user_error!).with(/SwiftLint finished with errors/).and_call_original
expect do
Fastlane::FastFile.new.parse("lane :test do
swiftlint(ignore_exit_status: false)
end").runner.execute(:test)
end.to raise_error(/SwiftLint finished with errors/)
end
end
end
context "when specify mode explicitly" do
it "uses lint mode as default" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
it "supports lint mode option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :lint
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
it "supports fix mode option" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.43.0'))
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :fix
)
end").runner.execute(:test)
expect(result).to eq("swiftlint --fix")
end
it "supports autocorrect mode option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :autocorrect
)
end").runner.execute(:test)
expect(result).to eq("swiftlint autocorrect")
end
it "switches autocorrect mode to fix mode option if swiftlint does not support it" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.43.0'))
expect(FastlaneCore::UI).to receive(:deprecated).with("Your version of swiftlint (0.43.0) has deprecated autocorrect mode, please start using fix mode in input param")
expect(FastlaneCore::UI).to receive(:important).with("For now, switching swiftlint mode `from :autocorrect to :fix` for you ๐")
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :autocorrect
)
end").runner.execute(:test)
expect(result).to eq("swiftlint --fix")
end
it "switches fix mode to autocorrect mode option if swiftlint does not support it" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.42.0'))
expect(FastlaneCore::UI).to receive(:important).with("Your version of swiftlint (0.42.0) does not support fix mode.\nUpdate swiftlint using `brew update && brew upgrade swiftlint`")
expect(FastlaneCore::UI).to receive(:important).with("For now, switching swiftlint mode `from :fix to :autocorrect` for you ๐")
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :fix
)
end").runner.execute(:test)
expect(result).to eq("swiftlint autocorrect")
end
end
context "when specify list of files to process" do
it "adds use script input files option and environment variables" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
files: ['AppDelegate.swift', 'path/to/project/src/Model.swift', 'path/to/project/test/Test.swift']
)
end").runner.execute(:test)
expect(result).to eq("SCRIPT_INPUT_FILE_COUNT=3 SCRIPT_INPUT_FILE_0=AppDelegate.swift SCRIPT_INPUT_FILE_1=path/to/project/src/Model.swift SCRIPT_INPUT_FILE_2=path/to/project/test/Test.swift swiftlint lint --use-script-input-files")
end
end
context "when file paths contain spaces" do
it "escapes spaces in output and config file paths" do
output_file = "output path with spaces.txt"
config_file = ".config file with spaces.yml"
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
output_file: '#{output_file}',
config_file: '#{config_file}'
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --config #{config_file.shellescape} > #{output_file.shellescape}")
end
it "escapes spaces in list of files to process" do
file = "path/to/my project/source code/AppDelegate.swift"
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
files: ['#{file}']
)
end").runner.execute(:test)
expect(result).to eq("SCRIPT_INPUT_FILE_COUNT=1 SCRIPT_INPUT_FILE_0=#{file.shellescape} swiftlint lint --use-script-input-files")
end
end
context "when specify reporter" do
it "adds reporter option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
reporter: 'json'
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --reporter json")
end
end
context "when specify quiet option" do
it "adds quiet option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
quiet: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --quiet")
end
it "omits quiet option if swiftlint does not support it" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.8.0'))
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
quiet: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
end
context "when specify false for quiet option" do
it "doesn't add quiet option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
quiet: false
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
end
context "when specify format option" do
it "adds format option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :autocorrect,
format: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint autocorrect --format")
end
it "omits format option if mode is :lint" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :lint,
format: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
it "omits format option if swiftlint does not support it" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.10.0'))
expect(FastlaneCore::UI).to receive(:important).with(/Your version of swiftlint \(0.10.0\) does not support/)
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :autocorrect,
format: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint autocorrect")
end
end
context "when specify false for format option" do
it "doesn't add format option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :autocorrect,
format: false
)
end").runner.execute(:test)
expect(result).to eq("swiftlint autocorrect")
end
end
context "when specify no-cache option" do
it "adds no-cache option if mode is :autocorrect" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :autocorrect,
no_cache: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint autocorrect --no-cache")
end
it "adds no-cache option if mode is :lint" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :lint,
no_cache: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint --no-cache")
end
it "adds no-cache option if mode is :fix" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.43.0'))
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :fix,
no_cache: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint --fix --no-cache")
end
it "omits format option if mode is :analyze" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :analyze,
no_cache: true
)
end").runner.execute(:test)
expect(result).to eq("swiftlint analyze")
end
end
context "when specify false for no-cache option" do
it "doesn't add no-cache option if mode is :autocorrect" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :autocorrect,
no_cache: false
)
end").runner.execute(:test)
expect(result).to eq("swiftlint autocorrect")
end
it "doesn't add no-cache option if mode is :lint" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :lint,
no_cache: false
)
end").runner.execute(:test)
expect(result).to eq("swiftlint lint")
end
it "doesn't add no-cache option if mode is :fix" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.43.0'))
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
mode: :fix,
no_cache: false
)
end").runner.execute(:test)
expect(result).to eq("swiftlint --fix")
end
end
context "when using analyzer mode" do
it "adds compiler-log-path option" do
path = "./spec/fixtures"
result = Fastlane::FastFile.new.parse("
lane :test do
swiftlint(
compiler_log_path: '#{path}',
mode: :analyze
)
end").runner.execute(:test)
expect(result).to eq("swiftlint analyze --compiler-log-path #{path}")
end
it "adds invalid path option" do
path = "./non/existent/path"
expect do
Fastlane::FastFile.new.parse("lane :test do
swiftlint(
compiler_log_path: '#{path}',
mode: :analyze
)
end").runner.execute(:test)
end.to raise_error(/Couldn't find compiler_log_path '.*#{path}'/)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/puts_spec.rb | fastlane/spec/actions_specs/puts_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "puts" do
it "works" do
Fastlane::FastFile.new.parse("lane :test do
puts 'hi'
end").runner.execute(:test)
end
it "works in Swift" do
Fastlane::FastFile.new.parse("lane :test do
puts(message: 'hi from Swift')
end").runner.execute(:test)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/sourcedocs_spec.rb | fastlane/spec/actions_specs/sourcedocs_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "SourceDocs" do
context "when specify output path" do
it "default use case" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
end
context "when specify all_modules option" do
it "doesn't add all_modules option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
all_modules: false,
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds all_modules option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
all_modules: true
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --all-modules --output-folder docs")
end
end
context "when specify spm_module option" do
it "doesn't add spm_module option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds spm_module option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
spm_module: 'MySpmModule'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --spm-module MySpmModule --output-folder docs")
end
end
context "when specify module_name option" do
it "doesn't add module_name option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds module_name option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
module_name: 'MyModule'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --module-name MyModule --output-folder docs")
end
end
context "when specify link_beginning option" do
it "doesn't add link_beginning option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds link_beginning option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
link_beginning: 'sdk'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --link-beginning sdk --output-folder docs")
end
end
context "when specify link_ending option" do
it "doesn't add link_ending option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds link_ending option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
link_ending: '.md'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --link-ending .md --output-folder docs")
end
end
context "when specify min_acl option" do
it "doesn't add min_acl option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds min_acl option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
min_acl: 'internal'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs --min-acl internal")
end
end
context "when specify module_name_path option" do
it "doesn't add module_name_path option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
module_name_path: false,
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds module_name_path option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
module_name_path: true
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs --module-name-path")
end
end
context "when specify clean option" do
it "doesn't add clean option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
clean: false,
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds clean option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
clean: true
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs --clean")
end
end
context "when specify collapsible option" do
it "adds collapsible option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
collapsible: true
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs --collapsible")
end
it "doesn't add collapsible option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
collapsible: false
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
end
context "when specify table_of_contents option" do
it "adds table_of_contents option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
table_of_contents: true
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs --table-of-contents")
end
it "doesn't add table-of-contents option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
table_of_contents: false
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
end
context "when specify reproducible option" do
it "adds reproducible option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
reproducible: true
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs --reproducible-docs")
end
it "doesn't add reproducible option" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
reproducible: false
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
end
context "when specify scheme parameter" do
it "adds scheme parameter" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
scheme: 'MyApp'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs -- -scheme MyApp")
end
it "adds sdk platform parameter" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
scheme: 'MyApp',
sdk_platform: 'iphoneos'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs -- -scheme MyApp -sdk iphoneos")
end
end
context "when scheme parameter not specified" do
it "adds no scheme parameter" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
it "adds no sdk platform parameter" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
output_folder: 'docs',
sdk_platform: 'iphoneos'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs")
end
end
context "when specify lots parameters" do
it "adds lots parameters" do
result = Fastlane::FastFile.new.parse("lane :test do
sourcedocs(
sdk_platform: 'macosx',
output_folder: 'docs',
collapsible: true,
table_of_contents: true,
clean: true,
reproducible: true,
module_name_path: true,
scheme: 'MyApp',
min_acl: 'internal'
)
end").runner.execute(:test)
expect(result).to eq("sourcedocs generate --output-folder docs --min-acl internal --module-name-path --clean --collapsible --table-of-contents --reproducible-docs -- -scheme MyApp -sdk macosx")
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/install_on_device_spec.rb | fastlane/spec/actions_specs/install_on_device_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "install_on_device" do
it "generates a valid command" do
result = Fastlane::FastFile.new.parse("lane :test do
install_on_device(ipa: 'demo.ipa')
end").runner.execute(:test)
expect(result).to eq("ios-deploy --bundle demo.ipa")
end
it "generates a valid command using app name with space" do
ipa = "demo app.ipa"
result = Fastlane::FastFile.new.parse("lane :test do
install_on_device(ipa: '#{ipa}')
end").runner.execute(:test)
expect(result).to eq("ios-deploy --bundle #{ipa.shellescape}")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/push_to_git_remote_spec.rb | fastlane/spec/actions_specs/push_to_git_remote_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Git Push to Remote Action" do
before(:each) do
allow(Fastlane::Actions).to receive(:sh)
.with("git rev-parse --abbrev-ref HEAD", log: false)
.and_return(nil)
allow(Fastlane::Actions).to receive(:git_branch).and_return("master")
end
it "runs git push with defaults" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags")
end
it "run git push with local_branch" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
local_branch: 'staging'
)
end").runner.execute(:test)
expect(result).to eq("git push origin staging:staging --tags")
end
it "run git push with local_branch and remote_branch" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
local_branch: 'staging',
remote_branch: 'production'
)
end").runner.execute(:test)
expect(result).to eq("git push origin staging:production --tags")
end
it "runs git push with tags:false" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
tags: false
)
end").runner.execute(:test)
expect(result).to eq("git push origin master:master")
end
it "runs git push with force:true" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
force: true
)
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags --force")
end
it "runs git push with force_with_lease:true" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
force_with_lease: true
)
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags --force-with-lease")
end
it "runs git push with remote" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
remote: 'not_github'
)
end").runner.execute(:test)
expect(result).to eq("git push not_github master:master --tags")
end
it "runs git push with no_verify:true" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
no_verify: true
)
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags --no-verify")
end
it "runs git push with set_upstream:true" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
set_upstream: true
)
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags --set-upstream")
end
it "runs git push with 1 element in push-options" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
push_options: ['something-to-tell-remote-git-server']
)
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags --push-option=something-to-tell-remote-git-server")
end
it "runs git push with 2 elements in push-options" do
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote(
push_options: ['something-to-tell-remote-git-server', 'something-else']
)
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags --push-option=something-to-tell-remote-git-server --push-option=something-else")
end
context "runs git push using a checked out commit git branch" do
it "should use the checked out commit git branch" do
allow(Fastlane::Actions).to receive(:sh)
.with("git rev-parse --abbrev-ref HEAD", log: false)
.and_return("staging")
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote
end").runner.execute(:test)
expect(result).to eq("git push origin staging:staging --tags")
end
end
context "runs git push when checked out commit git branch is different than git branch name is set in CI ENV" do
it "should use the checked out commit git branch if different than CI ENV" do
allow(Fastlane::Actions).to receive(:sh)
.with("git rev-parse --abbrev-ref HEAD", log: false)
.and_return("staging")
allow(Fastlane::Actions).to receive(:git_branch).and_return("master")
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote
end").runner.execute(:test)
expect(result).to eq("git push origin staging:staging --tags")
end
end
context "runs git push when checked out commit is detached HEAD and git branch name is set in CI ENV" do
it "should use CI ENV git branch if checked out commit is detached HEAD" do
allow(Fastlane::Actions).to receive(:sh)
.with("git rev-parse --abbrev-ref HEAD", log: false)
.and_return("HEAD")
allow(Fastlane::Actions).to receive(:git_branch).and_return("master")
result = Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote
end").runner.execute(:test)
expect(result).to eq("git push origin master:master --tags")
end
end
context "runs git push when checked out commit is detached HEAD and git branch name is not set in CI ENV" do
it "should raise an error" do
allow(Fastlane::Actions).to receive(:sh)
.with("git rev-parse --abbrev-ref HEAD", log: false)
.and_return("HEAD")
allow(Fastlane::Actions).to receive(:git_branch).and_return(nil)
expect(FastlaneCore::UI).to receive(:user_error!).with("Failed to get the current branch.").and_call_original
expect do
Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote
end").runner.execute(:test)
end.to raise_error("Failed to get the current branch.")
end
end
context "runs git push without local_branch and git branch name is not set in CI ENV" do
it "should raise an error if get current local branch failed and git branch name is not set in CI ENV" do
allow(Fastlane::Actions).to receive(:sh)
.with("git rev-parse --abbrev-ref HEAD", log: false)
.and_return(nil)
allow(Fastlane::Actions).to receive(:git_branch).and_return(nil)
expect(FastlaneCore::UI).to receive(:user_error!).with("Failed to get the current branch.").and_call_original
expect do
Fastlane::FastFile.new.parse("lane :test do
push_to_git_remote
end").runner.execute(:test)
end.to raise_error("Failed to get the current branch.")
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/get_info_plist_value_spec.rb | fastlane/spec/actions_specs/get_info_plist_value_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "get_info_plist" do
let(:plist_path) { "./fastlane/spec/fixtures/plist/Info.plist" }
it "fetches the value from the plist" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
value = Fastlane::FastFile.new.parse("lane :test do
get_info_plist_value(path: '#{plist_path}', key: 'CFBundleIdentifier')
end").runner.execute(:test)
expect(value).to eq("com.krausefx.app")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/commit_github_file_spec.rb | fastlane/spec/actions_specs/commit_github_file_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "commit_github_file" do
let(:response_body) { File.read("./fastlane/spec/fixtures/requests/github_create_file_response.json") }
context 'successful' do
before do
stub_request(:put, "https://api.github.com/repos/fastlane/fastlane/contents/test/assets/TEST_FILE.md").
with(body: "{\"path\":\"/test/assets/TEST_FILE.md\",\"message\":\"Add my new file\",\"content\":\"dGVzdA==\\n\",\"branch\":\"master\"}",
headers: {
'Authorization' => 'Basic MTIzNDVhYmNkZQ==',
'Host' => 'api.github.com:443',
'User-Agent' => 'fastlane-github_api'
}).
to_return(status: 200, body: response_body, headers: {})
end
it 'correctly submits to github' do
current_dir = Dir.pwd
path = "test/assets/TEST_FILE.md"
file = "#{current_dir}/fastlane/#{path}"
content = 'test'
allow(File).to receive(:exist?).with(file).and_return(true).at_least(:once)
allow(File).to receive(:exist?).and_return(:default)
allow(File).to receive(:open).with(file).and_return(StringIO.new(content))
result = Fastlane::FastFile.new.parse("
lane :test do
commit_github_file(
api_token: '12345abcde',
repository_name: 'fastlane/fastlane',
message: 'Add my new file',
path: '#{path}'
)
end
").runner.execute(:test)
expect(result['content']['url']).to eq('https://api.github.com/repos/fastlane/fastlane/contents/TEST_FILE.md?ref=test-branch')
expect(result['commit']['sha']).to eq('faa361b0c282fca74e2170bcb4ac3ec577fd2922')
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/sonar_spec.rb | fastlane/spec/actions_specs/sonar_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Sonar Integration" do
let(:test_path) { "/tmp/fastlane/tests/fastlane" }
let(:sonar_project_path) { "sonar-project.properties" }
before do
# Set up example sonar-project.properties file
FileUtils.mkdir_p(test_path)
File.write(File.join(test_path, sonar_project_path), '')
end
after(:each) do
File.delete(File.join(test_path, sonar_project_path)) if File.exist?(File.join(test_path, sonar_project_path))
end
it "Should not print sonar command" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
expected_command = "cd #{File.expand_path('.').shellescape} && sonar-scanner -Dsonar.token=\"asdf\""
expect(Fastlane::Actions::SonarAction).to receive(:verify_sonar_scanner_binary).and_return(true)
expect(Fastlane::Actions).to receive(:sh_control_output).with(expected_command, print_command: false, print_command_output: true).and_call_original
Fastlane::FastFile.new.parse("lane :sonar_test do
sonar(sonar_token: 'asdf')
end").runner.execute(:sonar_test)
end
it "works with all parameters" do
expect(Fastlane::Actions::SonarAction).to receive(:verify_sonar_scanner_binary).and_return(true)
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
result = Fastlane::FastFile.new.parse("lane :test do
sonar({
project_configuration_path: '#{test_path}/#{sonar_project_path}',
project_key: 'project-key',
project_name: 'project-name',
project_version: '1.0.0',
sources_path: '/Sources',
exclusions: '/Sources/Excluded',
project_language: 'ruby',
source_encoding: 'utf-8',
sonar_token: 'sonar-token',
sonar_url: 'http://www.sonarqube.com',
sonar_organization: 'org-key',
branch_name: 'branch-name',
pull_request_branch: 'pull-request-branch-name',
pull_request_base: 'pull-request-base',
pull_request_key: 'pull-request-key'
})
end").runner.execute(:test)
expected = "cd #{File.expand_path('.').shellescape} && sonar-scanner
-Dproject.settings=\"#{test_path}/#{sonar_project_path}\"
-Dsonar.projectKey=\"project-key\"
-Dsonar.projectName=\"project-name\"
-Dsonar.projectVersion=\"1.0.0\"
-Dsonar.sources=\"/Sources\"
-Dsonar.exclusions=\"/Sources/Excluded\"
-Dsonar.language=\"ruby\"
-Dsonar.sourceEncoding=\"utf-8\"
-Dsonar.token=\"sonar-token\"
-Dsonar.host.url=\"http://www.sonarqube.com\"
-Dsonar.organization=\"org-key\"
-Dsonar.branch.name=\"branch-name\"
-Dsonar.pullrequest.branch=\"pull-request-branch-name\"
-Dsonar.pullrequest.base=\"pull-request-base\"
-Dsonar.pullrequest.key=\"pull-request-key\"".gsub(/\s+/, ' ')
expect(result).to eq(expected)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/ipa_spec.rb | fastlane/spec/actions_specs/ipa_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "IPA Integration" do
it "works with default setting" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa
end").runner.execute(:test)
expect(result).to eq([])
end
it "works with object argument without clean and archive" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
workspace: 'Test.xcworkspace',
project: nil,
configuration: 'Release',
scheme: 'TestScheme',
destination: nil,
embed: nil,
identity: nil,
ipa: 'JoshIsAwesome.ipa'
})
end").runner.execute(:test)
expect(result.size).to eq(4)
end
it "works with object argument with clean and archive" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
workspace: 'Test.xcworkspace',
project: nil,
configuration: 'Release',
scheme: 'TestScheme',
clean: true,
archive: true,
destination: nil,
embed: nil,
identity: nil,
ipa: 'JoshIsAwesome.ipa'
})
end").runner.execute(:test)
expect(result.size).to eq(6)
end
it "works with object argument with all" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
workspace: 'Test.xcworkspace',
project: 'Test.xcproject',
configuration: 'Release',
scheme: 'TestScheme',
clean: true,
archive: true,
destination: 'Nowhere',
embed: 'Sure',
identity: 'bourne',
sdk: '10.0',
ipa: 'JoshIsAwesome.ipa',
xcconfig: 'SomethingGoesHere',
xcargs: 'MY_ADHOC_OPT1=0 MY_ADHOC_OPT2=1',
})
end").runner.execute(:test)
expect(result.size).to eq(13)
expect(result).to include('-w "Test.xcworkspace"')
expect(result).to include('-p "Test.xcproject"')
expect(result).to include('-c "Release"')
expect(result).to include('-s "TestScheme"')
expect(result).to include('--clean')
expect(result).to include('--archive')
expect(result).to include('-d "Nowhere"')
expect(result).to include('-m "Sure"')
expect(result).to include('-i "bourne"')
expect(result).to include('--sdk "10.0"')
expect(result).to include('--ipa "JoshIsAwesome.ipa"')
expect(result).to include('--xcconfig "SomethingGoesHere"')
expect(result).to include('--xcargs "MY_ADHOC_OPT1=0 MY_ADHOC_OPT2=1"')
end
it "respects the clean argument when true" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
clean: true,
})
end").runner.execute(:test)
expect(result).to include("--clean")
end
it "respects the clean argument when false" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
clean: false,
})
end").runner.execute(:test)
expect(result).to include("--no-clean")
end
it "respects the archive argument when true" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
archive: true,
})
end").runner.execute(:test)
expect(result).to include("--archive")
end
it "respects the archive argument when false" do
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
archive: false,
})
end").runner.execute(:test)
expect(result).to include("--no-archive")
end
it "works with object argument with all and extras and auto-use sigh profile if not given" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
ENV["SIGH_PROFILE_PATH"] = "some/great/value.file"
result = Fastlane::FastFile.new.parse("lane :test do
ipa ({
workspace: 'Test.xcworkspace',
project: 'Test.xcproject',
configuration: 'Release',
scheme: 'TestScheme',
clean: true,
archive: true,
destination: 'Nowhere',
identity: 'bourne',
sdk: '10.0',
ipa: 'JoshIsAwesome.ipa'
})
end").runner.execute(:test)
expect(result).to include("-m \"#{ENV['SIGH_PROFILE_PATH']}\"")
expect(result.size).to eq(11)
dest_path = File.expand_path('Nowhere')
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::IPA_OUTPUT_PATH]).to eq(File.join(dest_path, 'test.ipa'))
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::DSYM_OUTPUT_PATH]).to eq(File.join(dest_path, 'test.app.dSYM.zip'))
ENV["SIGH_PROFILE_PATH"] = nil
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/git_remote_branch_spec.rb | fastlane/spec/actions_specs/git_remote_branch_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
directory = "fl_spec_default_remote_branch"
describe "Git Remote Branch Action" do
it "generates the correct git command for retrieving default branch from remote" do
result = Fastlane::FastFile.new.parse("lane :test do
git_remote_branch
end").runner.execute(:test)
expect(result).to eq("variable=$(git remote) && git remote show $variable | grep 'HEAD branch' | sed 's/.*: //'")
end
end
describe "Git Remote Branch Action with optional remote name" do
it "generates the correct git command for retrieving default branch using provided remote name" do
result = Fastlane::FastFile.new.parse("lane :test do
git_remote_branch(remote_name:'upstream')
end").runner.execute(:test)
expect(result).to eq("git remote show upstream | grep 'HEAD branch' | sed 's/.*: //'")
end
end
context "runs the command in a directory with no git repo" do
it "Confirms that no default remote is found" do
test_directory_path = Dir.mktmpdir(directory)
Dir.chdir(test_directory_path) do
expect(Fastlane::Actions).to receive(:sh)
.with("variable=$(git remote) && git remote show $variable | grep 'HEAD branch' | sed 's/.*: //'", log: false)
result = Fastlane::FastFile.new.parse("lane :test do
git_remote_branch
end").runner.execute(:test)
expect(result).to be_nil
end
end
end
context "runs the command in a directory with no remote git repo" do
it "Confirms that no default remote is found" do
test_directory_path = Dir.mktmpdir(directory)
Dir.chdir(test_directory_path) do
`git -c init.defaultBranch=main init`
File.write('test_file', <<-TESTFILE)
'Hello'
TESTFILE
`git add .`
`git commit --message "Test file"`
expect(Fastlane::Actions).to receive(:sh)
.with("variable=$(git remote) && git remote show $variable | grep 'HEAD branch' | sed 's/.*: //'", log: false)
result = Fastlane::FastFile.new.parse("lane :test do
git_remote_branch
end").runner.execute(:test)
expect(result).to be_nil
end
end
end
context "runs the command with a remote git repo" do
it "Confirms that a default remote is found" do
allow(Fastlane::Actions).to receive(:sh)
.with("variable=$(git remote) && git remote show $variable | grep 'HEAD branch' | sed 's/.*: //'", log: false)
.and_return("main")
allow(Fastlane::Actions).to receive(:git_branch).and_return(nil)
result = Fastlane::FastFile.new.parse("lane :test do
git_remote_branch
end").runner.execute(:test)
expect(result).to eq("main")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/notarize_spec.rb | fastlane/spec/actions_specs/notarize_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "notarize" do
let(:success_submit_response) do
{
'status': 'Accepted',
'id': '1111-2222-3333-4444'
}.to_json
end
let(:invalid_submit_response) do
{
'status': 'Invalid',
'statusSummary': 'Archive contains critical validation errors',
'id': '1111-2222-3333-4444'
}.to_json
end
it "file at :api_key_path must exist" do
expect do
Fastlane::FastFile.new.parse("lane :test do
notarize(
api_key_path: '/tmp/file_does_not_exist'
)
end").runner.execute(:test)
end.to raise_error("API Key not found at '/tmp/file_does_not_exist'")
end
it "forbids to provide both :username and :api_key" do
expect do
Fastlane::FastFile.new.parse("lane :test do
notarize(
username: 'myusername@example.com',
api_key: {'anykey' => 'anyvalue'}
)
end").runner.execute(:test)
end.to raise_error("Unresolved conflict between options: 'username' and 'api_key'")
end
it "forbids to provide both :skip_stapling and :try_early_stapling" do
expect do
Fastlane::FastFile.new.parse("lane :test do
notarize(
skip_stapling: true,
try_early_stapling: true
)
end").runner.execute(:test)
end.to raise_error("Unresolved conflict between options: 'skip_stapling' and 'try_early_stapling'")
end
context "with notary tool" do
let(:package) { Tempfile.new('app.ipa.zip') }
let(:bundle_id) { 'com.some.app' }
context "with Apple ID" do
let(:username) { 'myusername@example.com' }
let(:asc_provider) { '123456789' }
let(:app_specific_password) { 'secretpass' }
it "successful" do
stub_const('ENV', { "FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD" => app_specific_password })
expect(Fastlane::Actions).to receive(:sh).with("xcrun notarytool submit #{package.path} --output-format json --wait --apple-id #{username} --password #{app_specific_password} --team-id #{asc_provider}", { error_callback: anything, log: false }).and_return(success_submit_response)
expect(Fastlane::Actions).to receive(:sh).with("xcrun stapler staple #{package.path}", { log: false })
result = Fastlane::FastFile.new.parse("lane :test do
notarize(
use_notarytool: true,
package: '#{package.path}',
bundle_id: '#{bundle_id}',
username: '#{username}',
asc_provider: '#{asc_provider}',
)
end").runner.execute(:test)
end
it "successful with verbose option" do
stub_const('ENV', { "FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD" => app_specific_password })
expect(Fastlane::Actions).to receive(:sh).with("xcrun notarytool submit #{package.path} --output-format json --wait --apple-id #{username} --password #{app_specific_password} --team-id #{asc_provider} --verbose", { error_callback: anything, log: true }).and_return(success_submit_response)
expect(Fastlane::Actions).to receive(:sh).with("xcrun stapler staple #{package.path}", { log: true })
result = Fastlane::FastFile.new.parse("lane :test do
notarize(
use_notarytool: true,
package: '#{package.path}',
bundle_id: '#{bundle_id}',
username: '#{username}',
asc_provider: '#{asc_provider}',
verbose: true
)
end").runner.execute(:test)
end
it "successful with skip_stapling" do
stub_const('ENV', { "FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD" => app_specific_password })
expect(Fastlane::Actions).to receive(:sh).with("xcrun notarytool submit #{package.path} --output-format json --wait --apple-id #{username} --password #{app_specific_password} --team-id #{asc_provider}", { error_callback: anything, log: false }).and_return(success_submit_response)
expect(Fastlane::Actions).not_to receive(:sh).with("xcrun stapler staple #{package.path}", { log: false })
result = Fastlane::FastFile.new.parse("lane :test do
notarize(
use_notarytool: true,
package: '#{package.path}',
bundle_id: '#{bundle_id}',
username: '#{username}',
asc_provider: '#{asc_provider}',
skip_stapling: true
)
end").runner.execute(:test)
end
it "invalid" do
stub_const('ENV', { "FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD" => app_specific_password })
expect(Fastlane::Actions).to receive(:sh).with("xcrun notarytool submit #{package.path} --output-format json --wait --apple-id #{username} --password #{app_specific_password} --team-id #{asc_provider}", { error_callback: anything, log: false }).and_return(invalid_submit_response)
expect do
result = Fastlane::FastFile.new.parse("lane :test do
notarize(
use_notarytool: true,
package: '#{package.path}',
bundle_id: '#{bundle_id}',
username: '#{username}',
asc_provider: '#{asc_provider}',
)
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, "Could not notarize package. To see the error, please set 'print_log' to true.")
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/jazzy_spec.rb | fastlane/spec/actions_specs/jazzy_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Jazzy" do
it "default use case" do
result = Fastlane::FastFile.new.parse("lane :test do
jazzy
end").runner.execute(:test)
expect(result).to eq("jazzy")
end
it "add config option" do
result = Fastlane::FastFile.new.parse("lane :test do
jazzy(
config: '.jazzy.yaml'
)
end").runner.execute(:test)
expect(result).to eq("jazzy --config .jazzy.yaml")
end
it "add module_version option" do
result = Fastlane::FastFile.new.parse("lane :test do
jazzy(
module_version: '1.2.6'
)
end").runner.execute(:test)
expect(result).to eq("jazzy --module-version 1.2.6")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/erb_spec.rb | fastlane/spec/actions_specs/erb_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "ERB template" do
let(:template) { File.expand_path("./fastlane/spec/fixtures/templates/dummy_html_template.erb") }
let(:destination) { "/tmp/fastlane/template.html" }
it "generate template without placeholders" do
result = Fastlane::FastFile.new.parse("lane :test do
erb(
template: '#{template}'
)
end").runner.execute(:test)
expect(result).to eq("<h1></h1>\n")
end
it "generate template with placeholders" do
result = Fastlane::FastFile.new.parse("lane :test do
erb(
template: '#{template}',
placeholders: {
template_name: 'ERB template name'
}
)
end").runner.execute(:test)
expect(result).to eq("<h1>ERB template name</h1>\n")
end
context "save to file" do
before do
FileUtils.mkdir_p(File.dirname(destination))
end
it "generate template and save to file" do
result = Fastlane::FastFile.new.parse("lane :test do
erb(
template: '#{template}',
destination: '#{destination}',
placeholders: {
template_name: 'ERB template name with save'
}
)
end").runner.execute(:test)
expect(result).to eq("<h1>ERB template name with save</h1>\n")
expect(
File.read(destination)
).to eq("<h1>ERB template name with save</h1>\n")
end
after do
File.delete(destination)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/app_store_build_number_spec.rb | fastlane/spec/actions_specs/app_store_build_number_spec.rb | require 'ostruct'
describe Fastlane do
describe Fastlane::FastFile do
describe "app_store_build_number" do
it "orders versions array of integers" do
versions = [3, 5, 1, 0, 4]
result = Fastlane::Actions::AppStoreBuildNumberAction.order_versions(versions)
expect(result).to eq(['0', '1', '3', '4', '5'])
end
it "orders versions array of integers and string integers" do
versions = [3, 5, '1', 0, '4']
result = Fastlane::Actions::AppStoreBuildNumberAction.order_versions(versions)
expect(result).to eq(['0', '1', '3', '4', '5'])
end
it "orders versions array of integers, string integers, floats, and semantic versions string" do
versions = [3, '1', '2.3', 9, '6.5.4', '11.4.6', 5.6]
result = Fastlane::Actions::AppStoreBuildNumberAction.order_versions(versions)
expect(result).to eq(['1', '2.3', '3', '5.6', '6.5.4', '9', '11.4.6'])
end
it "returns value as string (with build number as version string)" do
allow(Fastlane::Actions::AppStoreBuildNumberAction).to receive(:get_build_info).and_return(OpenStruct.new({ build_nr: "1.2.3", build_v: "foo" }))
result = Fastlane::FastFile.new.parse("lane :test do
app_store_build_number(username: 'name@example.com', app_identifier: 'x.y.z')
end").runner.execute(:test)
expect(result).to eq("1.2.3")
end
it "returns value as integer (with build number as version number)" do
allow(Fastlane::Actions::AppStoreBuildNumberAction).to receive(:get_build_info).and_return(OpenStruct.new({ build_nr: "3", build_v: "foo" }))
result = Fastlane::FastFile.new.parse("lane :test do
app_store_build_number(username: 'name@example.com', app_identifier: 'x.y.z')
end").runner.execute(:test)
expect(result).to eq(3)
end
end
describe "#get_build_info" do
let(:fake_api_key_json_path) do
"./spaceship/spec/connect_api/fixtures/asc_key.json"
end
let(:platform) do
"ios"
end
let(:app_identifier) do
"com.fastlane.tools"
end
let(:app_version) do
"1.0.0"
end
let(:build_number) do
"1234"
end
let(:app_id) do
"TXX1234XX"
end
let(:app) do
{ platform: platform, app_identifier: app_identifier, id: app_id }
end
let(:build) do
{ version: build_number }
end
let(:live_version) do
{ build: build, version_string: app_version }
end
let(:options) do
{ platform: platform, app_identifier: app_identifier }
end
before(:each) do
allow(Spaceship::ConnectAPI::Platform)
.to receive(:map)
.with(platform)
.and_return(platform)
allow(Spaceship::ConnectAPI::App)
.to receive(:find)
.with(app_identifier)
.and_return(app)
end
describe "what happens when fetching the 'live-version' build number" do
before(:each) do
allow(app)
.to receive(:get_live_app_store_version)
.with(platform: platform)
.and_return(live_version)
allow(live_version)
.to receive(:build)
.and_return(build)
allow(build)
.to receive(:version)
.and_return(build_number)
allow(live_version)
.to receive(:version_string)
.and_return(app_version)
options[:live] = true
end
context "when using app store connect api token" do
before(:each) do
allow(Spaceship::ConnectAPI)
.to receive(:token)
.and_return(Spaceship::ConnectAPI::Token.from(filepath: fake_api_key_json_path))
end
it "uses the existing API token if found and fetches the latest build number for live-version" do
expect(Spaceship::ConnectAPI::Token).to receive(:from).with(hash: nil, filepath: nil).and_return(false)
expect(UI).to receive(:message).with("Using existing authorization token for App Store Connect API")
expect(UI).to receive(:message).with("Fetching the latest build number for live-version")
expect(UI).to receive(:message).with("Latest upload for live-version #{app_version} is build: #{build_number}")
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(build_number)
expect(result.build_v).to eq(app_version)
end
it "creates and sets new API token using config api_key and api_key_path and fetches the latest build number for live-version" do
expect(Spaceship::ConnectAPI::Token).to receive(:from).with(hash: "api_key", filepath: "api_key_path").and_return(true)
expect(UI).to receive(:message).with("Creating authorization token for App Store Connect API")
expect(Spaceship::ConnectAPI).to receive(:token=)
expect(UI).to receive(:message).with("Fetching the latest build number for live-version")
expect(UI).to receive(:message).with("Latest upload for live-version #{app_version} is build: #{build_number}")
options[:api_key] = "api_key"
options[:api_key_path] = "api_key_path"
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(build_number)
expect(result.build_v).to eq(app_version)
end
end
context "when using web session" do
before(:each) do
allow(Spaceship::ConnectAPI)
.to receive(:token)
.and_return(nil)
end
it "performs the login using username and password and fetches the latest build number for live-version" do
expect(options).to receive(:fetch).with(:username, force_ask: true)
expect(UI).to receive(:message).with("Login to App Store Connect (username)")
expect(Spaceship::ConnectAPI).to receive(:login)
expect(UI).to receive(:message).with("Login successful")
expect(UI).to receive(:message).with("Fetching the latest build number for live-version")
expect(UI).to receive(:message).with("Latest upload for live-version #{app_version} is build: #{build_number}")
options[:username] = "username"
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(build_number)
expect(result.build_v).to eq(app_version)
end
end
end
describe "what happens when fetching the 'testflight' build number" do
before(:each) do
allow(Spaceship::ConnectAPI)
.to receive(:token)
.and_return(Spaceship::ConnectAPI::Token.from(filepath: fake_api_key_json_path))
allow(app)
.to receive(:id)
.and_return(app_id)
allow(build)
.to receive(:version)
.and_return(build_number)
allow(build)
.to receive(:app_version)
.and_return(app_version)
options[:live] = false
expect(UI).to receive(:message).with("Using existing authorization token for App Store Connect API")
end
context "when 'version' and 'platform' both params are NOT given in input options" do
before(:each) do
options[:version] = nil
options[:platform] = nil
end
it "sets the correct filters and fetches the latest testflight build number with any platform" do
expected_filter = { app: app_id }
expect(Spaceship::ConnectAPI::Platform).to receive(:map).with(nil).and_return(nil)
expect(UI).to receive(:message).with("Fetching the latest build number for any version")
expect(Spaceship::ConnectAPI).to receive(:get_builds).with(filter: expected_filter, sort: "-uploadedDate", includes: "preReleaseVersion", limit: 1).and_return([build])
expect(UI).to receive(:message).with("Latest upload for version #{app_version} on any platform is build: #{build_number}")
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(build_number)
expect(result.build_v).to eq(app_version)
end
end
context "when 'version' is NOT given but 'platform' is given in input options" do
before(:each) do
options[:version] = nil
options[:platform] = platform
end
it "sets the correct filters and fetches the latest testflight build number with correct platform" do
expected_filter = { :app => app_id, "preReleaseVersion.platform" => platform }
expect(UI).to receive(:message).with("Fetching the latest build number for any version")
expect(Spaceship::ConnectAPI).to receive(:get_builds).with(filter: expected_filter, sort: "-uploadedDate", includes: "preReleaseVersion", limit: 1).and_return([build])
expect(UI).to receive(:message).with("Latest upload for version #{app_version} on #{platform} platform is build: #{build_number}")
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(build_number)
expect(result.build_v).to eq(app_version)
end
end
context "when 'version' is given but 'platform' is NOT given in input options" do
before(:each) do
options[:version] = app_version
options[:platform] = nil
end
it "sets the correct filters and fetches the latest testflight build number with any platform of given version" do
expected_filter = { :app => app_id, "preReleaseVersion.version" => app_version }
expect(Spaceship::ConnectAPI::Platform).to receive(:map).with(nil).and_return(nil)
expect(UI).to receive(:message).with("Fetching the latest build number for version #{app_version}")
expect(Spaceship::ConnectAPI).to receive(:get_builds).with(filter: expected_filter, sort: "-uploadedDate", includes: "preReleaseVersion", limit: 1).and_return([build])
expect(UI).to receive(:message).with("Latest upload for version #{app_version} on any platform is build: #{build_number}")
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(build_number)
expect(result.build_v).to eq(app_version)
end
end
context "when 'version' and 'platform' both params are given in input options" do
before(:each) do
options[:version] = app_version
options[:platform] = platform
end
it "sets the correct filters and fetches the latest testflight build number with correct platform of given version" do
expected_filter = { :app => app_id, "preReleaseVersion.platform" => platform, "preReleaseVersion.version" => app_version }
expect(UI).to receive(:message).with("Fetching the latest build number for version #{app_version}")
expect(Spaceship::ConnectAPI).to receive(:get_builds).with(filter: expected_filter, sort: "-uploadedDate", includes: "preReleaseVersion", limit: 1).and_return([build])
expect(UI).to receive(:message).with("Latest upload for version #{app_version} on #{platform} platform is build: #{build_number}")
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(build_number)
expect(result.build_v).to eq(app_version)
end
end
context "when could not find the build and 'initial_build_number' is NOT given in input options" do
before(:each) do
expected_filter = { :app => app_id, "preReleaseVersion.platform" => platform, "preReleaseVersion.version" => app_version }
allow(Spaceship::ConnectAPI)
.to receive(:get_builds)
.with(filter: expected_filter, sort: "-uploadedDate", includes: "preReleaseVersion", limit: 1)
.and_return([nil])
options[:version] = app_version
options[:platform] = platform
options[:initial_build_number] = nil
end
it "raises an exception" do
expect(UI).to receive(:message).with("Fetching the latest build number for version #{app_version}")
expect(UI).to receive(:important).with("Could not find a build for version #{app_version} on #{platform} platform on App Store Connect")
expect(UI).to receive(:user_error!).with("Could not find a build on App Store Connect - and 'initial_build_number' option is not set")
Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
end
end
context "when could not find the build but 'initial_build_number' is given in input options" do
before(:each) do
expected_filter = { :app => app_id, "preReleaseVersion.platform" => platform, "preReleaseVersion.version" => app_version }
allow(Spaceship::ConnectAPI)
.to receive(:get_builds)
.with(filter: expected_filter, sort: "-uploadedDate", includes: "preReleaseVersion", limit: 1)
.and_return([nil])
options[:version] = app_version
options[:platform] = platform
options[:initial_build_number] = 5678
end
it "fallbacks to 'initial_build_number' input param" do
expect(UI).to receive(:message).with("Fetching the latest build number for version #{app_version}")
expect(UI).to receive(:important).with("Could not find a build for version #{app_version} on #{platform} platform on App Store Connect")
expect(UI).to receive(:message).with("Using initial build number of 5678")
result = Fastlane::Actions::AppStoreBuildNumberAction.get_build_info(options)
expect(result.build_nr).to eq(5678)
expect(result.build_v).to eq(app_version)
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/hg_commit_version_bump_spec.rb | fastlane/spec/actions_specs/hg_commit_version_bump_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Mercurial Commit Version Bump Action" do
it "passes when modified files are a subset of expected changed files" do
dirty_files = "file1,file2"
expected_files = "file1,file2"
result = Fastlane::FastFile.new.parse("lane :test do
hg_commit_version_bump ({
test_dirty_files: '#{dirty_files}',
test_expected_files: '#{expected_files}',
})
end").runner.execute(:test)
expect(result).to eq("hg commit -m 'Version Bump'")
end
it "passes when modified files are not a subset of expected files, but :force is true" do
dirty_files = "file1,file3,file5"
expected_files = "file1"
result = Fastlane::FastFile.new.parse("lane :test do
hg_commit_version_bump ({
test_dirty_files: '#{dirty_files}',
test_expected_files: '#{expected_files}',
force: true
})
end").runner.execute(:test)
expect(result).to eq("hg commit -m 'Version Bump'")
end
it "works with a custom commit message" do
message = "custom message"
result = Fastlane::FastFile.new.parse("lane :test do
hg_commit_version_bump ({
message: '#{message}',
})
end").runner.execute(:test)
expect(result).to eq("hg commit -m '#{message}'")
end
it "raises an exception with no files changed" do
dirty_files = ""
expected_files = "file1"
expect do
Fastlane::FastFile.new.parse("lane :test do
hg_commit_version_bump ({
test_dirty_files: '#{dirty_files}',
test_expected_files: '#{expected_files}',
})
end").runner.execute(:test)
end.to raise_exception('No file changes picked up. Make sure you run the `increment_build_number` action first.')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/push_git_tags_spec.rb | fastlane/spec/actions_specs/push_git_tags_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "push_git_tags" do
it "uses the correct default command" do
result = Fastlane::FastFile.new.parse("lane :test do
push_git_tags
end").runner.execute(:test)
expect(result).to eq("git push origin --tags")
end
it "uses the correct command when forced" do
result = Fastlane::FastFile.new.parse("lane :test do
push_git_tags(force: true)
end").runner.execute(:test)
expect(result).to eq("git push origin --tags --force")
end
it "uses the correct command when remote set" do
result = Fastlane::FastFile.new.parse("lane :test do
push_git_tags(remote: 'foo')
end").runner.execute(:test)
expect(result).to eq("git push foo --tags")
end
it "uses the correct command when remote set and forced" do
result = Fastlane::FastFile.new.parse("lane :test do
push_git_tags(remote: 'foo', force: true)
end").runner.execute(:test)
expect(result).to eq("git push foo --tags --force")
end
it "uses the correct command when tag set" do
result = Fastlane::FastFile.new.parse("lane :test do
push_git_tags(remote: 'foo', tag: 'v1.0')
end").runner.execute(:test)
expect(result).to eq("git push foo refs/tags/v1.0")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/hg_add_tag_spec.rb | fastlane/spec/actions_specs/hg_add_tag_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Mercurial Add Tag Action" do
it "allows you to specify your own tag" do
tag = '2.0.0'
result = Fastlane::FastFile.new.parse("lane :test do
hg_add_tag ({
tag: '#{tag}',
})
end").runner.execute(:test)
expect(result).to eq("hg tag \"#{tag}\"")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/git_commit_spec.rb | fastlane/spec/actions_specs/git_commit_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "git_commit" do
before :each do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
end
it "generates the correct git command" do
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: './fastlane/README.md', message: 'message')
end").runner.execute(:test)
expect(result).to eq("git commit -m message ./fastlane/README.md")
end
it "generates the correct git command with an array of paths" do
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: ['./fastlane/README.md', './LICENSE'], message: 'message')
end").runner.execute(:test)
expect(result).to eq("git commit -m message ./fastlane/README.md ./LICENSE")
end
it "generates the correct git command with an array of paths and/or pathspecs" do
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: ['./fastlane/*.md', './LICENSE'], message: 'message')
end").runner.execute(:test)
expect(result).to eq("git commit -m message #{'./fastlane/*.md'.shellescape} ./LICENSE")
end
it "generates the correct git command with shell-escaped-paths" do
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: ['./fastlane/README.md', './LICENSE', './fastlane/spec/fixtures/git_commit/A FILE WITH SPACE'], message: 'message')
end").runner.execute(:test)
expect(result).to eq("git commit -m message ./fastlane/README.md ./LICENSE " + "./fastlane/spec/fixtures/git_commit/A FILE WITH SPACE".shellescape)
end
it "generates the correct git command with a shell-escaped message" do
message = "message with 'quotes' (and parens)"
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: './fastlane/README.md', message: \"#{message}\")
end").runner.execute(:test)
expect(result).to eq("git commit -m #{message.shellescape} ./fastlane/README.md")
end
it "generates the correct git command when configured to skip git hooks" do
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: './fastlane/README.md', message: 'message', skip_git_hooks: true)
end").runner.execute(:test)
expect(result).to eq("git commit -m message ./fastlane/README.md --no-verify")
end
it "generates the correct git command when configured to allow nothing to commit and there are changes to commit" do
expect(Fastlane::Actions).to receive(:sh)
.with(*%w[git status ./fastlane/README.md --porcelain])
.and_return("M ./fastlane/README.md")
expect(Fastlane::Actions).to receive(:sh)
.with(*%w[git commit -m message ./fastlane/README.md])
.and_call_original
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: './fastlane/README.md', message: 'message', allow_nothing_to_commit: true)
end").runner.execute(:test)
expect(result).to eq("git commit -m message ./fastlane/README.md")
end
it "does not generate the git command when configured to allow nothing to commit and there are no changes to commit" do
expect(Fastlane::Actions).to receive(:sh)
.with(*%w[git status ./fastlane/README.md --porcelain])
.and_return("")
result = Fastlane::FastFile.new.parse("lane :test do
git_commit(path: './fastlane/README.md', message: 'message', allow_nothing_to_commit: true)
end").runner.execute(:test)
expect(result).to be_nil
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/ensure_git_status_clean_spec.rb | fastlane/spec/actions_specs/ensure_git_status_clean_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "ensure_git_status_clean" do
before :each do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
allow(FastlaneCore::UI).to receive(:success).with("Driving the lane 'test' ๐")
end
context "when git status is clean" do
before :each do
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain", log: true).and_return("")
end
it "outputs success message" do
expect(FastlaneCore::UI).to receive(:success).with("Git status is clean, all good! ๐ช")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean
end").runner.execute(:test)
end
end
context "when git status is not clean" do
before :each do
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain", log: true).and_return(" M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain", log: false).and_return(" M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain --ignored='traditional'", log: true).and_return(" M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/")
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain --ignored='no'", log: true).and_return(" M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain --ignored='matching'", log: true).and_return(" M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/.DS_Store")
allow(Fastlane::Actions).to receive(:sh).with("git diff").and_return("+ \"this is a new line\"")
end
context "with ignore_files" do
it "outputs success message" do
expect(FastlaneCore::UI).to receive(:success).with("Git status is clean, all good! ๐ช")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(
ignore_files: ['fastlane/lib/fastlane/actions/ensure_git_status_clean.rb']
)
end").runner.execute(:test)
end
it "outputs success message when a file path contains spaces" do
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain", log: false).and_return(" M \"fastlane/spec/fixtures/git_commit/A FILE WITH SPACE\"")
expect(FastlaneCore::UI).to receive(:success).with("Git status is clean, all good! ๐ช")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(
ignore_files: ['fastlane/spec/fixtures/git_commit/A FILE WITH SPACE']
)
end").runner.execute(:test)
end
it "outputs success message when a file path is renamed" do
allow(Fastlane::Actions).to receive(:sh).with("git status --porcelain", log: false).and_return("R \"fastlane/spec/fixtures/git_commit/A FILE WITH SPACE\" -> \"fastlane/spec/fixtures/git_commit/A_FILE_WITHOUT_SPACE\"")
expect(FastlaneCore::UI).to receive(:success).with("Git status is clean, all good! ๐ช")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(
ignore_files: ['fastlane/spec/fixtures/git_commit/A_FILE_WITHOUT_SPACE']
)
end").runner.execute(:test)
end
it "outputs rich error message" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(
ignore_files: ['.DS_Store']
)
end").runner.execute(:test)
end
end
context "with show_uncommitted_changes flag" do
context "true" do
it "outputs rich error message" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\n M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true)
end").runner.execute(:test)
end
end
context "false" do
it "outputs short error message" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: false)
end").runner.execute(:test)
end
end
end
context "without show_uncommitted_changes flag" do
it "outputs short error message" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean
end").runner.execute(:test)
end
end
context "with show_diff flag" do
context "true" do
it "outputs rich error message" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nGit diff: \n+ \"this is a new line\"")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_diff: true)
end").runner.execute(:test)
end
end
context "false" do
it "outputs short error message" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_diff: false)
end").runner.execute(:test)
end
end
end
context "with ignored mode" do
context "traditional" do
it "outputs error message with ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\n M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true, ignored: 'traditional')
end").runner.execute(:test)
end
end
context "none" do
it "outputs error message without ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\n M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true, ignored: 'none')
end").runner.execute(:test)
end
end
context "matching" do
it "outputs error message with ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\n M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb\n!! .DS_Store\n!! fastlane/.DS_Store")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true, ignored: 'matching')
end").runner.execute(:test)
end
end
end
context "without ignored mode" do
it "outputs error message without ignored files" do
expect(FastlaneCore::UI).to receive(:user_error!).with("Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.\nUncommitted changes:\n M fastlane/lib/fastlane/actions/ensure_git_status_clean.rb")
Fastlane::FastFile.new.parse("lane :test do
ensure_git_status_clean(show_uncommitted_changes: true)
end").runner.execute(:test)
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/get_github_release_spec.rb | fastlane/spec/actions_specs/get_github_release_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "get_github_release" do
before do
stub_request(:get, "https://api.github.com/repos/fastlane/fastlane/releases").
with(headers: { 'Host' => 'api.github.com:443' }).
to_return(status: 200, body: File.read("./fastlane/spec/fixtures/requests/github_releases.json"), headers: {})
end
it "correctly fetches all the data from GitHub" do
result = Fastlane::FastFile.new.parse("lane :test do
get_github_release(url: 'fastlane/fastlane', version: '1.8.0')
end").runner.execute(:test)
expect(result['author']['login']).to eq("KrauseFx")
expect(result['name']).to eq("1.8.0 Switch Lanes & Pass Parameters")
expect(result['tag_name']).to eq('1.8.0')
end
it "returns nil if release can't be found" do
result = Fastlane::FastFile.new.parse("lane :test do
get_github_release(url: 'fastlane/fastlane', version: 'notExistent')
end").runner.execute(:test)
expect(result).to eq(nil)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/xctool_action_spec.rb | fastlane/spec/actions_specs/xctool_action_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "xctool Integration" do
it "works with no parameters" do
result = Fastlane::FastFile.new.parse("lane :test do
xctool
end").runner.execute(:test)
expect(result).to eq("xctool ")
end
it "works with default setting" do
result = Fastlane::FastFile.new.parse("lane :test do
xctool 'build test'
end").runner.execute(:test)
expect(result).to eq("xctool build test")
end
it "works with default setting" do
result = Fastlane::FastFile.new.parse('lane :test do
xctool :test, [
"--workspace", "\'AwesomeApp.xcworkspace\'",
"--scheme", "\'Schema Name\'",
"--configuration", "Debug",
"--sdk", "iphonesimulator",
"--arch", "i386"
].join(" ")
end').runner.execute(:test)
expect(result).to eq("xctool test --workspace 'AwesomeApp.xcworkspace' --scheme 'Schema Name' --configuration Debug --sdk iphonesimulator --arch i386")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/team_id_spec.rb | fastlane/spec/actions_specs/team_id_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Team ID Action" do
it "works as expected" do
new_val = "abcdef"
Fastlane::FastFile.new.parse("lane :test do
team_id '#{new_val}'
end").runner.execute(:test)
[:CERT_TEAM_ID, :SIGH_TEAM_ID, :PEM_TEAM_ID, :PRODUCE_TEAM_ID, :SIGH_TEAM_ID, :FASTLANE_TEAM_ID].each do |current|
expect(ENV[current.to_s]).to eq(new_val)
end
end
it "raises an error if no team ID is given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
team_id
end").runner.execute(:test)
end.to raise_error("Please pass your Team ID (e.g. team_id 'Q2CBPK58CA')")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/appetize_view_url_generator_spec.rb | fastlane/spec/actions_specs/appetize_view_url_generator_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "AppetizeViewingUrlGeneratorAction" do
it "no parameters" do
result = Fastlane::FastFile.new.parse("lane :test do
appetize_viewing_url_generator(public_key: '123')
end").runner.execute(:test)
expect(result).to eq("https://appetize.io/embed/123?autoplay=true&orientation=portrait&device=iphone5s&deviceColor=black&scale=75")
end
it "sensible default scaling" do
result = Fastlane::FastFile.new.parse("lane :test do
appetize_viewing_url_generator(device: 'ipadair2', public_key: '123')
end").runner.execute(:test)
expect(result).to eq("https://appetize.io/embed/123?autoplay=true&orientation=portrait&device=ipadair2&deviceColor=black&scale=50")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/adb_devices_spec.rb | fastlane/spec/actions_specs/adb_devices_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "adb_devices" do
it "generates an empty list of devices" do
result = Fastlane::FastFile.new.parse("lane :test do
adb_devices(adb_path: '/some/path/to/adb')
end").runner.execute(:test)
expect(result).to match_array([])
end
it "generates an empty list of devices when ANDROID_SDK_ROOT is set" do
result = Fastlane::FastFile.new.parse("lane :test do
ENV['ANDROID_SDK_ROOT'] = '/usr/local/android-sdk'
adb_devices()
end").runner.execute(:test)
expect(result).to match_array([])
end
it "calls AdbHelper for loading all the devices" do
expect_any_instance_of(Fastlane::Helper::AdbHelper).to receive(:load_all_devices).and_return([1, 2, 3])
result = Fastlane::FastFile.new.parse("lane :test do
adb_devices
end").runner.execute(:test)
expect(result).to match_array([1, 2, 3])
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/update_info_plist_spec.rb | fastlane/spec/actions_specs/update_info_plist_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Update Info Plist Integration" do
let(:test_path) { "/tmp/fastlane/tests/fastlane" }
let(:fixtures_path) { "./fastlane/spec/fixtures/xcodeproj" }
let(:proj_file) { "bundle.xcodeproj" }
let(:xcodeproj) { File.join(test_path, proj_file) }
let(:plist_path) { "Info.plist" }
let(:scheme) { "bundle" }
let(:app_identifier) { "com.test.plist" }
let(:display_name) { "Update Info Plist Test" }
describe "without an existing xcodeproj file" do
it "throws an error when the xcodeproj file does not exist" do
expect do
Fastlane::FastFile.new.parse("lane :test do
update_info_plist ({
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}',
display_name: '#{display_name}'
})
end").runner.execute(:test)
end.to raise_error("Could not figure out your xcodeproj path. Please specify it using the `xcodeproj` parameter")
end
end
describe "with existing xcodeproj file" do
before do
# Set up example info.plist
FileUtils.mkdir_p(test_path)
source = File.join(fixtures_path, proj_file)
destination = File.join(test_path, proj_file)
# Copy .xcodeproj fixture, as it will be modified during the test
FileUtils.cp_r(source, destination)
File.write(File.join(test_path, plist_path), '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>CFBundleDisplayName</key><string>empty</string><key>CFBundleIdentifier</key><string>empty</string></dict></plist>')
end
it "updates the info plist based on the given properties" do
result = Fastlane::FastFile.new.parse("lane :test do
update_info_plist ({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}',
display_name: '#{display_name}'
})
end").runner.execute(:test)
expect(result).to include("<string>#{display_name}</string>")
expect(result).to include("<string>#{app_identifier}</string>")
end
it "updates the info plist based on the given block" do
result = Fastlane::FastFile.new.parse("lane :test do
update_info_plist ({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
block: lambda { |plist|
plist['CFBundleIdentifier'] = '#{app_identifier}'
plist['CFBundleDisplayName'] = '#{display_name}'
}
})
end").runner.execute(:test)
expect(result).to include("<string>#{display_name}</string>")
expect(result).to include("<string>#{app_identifier}</string>")
end
it "obtains info plist from the scheme" do
result = Fastlane::FastFile.new.parse("lane :test do
update_info_plist ({
xcodeproj: '#{xcodeproj}',
scheme: '#{scheme}',
block: lambda { |plist|
plist['TEST_PLIST_SUCCESSFULLY_RETRIEVED'] = true
}
})
end").runner.execute(:test)
expect(result).to include("TEST_PLIST_SUCCESSFULLY_RETRIEVED")
end
it "throws an error when the info plist file does not exist" do
# This is path update_info_plist creates to locate the plist file.
full_path = [test_path, proj_file, '..', "NOEXIST-#{plist_path}"].join(File::SEPARATOR)
expect do
Fastlane::FastFile.new.parse("lane :test do
update_info_plist ({
xcodeproj: '#{xcodeproj}',
plist_path: 'NOEXIST-#{plist_path}',
app_identifier: '#{app_identifier}',
display_name: '#{display_name}'
})
end").runner.execute(:test)
end.to raise_error("Couldn't find info plist file at path '#{full_path}'")
end
it "throws an error when the scheme does not exist" do
expect do
Fastlane::FastFile.new.parse("lane :test do
update_info_plist ({
xcodeproj: '#{xcodeproj}',
scheme: 'NOEXIST-#{scheme}',
app_identifier: '#{app_identifier}',
display_name: '#{display_name}'
})
end").runner.execute(:test)
end.to raise_error("Couldn't find scheme named 'NOEXIST-#{scheme}'")
end
it "returns 'false' if no plist parameters are specified" do
result = Fastlane::FastFile.new.parse("lane :test do
update_info_plist ({
xcodeproj: '#{xcodeproj}',
plist_path: 'NOEXIST-#{plist_path}'
})
end").runner.execute(:test)
expect(result).to eq(false)
end
after do
# Clean up files
File.delete(File.join(test_path, plist_path))
FileUtils.rm_rf(xcodeproj)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/set_github_release_spec.rb | fastlane/spec/actions_specs/set_github_release_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "set_github_release" do
describe "with api_token" do
it "sends and receives the right content from GitHub" do
stub_request(:post, "https://api.github.com/repos/czechboy0/czechboy0.github.io/releases").
with(body: "{\"tag_name\":\"tag33\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false,\"name\":\"Awesome Release\",\"body\":\"Bunch of new things :+1:\",\"target_commitish\":\"test\"}",
headers: { 'Authorization' => 'Basic MTIzNDVhYmNkZQ==', 'Host' => 'api.github.com:443', 'User-Agent' => 'fastlane-github_api' }).
to_return(status: 201, body: File.read("./fastlane/spec/fixtures/requests/github_create_release_response.json"), headers: {})
result = Fastlane::FastFile.new.parse("lane :test do
set_github_release(
repository_name: 'czechboy0/czechboy0.github.io',
api_token: '12345abcde',
tag_name: 'tag33',
name: 'Awesome Release',
commitish: 'test',
description: 'Bunch of new things :+1:',
is_draft: 'false',
is_prerelease: 'false',
is_generate_release_notes: 'false'
)
end").runner.execute(:test)
expect(result['html_url']).to eq("https://github.com/czechboy0/czechboy0.github.io/releases/tag/tag33")
expect(result['id']).to eq(1_585_808)
expect(result).to eq(JSON.parse(File.read("./fastlane/spec/fixtures/requests/github_create_release_response.json")))
end
it "returns nil if status code != 201" do
stub_request(:post, "https://api.github.com/repos/czechboy0/czechboy0.github.io/releases").
with(body: "{\"tag_name\":\"tag33\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false,\"name\":\"Awesome Release\",\"body\":\"Bunch of new things :+1:\",\"target_commitish\":\"test\"}",
headers: { 'Authorization' => 'Basic MTIzNDVhYmNkZQ==', 'Host' => 'api.github.com:443', 'User-Agent' => 'fastlane-github_api' }).
to_return(status: 422, headers: {})
result = Fastlane::FastFile.new.parse("lane :test do
set_github_release(
repository_name: 'czechboy0/czechboy0.github.io',
api_token: '12345abcde',
tag_name: 'tag33',
name: 'Awesome Release',
commitish: 'test',
description: 'Bunch of new things :+1:',
is_draft: false,
is_prerelease: false,
is_generate_release_notes: false
)
end").runner.execute(:test)
expect(result).to eq(nil)
end
it "raises error if status code is not a supported error code" do
stub_request(:post, "https://api.github.com/repos/czechboy0/czechboy0.github.io/releases").
with(body: "{\"tag_name\":\"tag33\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false,\"name\":\"Awesome Release\",\"body\":\"Bunch of new things :+1:\",\"target_commitish\":\"test\"}",
headers: { 'Authorization' => 'Basic MTIzNDVhYmNkZQ==', 'Host' => 'api.github.com:443', 'User-Agent' => 'fastlane-github_api' }).
to_return(status: 502, headers: {})
expect do
result = Fastlane::FastFile.new.parse("lane :test do
set_github_release(
repository_name: 'czechboy0/czechboy0.github.io',
api_token: '12345abcde',
tag_name: 'tag33',
name: 'Awesome Release',
commitish: 'test',
description: 'Bunch of new things :+1:',
is_draft: false,
is_prerelease: false,
is_generate_release_notes: false
)
end").runner.execute(:test)
end.to raise_error(/GitHub responded with 502/)
end
it "can use a generated changelog as the description" do
stub_request(:post, "https://api.github.com/repos/czechboy0/czechboy0.github.io/releases").
with(body: "{\"tag_name\":\"tag33\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false,\"name\":\"Awesome Release\",\"body\":\"autogenerated changelog\",\"target_commitish\":\"test\"}",
headers: { 'Authorization' => 'Basic MTIzNDVhYmNkZQ==', 'Host' => 'api.github.com:443', 'User-Agent' => 'fastlane-github_api' }).
to_return(status: 201, body: File.read("./fastlane/spec/fixtures/requests/github_create_release_response.json"), headers: {})
result = Fastlane::FastFile.new.parse("lane :test do
Actions.lane_context[SharedValues::FL_CHANGELOG] = 'autogenerated changelog'
set_github_release(
repository_name: 'czechboy0/czechboy0.github.io',
api_token: '12345abcde',
tag_name: 'tag33',
name: 'Awesome Release',
commitish: 'test',
is_draft: false,
is_prerelease: false,
is_generate_release_notes: false
)
end").runner.execute(:test)
expect(result).to_not(be_nil)
end
it "prefers an explicit description over a generated changelog" do
stub_request(:post, "https://api.github.com/repos/czechboy0/czechboy0.github.io/releases").
with(body: "{\"tag_name\":\"tag33\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false,\"name\":\"Awesome Release\",\"body\":\"explicitly provided\",\"target_commitish\":\"test\"}",
headers: { 'Authorization' => 'Basic MTIzNDVhYmNkZQ==', 'Host' => 'api.github.com:443', 'User-Agent' => 'fastlane-github_api' }).
to_return(status: 201, body: File.read("./fastlane/spec/fixtures/requests/github_create_release_response.json"), headers: {})
result = Fastlane::FastFile.new.parse("lane :test do
Actions.lane_context[SharedValues::FL_CHANGELOG] = 'autogenerated changelog'
set_github_release(
repository_name: 'czechboy0/czechboy0.github.io',
api_token: '12345abcde',
tag_name: 'tag33',
name: 'Awesome Release',
commitish: 'test',
description: 'explicitly provided',
is_draft: false,
is_prerelease: false,
is_generate_release_notes: false
)
end").runner.execute(:test)
expect(result).to_not(be_nil)
end
end
describe "with api_bearer" do
it "sends and receives the right content from GitHub" do
stub_request(:post, "https://api.github.com/repos/czechboy0/czechboy0.github.io/releases").
with(body: "{\"tag_name\":\"tag33\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":false,\"name\":\"Awesome Release\",\"body\":\"Bunch of new things :+1:\",\"target_commitish\":\"test\"}",
headers: { 'Authorization' => 'Bearer 12345abcde', 'Host' => 'api.github.com:443', 'User-Agent' => 'fastlane-github_api' }).
to_return(status: 201, body: File.read("./fastlane/spec/fixtures/requests/github_create_release_response.json"), headers: {})
result = Fastlane::FastFile.new.parse("lane :test do
set_github_release(
repository_name: 'czechboy0/czechboy0.github.io',
api_bearer: '12345abcde',
tag_name: 'tag33',
name: 'Awesome Release',
commitish: 'test',
description: 'Bunch of new things :+1:',
is_draft: 'false',
is_prerelease: 'false',
is_generate_release_notes: 'false'
)
end").runner.execute(:test)
expect(result['html_url']).to eq("https://github.com/czechboy0/czechboy0.github.io/releases/tag/tag33")
expect(result['id']).to eq(1_585_808)
expect(result).to eq(JSON.parse(File.read("./fastlane/spec/fixtures/requests/github_create_release_response.json")))
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/spm_spec.rb | fastlane/spec/actions_specs/spm_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
before do
# Force FastlaneCore::CommandExecutor.execute to return command
allow(FastlaneCore::CommandExecutor).to receive(:execute).and_wrap_original do |m, *args|
args[0][:command]
end
end
describe "SPM Integration" do
it "raises an error if command is invalid" do
expect do
Fastlane::FastFile.new.parse("lane :test do
spm(command: 'invalid_command')
end").runner.execute(:test)
end.to raise_error("Please pass a valid command. Use one of the following: build, test, clean, reset, update, resolve, generate-xcodeproj, init")
end
# Commands
it "default use case is build" do
result = Fastlane::FastFile.new.parse("lane :test do
spm
end").runner.execute(:test)
expect(result).to eq("swift build")
end
it "sets the command to build" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'build')
end").runner.execute(:test)
expect(result).to eq("swift build")
end
it "sets the command to test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'test')
end").runner.execute(:test)
expect(result).to eq("swift test")
end
it "sets the command to update" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'update')
end").runner.execute(:test)
expect(result).to eq("swift package update")
end
it "sets the command to clean" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'clean')
end").runner.execute(:test)
expect(result).to eq("swift package clean")
end
it "sets the command to reset" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'reset')
end").runner.execute(:test)
expect(result).to eq("swift package reset")
end
it "sets the command to generate-xcodeproj" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'generate-xcodeproj')
end").runner.execute(:test)
expect(result).to eq("swift package generate-xcodeproj")
end
it "skips --enable-code-coverage if command is not generate-xcode-proj or test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'build', enable_code_coverage: true)
end").runner.execute(:test)
expect(result).to eq("swift build")
end
it "sets the command to resolve" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(command: 'resolve')
end").runner.execute(:test)
expect(result).to eq("swift package resolve")
end
# Arguments
context "when command is not package related" do
it "adds verbose flag to command if verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(verbose: true)
end").runner.execute(:test)
expect(result).to eq("swift build --verbose")
end
it "doesn't add a verbose flag to command if verbose is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(verbose: false)
end").runner.execute(:test)
expect(result).to eq("swift build")
end
it "adds very_verbose flag to command if very_verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(very_verbose: true)
end").runner.execute(:test)
expect(result).to eq("swift build --very-verbose")
end
it "doesn't add a very_verbose flag to command if very_verbose is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(very_verbose: false)
end").runner.execute(:test)
expect(result).to eq("swift build")
end
it "adds build-path flag to command if build_path is set" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(build_path: 'foobar')
end").runner.execute(:test)
expect(result).to eq("swift build --build-path foobar")
end
it "adds package-path flag to command if package_path is set" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(package_path: 'foobar')
end").runner.execute(:test)
expect(result).to eq("swift build --package-path foobar")
end
it "adds configuration flag to command if configuration is set" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(configuration: 'release')
end").runner.execute(:test)
expect(result).to eq("swift build --configuration release")
end
it "raises an error if configuration is invalid" do
expect do
Fastlane::FastFile.new.parse("lane :test do
spm(configuration: 'foobar')
end").runner.execute(:test)
end.to raise_error("Please pass a valid configuration: (debug|release)")
end
it "adds disable-sandbox flag to command if disable_sandbox is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(disable_sandbox: true)
end").runner.execute(:test)
expect(result).to eq("swift build --disable-sandbox")
end
it "doesn't add a disable-sandbox flag to command if disable_sandbox is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(disable_sandbox: false)
end").runner.execute(:test)
expect(result).to eq("swift build")
end
it "works with no parameters" do
expect do
Fastlane::FastFile.new.parse("lane :test do
spm
end").runner.execute(:test)
end.not_to(raise_error)
end
it "sets --enable-code-coverage to true for test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test',
enable_code_coverage: true
)
end").runner.execute(:test)
expect(result).to eq("swift test --enable-code-coverage")
end
it "sets --enable-code-coverage to false for test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test',
enable_code_coverage: false
)
end").runner.execute(:test)
expect(result).to eq("swift test")
end
it "sets --parallel to true for test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test',
parallel: true
)
end").runner.execute(:test)
expect(result).to eq("swift test --parallel")
end
it "sets --parallel to false for test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test',
parallel: false
)
end").runner.execute(:test)
expect(result).to eq("swift test")
end
it "does not add --parallel by default" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test'
)
end").runner.execute(:test)
expect(result).to eq("swift test")
end
it "does not add --parallel for irrelevant commands" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
parallel: true
)
end").runner.execute(:test)
expect(result).to eq("swift build")
end
end
context "when command is package related" do
let(:command) { 'update' }
it "adds verbose flag to package command if verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
verbose: true
)
end").runner.execute(:test)
expect(result).to eq("swift package --verbose #{command}")
end
it "doesn't add a verbose flag to package command if verbose is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
verbose: false
)
end").runner.execute(:test)
expect(result).to eq("swift package #{command}")
end
it "adds very_verbose flag to package command if very_verbose is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
very_verbose: true
)
end").runner.execute(:test)
expect(result).to eq("swift package --very-verbose #{command}")
end
it "doesn't add a very_verbose flag to package command if very_verbose is set to false" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
very_verbose: false
)
end").runner.execute(:test)
expect(result).to eq("swift package #{command}")
end
it "adds build-path flag to package command if package_path is set to true" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
build_path: 'foobar'
)
end").runner.execute(:test)
expect(result).to eq("swift package --build-path foobar #{command}")
end
it "adds package-path flag to package command if package_path is set" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
package_path: 'foobar'
)
end").runner.execute(:test)
expect(result).to eq("swift package --package-path foobar #{command}")
end
it "adds configuration flag to package command if configuration is set" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
configuration: 'release'
)
end").runner.execute(:test)
expect(result).to eq("swift package --configuration release #{command}")
end
it "raises an error if configuration is invalid" do
expect do
Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
configuration: 'foobar'
)
end").runner.execute(:test)
end.to raise_error("Please pass a valid configuration: (debug|release)")
end
it "raises an error if xcpretty output type is invalid" do
expect do
Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
xcpretty_output: 'foobar'
)
end").runner.execute(:test)
end.to raise_error(/^Please pass a valid xcpretty output type: /)
end
it "passes additional arguments to xcpretty if specified" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
xcpretty_output: 'simple',
xcpretty_args: '--tap --no-utf'
)
end").runner.execute(:test)
expect(result).to eq("set -o pipefail && swift package #{command} 2>&1 | xcpretty --simple --tap --no-utf")
end
it "set pipefail with xcpretty" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: '#{command}',
xcpretty_output: 'simple'
)
end").runner.execute(:test)
expect(result).to eq("set -o pipefail && swift package #{command} 2>&1 | xcpretty --simple")
end
end
context "when command is generate-xcodeproj" do
it "adds xcconfig-overrides with :xcconfig is set and command is package command" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'generate-xcodeproj',
xcconfig: 'Package.xcconfig',
)
end").runner.execute(:test)
expect(result).to eq("swift package generate-xcodeproj --xcconfig-overrides Package.xcconfig")
end
it "sets --enable-code-coverage to true for generate-xcodeproj" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'generate-xcodeproj',
enable_code_coverage: true
)
end").runner.execute(:test)
expect(result).to eq("swift package generate-xcodeproj --enable-code-coverage")
end
it "sets --enable-code-coverage to false for generate-xcodeproj" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'generate-xcodeproj',
enable_code_coverage: false
)
end").runner.execute(:test)
expect(result).to eq("swift package generate-xcodeproj")
end
it "adds --verbose and xcpretty options correctly as well" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'generate-xcodeproj',
xcconfig: 'Package.xcconfig',
verbose: true,
xcpretty_output: 'simple'
)
end").runner.execute(:test)
expect(result).to eq("set -o pipefail && swift package --verbose generate-xcodeproj --xcconfig-overrides Package.xcconfig 2>&1 | xcpretty --simple")
end
it "adds --very-verbose and xcpretty options correctly as well" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'generate-xcodeproj',
xcconfig: 'Package.xcconfig',
very_verbose: true,
xcpretty_output: 'simple'
)
end").runner.execute(:test)
expect(result).to eq("set -o pipefail && swift package --very-verbose generate-xcodeproj --xcconfig-overrides Package.xcconfig 2>&1 | xcpretty --simple")
end
end
context "when simulator is specified" do
it "adds simulator flags to the build command" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'build',
simulator: 'iphonesimulator'
)
end").runner.execute(:test)
expect(result).to eq("swift build -Xswiftc -sdk -Xswiftc $(xcrun --sdk iphonesimulator --show-sdk-path) -Xswiftc -target -Xswiftc arm64-apple-ios$(xcrun --sdk iphonesimulator --show-sdk-version | cut -d '.' -f 1)-simulator")
end
it "raises an error if simulator syntax is invalid" do
expect do
Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'build',
simulator: 'invalid_simulator'
)
end").runner.execute(:test)
end.to raise_error("Please pass a valid simulator. Use one of the following: iphonesimulator, macosx")
end
it "sets arm64 as the default architecture when simulator is specified without architecture" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'build',
simulator: 'iphonesimulator'
)
end").runner.execute(:test)
expect(result).to eq("swift build -Xswiftc -sdk -Xswiftc $(xcrun --sdk iphonesimulator --show-sdk-path) -Xswiftc -target -Xswiftc arm64-apple-ios$(xcrun --sdk iphonesimulator --show-sdk-version | cut -d '.' -f 1)-simulator")
end
it "sets x86-64 as the architecture parameter when simulator is specified" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'build',
simulator: 'iphonesimulator',
simulator_arch: 'x86_64'
)
end").runner.execute(:test)
expect(result).to eq("swift build -Xswiftc -sdk -Xswiftc $(xcrun --sdk iphonesimulator --show-sdk-path) -Xswiftc -target -Xswiftc x86_64-apple-ios$(xcrun --sdk iphonesimulator --show-sdk-version | cut -d '.' -f 1)-simulator")
end
it "sets macosx as the simulator parameter without architecture being specified" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'build',
simulator: 'macosx'
)
end").runner.execute(:test)
expect(result).to eq("swift build -Xswiftc -sdk -Xswiftc $(xcrun --sdk macosx --show-sdk-path) -Xswiftc -target -Xswiftc arm64-apple-macosx$(xcrun --sdk macosx --show-sdk-version | cut -d '.' -f 1)")
end
it "sets macosx as the simulator parameter with x86_64 passed as architecture" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'build',
simulator: 'macosx',
simulator_arch: 'x86_64'
)
end").runner.execute(:test)
expect(result).to eq("swift build -Xswiftc -sdk -Xswiftc $(xcrun --sdk macosx --show-sdk-path) -Xswiftc -target -Xswiftc x86_64-apple-macosx$(xcrun --sdk macosx --show-sdk-version | cut -d '.' -f 1)")
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/deploygate_spec.rb | fastlane/spec/actions_specs/deploygate_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "DeployGate Integration" do
it "raises an error if no parameters were given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate()
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, /No API Token for DeployGate given/)
end
it "raises an error if no api token was given" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate({
ipa: './fastlane/spec/fixtures/fastfiles/Fastfile1',
user: 'deploygate',
})
end").runner.execute(:test)
end.to raise_error("No API Token for DeployGate given, pass using `api_token: 'token'`")
end
it "raises an error if no target user was given" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate({
ipa: './fastlane/spec/fixtures/fastfiles/Fastfile1',
api_token: 'thisistest'
})
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, /No User for DeployGate given/)
end
it "raises an error if no binary path was given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate({
api_token: 'thisistest',
user: 'deploygate'
})
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, 'missing `ipa` and `apk`. deploygate action needs least one.')
end
it "raises an error if the given ipa path was not found" do
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate({
api_token: 'thisistest',
user: 'deploygate',
ipa: './fastlane/nonexistent'
})
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, "Couldn't find ipa file at path './fastlane/nonexistent'")
end
it "raises an error if the given apk path was not found" do
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate({
api_token: 'testistest',
user: 'deploygate',
apk: './fastlane/nonexistent'
})
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, "Couldn't find apk file at path './fastlane/nonexistent'")
end
it "works with valid parameters" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate({
ipa: './fastlane/spec/fixtures/fastfiles/Fastfile1',
user: 'deploygate',
api_token: 'thisistest',
})
end").runner.execute(:test)
end.not_to(raise_error)
end
it "works with valid parameters include optionals" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
expect do
Fastlane::FastFile.new.parse("lane :test do
deploygate({
ipa: './fastlane/spec/fixtures/fastfiles/Fastfile1',
user: 'deploygate',
api_token: 'thisistest',
release_note: 'This is a test release.',
disable_notify: true,
distribution_name: 'test_name',
})
end").runner.execute(:test)
end.not_to(raise_error)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/register_devices_spec.rb | fastlane/spec/actions_specs/register_devices_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Register Devices Action" do
let(:devices_file_with_platform) do
File.absolute_path('./fastlane/spec/fixtures/actions/register_devices/devices-list-with-platform.txt')
end
let(:devices_file_without_platform) do
File.absolute_path('./fastlane/spec/fixtures/actions/register_devices/devices-list-without-platform.txt')
end
let(:devices_file_with_spaces) do
File.absolute_path('./fastlane/spec/fixtures/actions/register_devices/devices-list-with-spaces.txt')
end
let(:devices_file_with_too_many_columns) do
File.absolute_path('./fastlane/spec/fixtures/actions/register_devices/devices-list-with-too-many-columns.txt')
end
let(:existing_device) { double }
let(:fake_devices) { [existing_device] }
let(:fake_credentials) { double }
before(:each) do
allow(fake_credentials).to receive(:user)
allow(fake_credentials).to receive(:password)
allow(CredentialsManager::AccountManager).to receive(:new).and_return(fake_credentials)
allow(Spaceship::Portal).to receive(:login)
allow(Spaceship::Portal).to receive(:select_team)
allow(existing_device).to receive(:udid).and_return("A123456789012345678901234567890123456789")
end
it "registers devices with file with platform" do
expect(Spaceship::ConnectAPI::Device).to receive(:all).and_return(fake_devices)
expect(Fastlane::Actions::RegisterDevicesAction).to receive(:try_create_device).with(
name: 'NAME2',
udid: 'B123456789012345678901234567890123456789',
platform: "IOS"
)
expect(Fastlane::Actions::RegisterDevicesAction).to receive(:try_create_device).with(
name: 'NAME3',
udid: 'A5B5CD50-14AB-5AF7-8B78-AB4751AB10A8',
platform: "MAC_OS"
)
expect(Fastlane::Actions::RegisterDevicesAction).to receive(:try_create_device).with(
name: 'NAME4',
udid: 'A5B5CD50-14AB-5AF7-8B78-AB4751AB10A7',
platform: "MAC_OS"
)
result = Fastlane::FastFile.new.parse("lane :test do
register_devices(
username: 'test@test.com',
devices_file: '#{devices_file_with_platform}'
)
end").runner.execute(:test)
end
it "registers devices for ios with file without platform" do
expect(Spaceship::ConnectAPI::Device).to receive(:all).and_return(fake_devices)
expect(Fastlane::Actions::RegisterDevicesAction).to receive(:try_create_device).with(
name: 'NAME2',
udid: 'B123456789012345678901234567890123456789',
platform: "IOS"
)
result = Fastlane::FastFile.new.parse("lane :test do
register_devices(
username: 'test@test.com',
devices_file: '#{devices_file_without_platform}',
platform: 'ios'
)
end").runner.execute(:test)
end
it "registers devices for mac with file without platform" do
expect(Spaceship::ConnectAPI::Device).to receive(:all).and_return(fake_devices)
expect(Fastlane::Actions::RegisterDevicesAction).to receive(:try_create_device).with(
name: 'NAME2',
udid: 'B123456789012345678901234567890123456789',
platform: "MAC_OS"
)
result = Fastlane::FastFile.new.parse("lane :test do
register_devices(
username: 'test@test.com',
devices_file: '#{devices_file_without_platform}',
platform: 'mac'
)
end").runner.execute(:test)
end
describe "displays error messages" do
it "raises when csv has spaces" do
expect do
result = Fastlane::FastFile.new.parse("lane :test do
register_devices(
username: 'test@test.com',
devices_file: '#{devices_file_with_spaces}',
platform: 'mac'
)
end").runner.execute(:test)
end.to raise_error("Invalid device line, ensure you are using tabs (NOT spaces). See Apple's sample/spec here: https://developer.apple.com/account/resources/downloads/Multiple-Upload-Samples.zip")
end
it "raises when csv too many columns" do
expect do
result = Fastlane::FastFile.new.parse("lane :test do
register_devices(
username: 'test@test.com',
devices_file: '#{devices_file_with_too_many_columns}',
platform: 'mac'
)
end").runner.execute(:test)
end.to raise_error("Invalid device line, please provide a file according to the Apple Sample UDID file (https://developer.apple.com/account/resources/downloads/Multiple-Upload-Samples.zip)")
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/prompt_spec.rb | fastlane/spec/actions_specs/prompt_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "prompt" do
it "uses the CI value if necessary" do
# make prompt think we're running in CI mode
expect(FastlaneCore::UI).to receive(:interactive?).with(no_args).and_return(false)
result = Fastlane::FastFile.new.parse("lane :test do
prompt(text: 'text', ci_input: 'ci')
end").runner.execute(:test)
expect(result).to eq('ci')
end
it "reads full lines from $stdin until encountering multi_line_end_keyword" do
# make prompt think we're running in interactive, non-CI mode
expect(FastlaneCore::UI).to receive(:interactive?).with(no_args).and_return(true)
expect($stdin).to receive(:gets).with(no_args).and_return("First line\n", "Second lineEND\n")
result = Fastlane::FastFile.new.parse("lane :test do
prompt(text: 'text', multi_line_end_keyword: 'END', ci_input: 'if this value is returned, prompt incorrectly assumes CI mode')
end").runner.execute(:test)
expect(result).to eq("First line\nSecond line")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/rsync_spec.rb | fastlane/spec/actions_specs/rsync_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "rsync" do
it "generates a valid command" do
result = Fastlane::FastFile.new.parse("lane :test do
rsync(source: '/tmp/1.txt', destination: '/tmp/2.txt')
end").runner.execute(:test)
expect(result).to eq("rsync -av /tmp/1.txt /tmp/2.txt")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/update_plist_spec.rb | fastlane/spec/actions_specs/update_plist_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Update Plist Integration" do
let(:test_path) { "/tmp/fastlane/tests/fastlane" }
let(:fixtures_path) { "./fastlane/spec/fixtures/xcodeproj" }
let(:proj_file) { "bundle.xcodeproj" }
let(:plist_path) { "Info.plist" }
let(:app_identifier) { "com.test.plist" }
let(:display_name) { "Update Info Plist Test" }
before do
# Set up example info.plist
FileUtils.mkdir_p(test_path)
source = File.join(fixtures_path, proj_file)
destination = File.join(test_path, proj_file)
# Copy .xcodeproj fixture, as it will be modified during the test
FileUtils.cp_r(source, destination)
File.write(File.join(test_path, plist_path), '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>CFBundleDisplayName</key><string>empty</string><key>CFBundleIdentifier</key><string>empty</string></dict></plist>')
end
it "updates the plist based on the given block" do
result = Fastlane::FastFile.new.parse("lane :test do
update_plist ({
plist_path: '#{test_path}/#{plist_path}',
block: proc do |plist|
plist['CFBundleIdentifier'] = '#{app_identifier}'
plist['CFBundleDisplayName'] = '#{display_name}'
end
})
end").runner.execute(:test)
expect(result).to include("<string>#{display_name}</string>")
expect(result).to include("<string>#{app_identifier}</string>")
end
it "throws an error when the plist file does not exist" do
# This is path update_plist creates to locate the plist file.
full_path = [test_path, proj_file, '..', "NOEXIST-#{plist_path}"].join(File::SEPARATOR)
expect do
Fastlane::FastFile.new.parse("lane :test do
update_plist ({
plist_path: 'NOEXIST-#{plist_path}',
block: proc do |plist|
plist['CFBundleDisplayName'] = '#{app_identifier}'
end
})
end").runner.execute(:test)
end.to raise_error("Couldn't find plist file at path 'NOEXIST-#{plist_path}'")
end
after do
# Clean up files
File.delete(File.join(test_path, plist_path))
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/appetize_spec.rb | fastlane/spec/actions_specs/appetize_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
let(:response_string) do
<<-"EOS"
{
"privateKey" : "private_Djksfj",
"publicKey" : "sKdfjL",
"appURL" : "https://appetize.io/app/sKdfjL",
"manageURL" : "https://appetize.io/manage/private_Djksfj"
}
EOS
end
let(:api_host) { 'custom.appetize.io' }
let(:api_token) { 'mysecrettoken' }
let(:url) { 'https://example.com/app.zip' }
let(:http) { double('http') }
let(:request) { double('request') }
let(:response) { double('response') }
let(:params) do
{ token: api_token,
url: url,
platform: 'ios' }
end
before do
allow(Net::HTTP).to receive(:new).and_return(http)
allow(Net::HTTP::Post).to receive(:new).and_return(request)
allow(http).to receive(:use_ssl=).with(true)
allow(http).to receive(:request).with(request).and_return(response)
allow(request).to receive(:basic_auth).with(api_token, nil)
allow(request).to receive(:body=).with(kind_of(String)).and_return(response)
allow(response).to receive(:body).and_return(response_string)
allow(response).to receive(:code).and_return('200')
end
describe "Appetize Integration" do
it "raises an error if no parameters were given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appetize()
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end
it "raises an error if no url or path was given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appetize({
api_token: '#{api_token}'
})
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, /url parameter is required/)
end
it "works with valid parameters" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appetize({
api_token: '#{api_token}',
url: '#{url}'
})
end").runner.execute(:test)
end.not_to(raise_error)
expect(http).not_to(receive(:request).with(JSON.generate(params)))
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APPETIZE_PUBLIC_KEY]).to eql('sKdfjL')
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APPETIZE_APP_URL]).to eql('https://appetize.io/app/sKdfjL')
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APPETIZE_MANAGE_URL]).to eql('https://appetize.io/manage/private_Djksfj')
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APPETIZE_API_HOST]).to eql('api.appetize.io')
end
it "raises an error when the API returns an unsuccessful status code" do
allow(response).to receive(:code).and_return('401')
allow(response).to receive(:body).and_return('{"message": "Invalid Key"}')
expect do
Fastlane::FastFile.new.parse("lane :test do
appetize({
api_token: '#{api_token}',
url: '#{url}'
})
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, /Error uploading to Appetize.io: received HTTP 401 with body {"message": "Invalid Key"}/)
end
it "works with custom API host" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appetize({
api_host: '#{api_host}',
api_token: '#{api_token}',
url: '#{url}'
})
end").runner.execute(:test)
end.not_to(raise_error)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APPETIZE_API_HOST]).to eql(api_host)
end
it "raises an error if an invalid timeout was given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
appetize({
api_token: '#{api_token}',
url: '#{url}',
timeout: 9999
})
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError, /value provided doesn't match any of the supported options/)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/download_spec.rb | fastlane/spec/actions_specs/download_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "download" do
before do
stub_request(:get, "https://google.com/remoteFile.json").
to_return(status: 200, body: { status: :ok }.to_json, headers: {})
stub_request(:get, "https://google.com/timeout.json").to_timeout
end
it "downloads the file from a remote server" do
url = "https://google.com/remoteFile.json"
result = Fastlane::FastFile.new.parse("lane :test do
download(url: '#{url}')
end").runner.execute(:test)
correct = { 'status' => 'ok' }
expect(result).to eq(correct)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::DOWNLOAD_CONTENT]).to eq(correct)
end
it "properly handles network failures" do
expect do
url = "https://google.com/timeout.json"
result = Fastlane::FastFile.new.parse("lane :test do
download(url: '#{url}')
end").runner.execute(:test)
end.to raise_error("Error fetching remote file: execution expired")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/dsym_zip_spec.rb | fastlane/spec/actions_specs/dsym_zip_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Create dSYM zip" do
xcodebuild_archive = 'MyApp.xcarchive'
before(:each) do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::XCODEBUILD_ARCHIVE] = xcodebuild_archive
end
context "when there's no custom zip path" do
result = nil
before :each do
result = Fastlane::FastFile.new.parse("lane :test do
dsym_zip
end").runner.execute(:test)
end
it "creates a zip file with default archive_path from xcodebuild" do
# Move one folder above as specs are execute in fastlane folder
root_path = File.expand_path(".")
file_basename = File.basename(xcodebuild_archive, '.*')
dsym_folder_path = File.join(root_path, File.join(xcodebuild_archive, 'dSYMs'))
zipped_dsym_path = File.join(root_path, "#{file_basename}.app.dSYM.zip")
expect(result).to eq(%(cd "#{dsym_folder_path}" && zip -r "#{zipped_dsym_path}" "MyApp.app.dSYM"))
end
end
context "when there's a custom zip path" do
result = nil
before :each do
result = Fastlane::FastFile.new.parse("lane :test do
dsym_zip(
archive_path: 'CustomApp.xcarchive'
)
end").runner.execute(:test)
end
it "creates a zip file with a custom archive path" do
custom_app_path = 'CustomApp.xcarchive'
# Move one folder above as specs are execute in fastlane folder
root_path = File.expand_path(".")
file_basename = File.basename(custom_app_path.to_s, '.*')
dsym_folder_path = File.join(root_path, File.join(custom_app_path.to_s, 'dSYMs'))
zipped_dsym_path = File.join(root_path, "#{file_basename}.app.dSYM.zip")
# MyApp is hardcoded into tested class so we'll just use that here
expect(result).to eq(%(cd "#{dsym_folder_path}" && zip -r "#{zipped_dsym_path}" "MyApp.app.dSYM"))
end
end
context "when there's a custom dsym path" do
result = nil
before :each do
result = Fastlane::FastFile.new.parse("lane :test do
dsym_zip(
dsym_path: 'CustomPath/MyApp.app.dSYM.zip'
)
end").runner.execute(:test)
end
it "creates a zip file with a custom dsym path" do
# Move one folder above as specs are execute in fastlane folder
root_path = File.expand_path(".")
file_basename = File.basename(xcodebuild_archive, '.*')
dsym_folder_path = File.join(root_path, File.join(xcodebuild_archive, 'dSYMs'))
zipped_dsym_path = File.join(File.join(root_path, 'CustomPath'), "#{file_basename}.app.dSYM.zip")
expect(result).to eq(%(cd "#{dsym_folder_path}" && zip -r "#{zipped_dsym_path}" "MyApp.app.dSYM"))
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/get_managed_play_store_publishing_rights_spec.rb | fastlane/spec/actions_specs/get_managed_play_store_publishing_rights_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "get_managed_play_store_publishing_rights" do
let(:json_key_path) { File.expand_path("./fastlane/spec/fixtures/google_play/google_play.json") }
let(:json_key_data) { File.open(json_key_path, 'rb').read }
let(:json_key_client_email) { JSON.parse(json_key_data)['client_email'] }
describe "without options" do
it "could not find file" do
expect(UI).to receive(:important).with("To not be asked about this value, you can specify it using 'json_key'")
expect(UI).to receive(:input).with(anything).and_return("not_a_file")
expect(UI).to receive(:user_error!).with(/Could not find service account json file at path*/).and_raise("boom")
expect do
Fastlane::FastFile.new.parse("lane :test do
get_managed_play_store_publishing_rights()
end").runner.execute(:test)
end.to raise_error("boom")
end
it "found file" do
expect(UI).to receive(:important).with("To not be asked about this value, you can specify it using 'json_key'").once
expect(UI).to receive(:input).with(anything).and_return(json_key_path)
expect(UI).to receive(:important).with("https://play.google.com/apps/publish/delegatePrivateApp?service_account=#{json_key_client_email}&continueUrl=https://fastlane.github.io/managed_google_play-callback/callback.html")
Fastlane::FastFile.new.parse("lane :test do
get_managed_play_store_publishing_rights()
end").runner.execute(:test)
end
end
describe "with options" do
it "with :json_key" do
expect(UI).to receive(:important).with("https://play.google.com/apps/publish/delegatePrivateApp?service_account=#{json_key_client_email}&continueUrl=https://fastlane.github.io/managed_google_play-callback/callback.html")
Fastlane::FastFile.new.parse("lane :test do
get_managed_play_store_publishing_rights(
json_key: '#{json_key_path}'
)
end").runner.execute(:test)
end
it "with :json_key_data" do
expect(UI).to receive(:important).with("https://play.google.com/apps/publish/delegatePrivateApp?service_account=#{json_key_client_email}&continueUrl=https://fastlane.github.io/managed_google_play-callback/callback.html")
Fastlane::FastFile.new.parse("lane :test do
get_managed_play_store_publishing_rights(
json_key_data: '#{json_key_data}'
)
end").runner.execute(:test)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/cloc_spec.rb | fastlane/spec/actions_specs/cloc_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "CLOC Integration" do
it "does run cloc using only default options" do
result = Fastlane::FastFile.new.parse("lane :test do
cloc
end").runner.execute(:test)
expect(result).to eq("/usr/local/bin/cloc --by-file --xml --out=build/cloc.xml")
end
it 'does set the exclude directories' do
result = Fastlane::FastFile.new.parse("lane :test do
cloc(exclude_dir: 'test1,test2,build')
end").runner.execute(:test)
expect(result).to eq("/usr/local/bin/cloc --exclude-dir=test1,test2,build --by-file --xml --out=build/cloc.xml")
end
it 'does set the output directory' do
result = Fastlane::FastFile.new.parse("lane :test do
cloc(output_directory: '/tmp')
end").runner.execute(:test)
expect(result).to eq("/usr/local/bin/cloc --by-file --xml --out=/tmp/cloc.xml")
end
it 'does set the source directory' do
result = Fastlane::FastFile.new.parse("lane :test do
cloc(source_directory: 'MyCoolApp')
end").runner.execute(:test)
expect(result).to eq("/usr/local/bin/cloc --by-file --xml --out=build/cloc.xml MyCoolApp")
end
it 'does switch to plain text when xml is toggled off' do
result = Fastlane::FastFile.new.parse("lane :test do
cloc(xml: false)
end").runner.execute(:test)
expect(result).to eq("/usr/local/bin/cloc --by-file --out=build/cloc.txt")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/git_pull_spec.rb | fastlane/spec/actions_specs/git_pull_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Git Pull Action" do
it "runs git pull and git fetch with tags by default" do
result = Fastlane::FastFile.new.parse("lane :test do
git_pull
end").runner.execute(:test)
expect(result).to eq("git pull && git fetch --tags")
end
it "only runs git fetch --tags if only_tags" do
result = Fastlane::FastFile.new.parse("lane :test do
git_pull(
only_tags: true
)
end").runner.execute(:test)
expect(result).to eq("git fetch --tags")
end
it "uses git pull --rebase if rebase" do
result = Fastlane::FastFile.new.parse("lane :test do
git_pull(
rebase: true
)
end").runner.execute(:test)
expect(result).to eq("git pull --rebase && git fetch --tags")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/setup_circle_ci_spec.rb | fastlane/spec/actions_specs/setup_circle_ci_spec.rb | describe Fastlane do
describe Fastlane::Actions::SetupCircleCiAction do
describe "Setup CircleCi Integration" do
let(:tmp_keychain_name) { "fastlane_tmp_keychain" }
def check_keychain_nil
expect(ENV["MATCH_KEYCHAIN_NAME"]).to be_nil
expect(ENV["MATCH_KEYCHAIN_PASSWORD"]).to be_nil
expect(ENV["MATCH_READONLY"]).to be_nil
end
def check_keychain_created
expect(ENV["MATCH_KEYCHAIN_NAME"]).to eq(tmp_keychain_name)
expect(ENV["MATCH_KEYCHAIN_PASSWORD"]).to eq("")
expect(ENV["MATCH_READONLY"]).to eq("true")
end
it "doesn't work outside CI" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
stub_const("ENV", {})
expect(UI).to receive(:message).with("Not running on CI, skipping CI setup")
Fastlane::FastFile.new.parse("lane :test do
setup_circle_ci
end").runner.execute(:test)
check_keychain_nil
end
it "skips outside macOS CI agent" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(false)
stub_const("ENV", { "FL_SETUP_CIRCLECI_FORCE" => "true" })
expect(UI).to receive(:message).with("Skipping Log Path setup as FL_OUTPUT_DIR is unset")
expect(UI).to receive(:message).with("Skipping Keychain setup on non-macOS CI Agent")
Fastlane::FastFile.new.parse("lane :test do
setup_circle_ci
end").runner.execute(:test)
check_keychain_nil
end
it "works on macOS Environment when forced" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
stub_const("ENV", {})
Fastlane::FastFile.new.parse("lane :test do
setup_circle_ci(
force: true
)
end").runner.execute(:test)
check_keychain_created
end
it "works on macOS Environment inside CI" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
expect(Fastlane::Actions::CreateKeychainAction).to receive(:run).with(
{
name: tmp_keychain_name,
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: true,
password: "",
add_to_search_list: true
}
)
stub_const("ENV", { "FL_SETUP_CIRCLECI_FORCE" => "true" })
Fastlane::FastFile.new.parse("lane :test do
setup_circle_ci
end").runner.execute(:test)
check_keychain_created
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/notification_spec.rb | fastlane/spec/actions_specs/notification_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "notification action" do
it "raises without a message" do
expect do
Fastlane::FastFile.new.parse("lane :test do
notification(
title: 'hello',
subtitle: 'hi'
)
end").runner.execute(:test)
end.to raise_exception(FastlaneCore::Interface::FastlaneError, "No value found for 'message'")
end
it "works with message argument alone" do
# fastlane passes default :title of 'fastlane'
expect(TerminalNotifier).to receive(:notify).with("hello", hash_including)
Fastlane::FastFile.new.parse("lane :test do
notification(
message: 'hello'
)
end").runner.execute(:test)
end
it "provides default title of 'fastlane'" do
expect(TerminalNotifier).to receive(:notify).with("hello", hash_including(title: 'fastlane'))
Fastlane::FastFile.new.parse("lane :test do
notification(
message: 'hello'
)
end").runner.execute(:test)
end
it "passes all supported specified arguments to terminal-notifier" do
args = {
title: "My Great App",
subtitle: "Check it out at http://store.itunes.com/abcd",
sound: "default",
activate: "com.apple.Safari",
appIcon: "path/to/app_icon.png",
contentImage: "path/to/content_image.png",
open: "http://store.itunes.com/abcd",
execute: "ls"
}
expect(TerminalNotifier).to receive(:notify).with("hello", hash_including(**args))
Fastlane::FastFile.new.parse("lane :test do
notification(
message: 'hello',
title: '#{args[:title]}',
subtitle: '#{args[:subtitle]}',
sound: '#{args[:sound]}',
activate: '#{args[:activate]}',
app_icon: '#{args[:appIcon]}',
content_image: '#{args[:contentImage]}',
open: '#{args[:open]}',
execute: '#{args[:execute]}'
)
end").runner.execute(:test)
end
it "does not pass unspecified arguments with message argument" do
expect(TerminalNotifier).to receive(:notify).with("hello", hash_excluding(:subtitle, :sound, :activate, :appIcon, :contentImage, :open, :execute))
Fastlane::FastFile.new.parse("lane :test do
notification(
message: 'hello'
)
end").runner.execute(:test)
end
it "does not pass unspecified arguments with message and title argument" do
expect(TerminalNotifier).to receive(:notify).with("hello", hash_excluding(:subtitle, :sound, :activate, :appIcon, :contentImage, :open, :execute))
Fastlane::FastFile.new.parse("lane :test do
notification(
message: 'hello',
title: 'My Great App'
)
end").runner.execute(:test)
end
it "does not pass unspecified arguments with message and subtitle argument" do
expect(TerminalNotifier).to receive(:notify).with("hello", hash_excluding(:sound, :activate, :appIcon, :contentImage, :open, :execute))
Fastlane::FastFile.new.parse("lane :test do
notification(
message: 'hello',
subtitle: 'My Great App'
)
end").runner.execute(:test)
end
it "does not pass unspecified arguments with message, title and subtitle argument" do
expect(TerminalNotifier).to receive(:notify).with("hello", hash_excluding(:sound, :activate, :appIcon, :contentImage, :open, :execute))
Fastlane::FastFile.new.parse("lane :test do
notification(
message: 'hello',
title: 'hi',
subtitle: 'My Great App'
)
end").runner.execute(:test)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/git_submodule_update_spec.rb | fastlane/spec/actions_specs/git_submodule_update_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "git_submodule_update" do
it "runs git submodule update without options by default" do
result = Fastlane::FastFile.new.parse("lane :test do
git_submodule_update
end").runner.execute(:test)
expect(result).to eq("git submodule update")
end
it "updates the submodules recursively if requested" do
result = Fastlane::FastFile.new.parse("lane :test do
git_submodule_update(
recursive: true
)
end").runner.execute(:test)
expect(result).to eq("git submodule update --recursive")
end
it "initialize the submodules if requested" do
result = Fastlane::FastFile.new.parse("lane :test do
git_submodule_update(
init: true
)
end").runner.execute(:test)
expect(result).to eq("git submodule update --init")
end
it "initialize the submodules and updates them recursively if requested" do
result = Fastlane::FastFile.new.parse("lane :test do
git_submodule_update(
recursive: true,
init: true
)
end").runner.execute(:test)
expect(result).to eq("git submodule update --init --recursive")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/setup_ci_spec.rb | fastlane/spec/actions_specs/setup_ci_spec.rb | describe Fastlane do
describe Fastlane::Actions::SetupCiAction do
describe "#run" do
context "when it should run" do
before do
stub_const("ENV", { "CI" => "anything" })
allow(Fastlane::Actions::CreateKeychainAction).to receive(:run).and_return(nil)
end
describe "calls setup_keychain after setup_output_paths if :provider is set to circleci on Mac Agents" do
it "runs on Mac" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
# Message is asserted in reverse order, hence output of setup_output_paths is expected last
expect(Fastlane::UI).to receive(:message).with("Enabling match readonly mode.")
expect(Fastlane::UI).to receive(:message).with("Creating temporary keychain: \"fastlane_tmp_keychain\".")
expect(Fastlane::UI).to receive(:message).with("Skipping Log Path setup as FL_OUTPUT_DIR is unset")
described_class.run(provider: "circleci", keychain_name: "fastlane_tmp_keychain")
end
it "skips on linux" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(false)
expect(Fastlane::UI).to receive(:message).with("Skipping Log Path setup as FL_OUTPUT_DIR is unset")
expect(Fastlane::UI).to receive(:message).with("Skipping Keychain setup on non-macOS CI Agent")
described_class.run(provider: "circleci")
end
end
describe "calls setup_keychain after setup_output_paths if CODEBUILD_BUILD_ARN env variable is set on Mac Agents" do
before do
stub_const("ENV", { "CODEBUILD_BUILD_ARN" => "anything" })
end
it "runs on Mac" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
# Message is asserted in reverse order, hence output of setup_output_paths is expected last
expect(Fastlane::UI).to receive(:message).with("Enabling match readonly mode.")
expect(Fastlane::UI).to receive(:message).with("Creating temporary keychain: \"fastlane_tmp_keychain\".")
expect(Fastlane::UI).to receive(:message).with("Skipping Log Path setup as FL_OUTPUT_DIR is unset")
described_class.run(force: true, keychain_name: "fastlane_tmp_keychain")
end
it "skips on linux" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(false)
expect(Fastlane::UI).to receive(:message).with("Skipping Log Path setup as FL_OUTPUT_DIR is unset")
expect(Fastlane::UI).to receive(:message).with("Skipping Keychain setup on non-macOS CI Agent")
described_class.run(provider: "circleci")
end
end
describe "calls setup_keychain if no provider is be detected on Mac Agents" do
it "runs on Mac" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
expect(Fastlane::UI).to receive(:message).with("Enabling match readonly mode.")
expect(Fastlane::UI).to receive(:message).with("Creating temporary keychain: \"fastlane_tmp_keychain\".")
described_class.run(force: true, keychain_name: "fastlane_tmp_keychain")
end
it "skips on linux" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(false)
expect(Fastlane::UI).to receive(:message).with("Skipping Keychain setup on non-macOS CI Agent")
described_class.run(force: true)
end
end
describe "keychain_name option" do
it "accepts a custom keychain_name" do
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
expect(Fastlane::UI).to receive(:message).with("Enabling match readonly mode.")
expect(Fastlane::UI).to receive(:message).with("Creating temporary keychain: \"example_keychain_name\".")
described_class.run(force: true, keychain_name: "example_keychain_name")
end
end
end
end
describe "#should_run" do
context "when running on CI" do
before do
expect(Fastlane::Helper).to receive(:ci?).and_return(true)
end
it "returns true when :force is true" do
expect(described_class.should_run?(force: true)).to eql(true)
end
it "returns true when :force is false" do
expect(described_class.should_run?(force: false)).to eql(true)
end
end
context "when not running on CI" do
before do
expect(Fastlane::Helper).to receive(:ci?).and_return(false)
end
it "returns false when :force is not set" do
expect(described_class.should_run?(force: false)).to eql(false)
end
it "returns true when :force is set" do
expect(described_class.should_run?(force: true)).to eql(true)
end
end
end
describe "#detect_provider" do
context "when running on CircleCI" do
before do
stub_const("ENV", { "CIRCLECI" => "anything" })
end
it "returns circleci when :provider is not set" do
expect(described_class.detect_provider({})).to eql("circleci")
end
it "returns github when :provider is set to github" do
expect(described_class.detect_provider(provider: "github")).to eql("github")
end
end
context "When running on CodeBuild" do
before do
stub_const("ENV", { "CODEBUILD_BUILD_ARN" => "anything" })
end
it "returns codebuild when :provider is not set" do
expect(described_class.detect_provider({})).to eql("codebuild")
end
end
context "when not running on CircleCI and CodeBuild" do
before do
# Unset environment to ensure CIRCLECI is not set even if the test suite is run on CircleCI
stub_const("ENV", {})
end
it "returns nil when :provider is not set" do
expect(described_class.detect_provider({})).to eql(nil)
end
it "returns github when :provider is set to github" do
expect(described_class.detect_provider(provider: "github")).to eql("github")
end
end
end
describe "#setup_keychain" do
context "when MATCH_KEYCHAIN_NAME is set" do
it "skips the setup process" do
stub_const("ENV", { "MATCH_KEYCHAIN_NAME" => "anything" })
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
expect(Fastlane::UI).to receive(:message).with("Skipping Keychain setup as a keychain was already specified")
described_class.setup_keychain(timeout: 3600)
end
end
context "when operating system is macOS" do
before do
stub_const("ENV", {})
allow(Fastlane::Actions::CreateKeychainAction).to receive(:run).and_return(nil)
allow(FastlaneCore::Helper).to receive(:mac?).and_return(true)
end
it "sets the MATCH_KEYCHAIN_NAME env var" do
described_class.setup_keychain(timeout: 3600, keychain_name: "example_keychain_name")
expect(ENV["MATCH_KEYCHAIN_NAME"]).to eql("example_keychain_name")
end
it "sets the MATCH_KEYCHAIN_PASSWORD env var" do
described_class.setup_keychain(timeout: 3600)
expect(ENV["MATCH_KEYCHAIN_PASSWORD"]).to eql("")
end
it "sets the MATCH_READONLY env var" do
described_class.setup_keychain(timeout: 3600)
expect(ENV["MATCH_READONLY"]).to eql("true")
end
end
context "when operating system is not macOS" do
it "skips the setup process" do
stub_const("ENV", {})
allow(Fastlane::Actions::CreateKeychainAction).to receive(:run).and_return(nil)
allow(FastlaneCore::Helper).to receive(:mac?).and_return(false)
expect(Fastlane::UI).to receive(:message).with("Skipping Keychain setup on non-macOS CI Agent")
described_class.setup_keychain(timeout: 3600)
end
end
end
describe "#setup_output_paths" do
before do
stub_const("ENV", { "FL_OUTPUT_DIR" => "/dev/null" })
end
it "sets the SCAN_OUTPUT_DIRECTORY" do
described_class.setup_output_paths
expect(ENV["SCAN_OUTPUT_DIRECTORY"]).to eql("/dev/null/scan")
end
it "sets the GYM_OUTPUT_DIRECTORY" do
described_class.setup_output_paths
expect(ENV["GYM_OUTPUT_DIRECTORY"]).to eql("/dev/null/gym")
end
it "sets the FL_BUILDLOG_PATH" do
described_class.setup_output_paths
expect(ENV["FL_BUILDLOG_PATH"]).to eql("/dev/null/buildlogs")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/add_extra_platforms_spec.rb | fastlane/spec/actions_specs/add_extra_platforms_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "add_extra_platforms" do
before(:each) do
allow(Fastlane::SupportedPlatforms).to receive(:all).and_return([:ios, :macos, :android])
end
it "updates the extra supported platforms" do
expect(UI).to receive(:verbose).with("Before injecting extra platforms: [:ios, :macos, :android]")
expect(Fastlane::SupportedPlatforms).to receive(:extra=).with([:windows, :neogeo])
expect(UI).to receive(:verbose).with("After injecting extra platforms ([:windows, :neogeo])...: [:ios, :macos, :android]")
Fastlane::FastFile.new.parse("lane :test do
add_extra_platforms(platforms: [:windows, :neogeo])
end").runner.execute(:test)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/download_universal_apk_from_google_play_spec.rb | fastlane/spec/actions_specs/download_universal_apk_from_google_play_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "download_universal_apk_from_google_play" do
let(:client_stub) { instance_double(Supply::Client) }
let(:package_name) { 'com.fastlane.myapp' }
let(:version_code) { 1337 }
let(:json_key_path) { File.expand_path("./fastlane/spec/fixtures/google_play/google_play.json") }
let(:destination) { '/tmp/universal-apk/fastlane-generated-apk-spec.apk' }
let(:cert_sha_1) { '01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:15:16:17:18:19:1a:1b:1c:1d:1e:1f:20' }
let(:download_id_1) { 'Stub_Id_For_Cert_1' }
let(:cert_sha_2) { 'a1:a2:a3:a4:a5:a6:a7:a8:a9:aa:ab:ac:ad:ae:af:b0:b1:b2:b3:b4:b5:b6:b7:b8:b9:ba:bb:bc:bd:be:bf:c0' }
let(:download_id_2) { 'Stub_Id_For_Cert_2' }
let(:cert_sha_not_found) { '00:de:ad:00:be:ef:00:00:ba:ad:00:ca:fe:00:00:fe:ed:00:c0:ff:ee:00:b4:00:f0:0d:00:00:12:34:56:78' }
let(:cert_sha_invalid_format) { cert_sha_1.gsub(':', '') }
let(:cert_sha_too_short) { '13:37:00:42' }
before :each do
allow(Supply::Client).to receive_message_chain(:make_from_config).and_return(client_stub)
end
def stub_client_list(download_id_per_cert)
response = download_id_per_cert.map do |cert_hash, download_id|
Supply::GeneratedUniversalApk.new(package_name, version_code, cert_hash, download_id)
end
allow(client_stub).to receive(:list_generated_universal_apks)
.with(package_name: package_name, version_code: version_code)
.and_return(response)
end
context 'when no `certificate_sha256_hash` is provided' do
it 'finds and download the only generated APK' do
stub_client_list({ cert_sha_1 => download_id_1 })
expected_ref = Supply::GeneratedUniversalApk.new(package_name, version_code, cert_sha_1, download_id_1)
expect(FileUtils).to receive(:mkdir_p).with('/tmp/universal-apk')
expect(client_stub).to receive(:download_generated_universal_apk)
.with(generated_universal_apk: expected_ref, destination: destination)
result = Fastlane::FastFile.new.parse("lane :test do
download_universal_apk_from_google_play(
package_name: '#{package_name}',
version_code: '#{version_code}',
json_key: '#{json_key_path}',
destination: '#{destination}'
)
end").runner.execute(:test)
expect(result).to eq(destination)
end
it 'raises if it finds more than one APK' do
stub_client_list({ cert_sha_1 => download_id_1, cert_sha_2 => download_id_2 })
expect(client_stub).not_to receive(:download_generated_universal_apk)
expected_error = <<~ERROR
We found multiple Generated Universal APK, with the following `certificate_sha256_hash`:
- #{cert_sha_1}
- #{cert_sha_2}
Use the `certificate_sha256_hash` parameter to specify which one to download.
ERROR
expect {
Fastlane::FastFile.new.parse("lane :test do
download_universal_apk_from_google_play(
package_name: '#{package_name}',
version_code: '#{version_code}',
json_key: '#{json_key_path}',
destination: '#{destination}'
)
end").runner.execute(:test)
}.to raise_error(FastlaneCore::Interface::FastlaneError, expected_error)
end
end
context 'when a `certificate_sha256_hash` is provided' do
it 'finds a matching APK and downloads it' do
stub_client_list({ cert_sha_1 => download_id_1, cert_sha_2 => download_id_2 })
expected_ref = Supply::GeneratedUniversalApk.new(package_name, version_code, cert_sha_2, download_id_2)
expect(FileUtils).to receive(:mkdir_p).with('/tmp/universal-apk')
expect(client_stub).to receive(:download_generated_universal_apk)
.with(generated_universal_apk: expected_ref, destination: destination)
result = Fastlane::FastFile.new.parse("lane :test do
download_universal_apk_from_google_play(
package_name: '#{package_name}',
version_code: '#{version_code}',
json_key: '#{json_key_path}',
destination: '#{destination}',
certificate_sha256_hash: '#{cert_sha_2}'
)
end").runner.execute(:test)
expect(result).to eq(destination)
end
it 'errors if it does not find any matching APK' do
stub_client_list({ cert_sha_1 => download_id_1, cert_sha_2 => download_id_2 })
expected_error = <<~ERROR
None of the Universal APK(s) found for this version code matched the `certificate_sha256_hash` of `#{cert_sha_not_found}`.
We found 2 Generated Universal APK(s), but with a different `certificate_sha256_hash`:
- #{cert_sha_1}
- #{cert_sha_2}
ERROR
expect {
Fastlane::FastFile.new.parse("lane :test do
download_universal_apk_from_google_play(
package_name: '#{package_name}',
version_code: '#{version_code}',
json_key: '#{json_key_path}',
destination: '#{destination}',
certificate_sha256_hash: '#{cert_sha_not_found}'
)
end").runner.execute(:test)
}.to raise_error(FastlaneCore::Interface::FastlaneError, expected_error)
end
end
context 'when invalid input parameters are provided' do
it 'reports an error if the destination is not a path to an apk file' do
expected_error = "The 'destination' must be a file path with the `.apk` file extension"
expect {
Fastlane::FastFile.new.parse("lane :test do
download_universal_apk_from_google_play(
package_name: '#{package_name}',
version_code: '#{version_code}',
json_key: '#{json_key_path}',
destination: '/tmp/somedir/'
)
end").runner.execute(:test)
}.to raise_error(FastlaneCore::Interface::FastlaneError, expected_error)
end
it 'reports an error if the cert sha is not in the right format' do
expected_error = "When provided, the certificate sha256 must be in the 'xx:xx:xx:โฆ:xx' (32 hex bytes separated by colons) format"
expect {
Fastlane::FastFile.new.parse("lane :test do
download_universal_apk_from_google_play(
package_name: '#{package_name}',
version_code: '#{version_code}',
json_key: '#{json_key_path}',
destination: '#{destination}',
certificate_sha256_hash: '#{cert_sha_invalid_format}'
)
end").runner.execute(:test)
}.to raise_error(FastlaneCore::Interface::FastlaneError, expected_error)
end
it 'reports an error if the cert sha is not of the right length' do
expected_error = "When provided, the certificate sha256 must be in the 'xx:xx:xx:โฆ:xx' (32 hex bytes separated by colons) format"
expect {
Fastlane::FastFile.new.parse("lane :test do
download_universal_apk_from_google_play(
package_name: '#{package_name}',
version_code: '#{version_code}',
json_key: '#{json_key_path}',
destination: '#{destination}',
certificate_sha256_hash: '#{cert_sha_too_short}'
)
end").runner.execute(:test)
}.to raise_error(FastlaneCore::Interface::FastlaneError, expected_error)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/backup_xcarchive_spec.rb | fastlane/spec/actions_specs/backup_xcarchive_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Backup xcarchive Integration" do
let(:tmp_path) { Dir.mktmpdir }
let(:source_path) { "#{tmp_path}/fastlane" }
let(:destination_path) { "#{source_path}/dest" }
let(:xcarchive_file) { "fake.xcarchive" }
let(:zip_file) { "fake.xcarchive.zip" }
let(:source_xcarchive_path) { "#{source_path}/#{xcarchive_file}" }
let(:file_content) { Time.now.to_s }
context "plain backup" do
before :each do
FileUtils.mkdir_p(source_path)
FileUtils.mkdir_p(destination_path)
File.write(File.join(source_path, xcarchive_file), file_content)
end
it "copy xcarchive to destination" do
result = Fastlane::FastFile.new.parse("lane :test do
backup_xcarchive(
versioned: false,
xcarchive: '#{source_xcarchive_path}',
destination: '#{destination_path}',
zip: false)
end").runner.execute(:test)
expect(File.exist?(File.join(destination_path, xcarchive_file))).to eq(true)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BACKUP_XCARCHIVE_FILE]).to eq(File.join(destination_path, xcarchive_file))
end
after :each do
File.delete(File.join(source_path, xcarchive_file))
File.delete(File.join(destination_path, xcarchive_file))
end
end
context "zipped backup" do
before :each do
FileUtils.mkdir_p(source_path)
FileUtils.mkdir_p(destination_path)
File.write(File.join(source_path, xcarchive_file), file_content)
File.write(File.join(tmp_path, zip_file), file_content)
expect(Dir).to receive(:mktmpdir).with("backup_xcarchive").and_yield(tmp_path)
end
it "make and copy zip to destination" do
result = Fastlane::FastFile.new.parse("lane :test do
backup_xcarchive(
versioned: false,
xcarchive: '#{source_xcarchive_path}',
destination: '#{destination_path}',
zip: true
)
end").runner.execute(:test)
expect(File.exist?(File.join(destination_path, zip_file))).to eq(true)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BACKUP_XCARCHIVE_FILE]).to eq(File.join(destination_path, zip_file))
end
after :each do
File.delete(File.join(source_path, xcarchive_file))
File.delete(File.join(destination_path, zip_file))
end
end
context "zipped backup with custom filename" do
let(:custom_zip_filename) { "App_1.0.0" }
let(:zip_file) { "#{custom_zip_filename}.xcarchive.zip" }
before :each do
FileUtils.mkdir_p(source_path)
FileUtils.mkdir_p(destination_path)
File.write(File.join(source_path, xcarchive_file), file_content)
File.write(File.join(tmp_path, zip_file), file_content)
expect(Dir).to receive(:mktmpdir).with("backup_xcarchive").and_yield(tmp_path)
end
it "make zip with custom filename and copy to destination" do
allow(Fastlane::Actions).to receive(:sh).with("cd \"#{source_path}\" && zip -r -X -y \"#{tmp_path}/#{custom_zip_filename}.xcarchive.zip\" \"#{xcarchive_file}\" > /dev/null").and_return("")
result = Fastlane::FastFile.new.parse("lane :test do
backup_xcarchive(
versioned: false,
xcarchive: '#{source_xcarchive_path}',
destination: '#{destination_path}',
zip: true,
zip_filename: '#{custom_zip_filename}'
)
end").runner.execute(:test)
end
after :each do
File.delete(File.join(source_path, xcarchive_file))
File.delete(File.join(destination_path, zip_file))
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/min_fastlane_version_spec.rb | fastlane/spec/actions_specs/min_fastlane_version_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "min_fastlane_version action" do
it "works as expected" do
Fastlane::FastFile.new.parse("lane :test do
min_fastlane_version '0.1'
end").runner.execute(:test)
end
it "raises an exception if it's an old version" do
expect do
stub_const('ENV', { 'BUNDLE_BIN_PATH' => '/fake/elsewhere' })
expect(FastlaneCore::Changelog).to receive(:show_changes).with("fastlane", Fastlane::VERSION, update_gem_command: "bundle update fastlane")
Fastlane::FastFile.new.parse("lane :test do
min_fastlane_version '9999'
end").runner.execute(:test)
end.to raise_error(/The Fastfile requires a fastlane version of >= 9999./)
end
it "raises an exception if it's an old version in a non-bundler environment" do
expect do
# We have to clean ENV to be sure that Bundler environment is not defined.
stub_const('ENV', {})
expect(FastlaneCore::Changelog).to receive(:show_changes).with("fastlane", Fastlane::VERSION, update_gem_command: "gem install fastlane")
Fastlane::FastFile.new.parse("lane :test do
min_fastlane_version '9999'
end").runner.execute(:test)
end.to raise_error("The Fastfile requires a fastlane version of >= 9999. You are on #{Fastlane::VERSION}.")
end
it "raises an exception if it's an old version in a bundler environment" do
expect do
expect(FastlaneCore::Changelog).to receive(:show_changes).with("fastlane", Fastlane::VERSION, update_gem_command: "bundle update fastlane")
# Let's define BUNDLE_BIN_PATH in ENV to simulate a bundler environment
stub_const('ENV', { 'BUNDLE_BIN_PATH' => '/fake/elsewhere' })
Fastlane::FastFile.new.parse("lane :test do
min_fastlane_version '9999'
end").runner.execute(:test)
end.to raise_error("The Fastfile requires a fastlane version of >= 9999. You are on #{Fastlane::VERSION}.")
end
it "raises an error if no fastlane version is given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
min_fastlane_version
end").runner.execute(:test)
end.to raise_error("Please pass minimum fastlane version as parameter to min_fastlane_version")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/import_from_git_spec.rb | fastlane/spec/actions_specs/import_from_git_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "import_from_git" do
it "raises an exception when no path is given" do
expect do
Fastlane::FastFile.new.parse("lane :test do
import_from_git
end").runner.execute(:test)
end.to raise_error("Please pass a path to the `import_from_git` action")
end
# (2.32.0)
# (2.32.0).win.1
# (3)
def git_version
output = `git --version`
m = output.match(/(?<version>\d+(?:\.\d+)*)/)
raise "Couldn't parse git version in '#{output}'" unless m
m['version']
end
source_directory_path = nil
cache_directory_path = nil
missing_cache_directory_path = nil
before :all do
# This is needed for tag searching that `import_from_git` needs.
ENV["FORCE_SH_DURING_TESTS"] = "1"
source_directory_path = Dir.mktmpdir("fl_spec_import_from_git_source")
Dir.chdir(source_directory_path) do
if Gem::Version.new(git_version) >= Gem::Version.new("2.28.0")
`git init -b master`
else
`git init`
end
`git config user.email "you@example.com"`
`git config user.name "Your Name"`
`mkdir fastlane`
File.write('fastlane/Fastfile', <<-FASTFILE)
lane :works do
UI.important('Works since v1')
end
FASTFILE
`git add .`
`git commit --message "Version 1"`
`git tag "1" --message "Version 1"`
File.write('fastlane/FastfileExtra', <<-FASTFILE)
lane :works_extra do
UI.important('Works from extra since v2')
end
FASTFILE
`git add .`
`git commit --message "Version 2"`
`git tag "2" --message "Version 2"`
File.write('FastfileRoot', <<-FASTFILE)
lane :works_root do
UI.important('Works from root since v3')
end
FASTFILE
`git add .`
`git commit --message "Version 3"`
`git tag "3" --message "Version 3"`
`mkdir fastlane/actions`
FileUtils.mkdir_p('fastlane/actions')
File.write('fastlane/actions/work_action.rb', <<-FASTFILE)
module Fastlane
module Actions
class WorkActionAction < Action
def self.run(params)
UI.important('Works from action since v4')
end
def self.is_supported?(platform)
true
end
end
end
end
FASTFILE
`git add .`
`git commit --message "Version 4"`
`git tag "4" --message "Version 4"`
`git checkout tags/2 -b version-2.1 2>&1`
File.write('fastlane/Fastfile', <<-FASTFILE)
lane :works do
UI.important('Works since v2.1')
end
FASTFILE
`git add .`
`git commit --message "Version 2.1"`
end
cache_directory_path = Dir.mktmpdir("fl_spec_import_from_git_cache")
missing_cache_directory_path = Dir.mktmpdir("fl_spec_import_from_git_missing_cache")
FileUtils.remove_dir(missing_cache_directory_path)
end
let(:caching_message) { "Eligible for caching" }
describe "with caching" do
it "works with version" do
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works since v1')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', version: '1', cache_path: '#{cache_directory_path}')
works
end").runner.execute(:test)
end
it "works with dependencies and version" do
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works from extra since v2')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', dependencies: ['fastlane/FastfileExtra'], version: '2', cache_path: '#{cache_directory_path}')
works_extra
end").runner.execute(:test)
end
it "works with path and version" do
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works from root since v3')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', path: 'FastfileRoot', version: '3', cache_path: '#{cache_directory_path}')
works_root
end").runner.execute(:test)
end
it "works with actions" do
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works from action since v4')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', version: '4', cache_path: '#{cache_directory_path}')
work_action
end").runner.execute(:test)
end
# This is based on the fact that rspec runs the tests in the order
# they're defined in this file, so it tests the fact that importing
# works with an older version after a newer one was previously checked
# out.
it "works with older version" do
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works since v1')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', version: '1', cache_path: '#{cache_directory_path}')
works
end").runner.execute(:test)
end
# Meaning, a `git pull` is performed when the specified tag is not found
# in the local clone.
it "works with new tags" do
Dir.chdir(source_directory_path) do
`git checkout "master" 2>&1`
File.write('fastlane/Fastfile', <<-FASTFILE)
lane :works do
UI.important('Works until v5')
end
FASTFILE
`git add .`
`git commit --message "Version 5"`
`git tag "5" --message "Version 5"`
end
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works until v5')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', branch: 'master', version: '5', cache_path: '#{cache_directory_path}')
works
end").runner.execute(:test)
end
# Actually, `git checkout` makes sure of this, but I think it's ok to
# keep this test, in case we change the implementation.
it "works with nonexistent paths" do
expect(UI).to receive(:important).with('Works since v1')
expect do
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', version: '3', cache_path: '#{missing_cache_directory_path}')
works
end").runner.execute(:test)
end.not_to raise_error
end
it "works with branch" do
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works since v2.1')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', branch: 'version-2.1', cache_path: '#{cache_directory_path}')
works
end").runner.execute(:test)
end
# Meaning, `git fetch` and `git rebase` are performed when caching is eligible
# and the version isn't specified.
it "works with updated branch" do
Dir.chdir(source_directory_path) do
`git checkout "version-2.1" 2>&1`
File.write('fastlane/Fastfile', <<-FASTFILE)
lane :works do
UI.important('Works until v5')
end
FASTFILE
`git add .`
`git commit --message "Version 5"`
end
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works until v5')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', branch: 'version-2.1', cache_path: '#{cache_directory_path}')
works
end").runner.execute(:test)
end
# Respects the specified version even if the branch is specified.
it "works with new tags and branch" do
Dir.chdir(source_directory_path) do
`git checkout "master" 2>&1`
File.write('fastlane/Fastfile', <<-FASTFILE)
lane :works do
UI.important('Works until v6')
end
FASTFILE
`git add .`
`git commit --message "Version 6"`
`git tag "6" --message "Version 6"`
end
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works until v6')
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', branch: 'version-2.1', version: '6', cache_path: '#{cache_directory_path}')
works
end").runner.execute(:test)
end
it "doesn't superfluously execute checkout" do
allow(UI).to receive(:message)
expect(UI).to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works until v6')
allow(Fastlane::Actions).to receive(:sh).and_call_original
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', version: '6', cache_path: '#{cache_directory_path}')
works
end").runner.execute(:test)
expect(Fastlane::Actions).not_to have_received(:sh).with(/git checkout/)
end
end
describe "without caching" do
it "works when no cache is provided" do
allow(UI).to receive(:message)
expect(UI).not_to receive(:message).with(caching_message)
expect(UI).to receive(:important).with('Works until v6')
allow(Fastlane::Actions).to receive(:sh).and_call_original
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', cache_path: nil)
works
end").runner.execute(:test)
end
end
it "works with one HTTP header" do
header = 'Authorization: Basic my_base_64_key'
allow(Fastlane::Actions).to receive(:sh).and_call_original
expect(Fastlane::Actions).to receive(:sh).with(any_args, '--config', "http.extraHeader=#{header}")
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', git_extra_headers: ['#{header}'])
end").runner.execute(:test)
end
it "works with two HTTP headers" do
first_header = 'Authorization: Basic my_base_64_key'
second_header = 'Cache-Control: no-cache'
allow(Fastlane::Actions).to receive(:sh).and_call_original
expect(Fastlane::Actions).to receive(:sh).with(any_args, '--config', "http.extraHeader=#{first_header}", '--config', "http.extraHeader=#{second_header}")
Fastlane::FastFile.new.parse("lane :test do
import_from_git(url: '#{source_directory_path}', git_extra_headers: ['#{first_header}', '#{second_header}'])
end").runner.execute(:test)
end
after :all do
ENV.delete("FORCE_SH_DURING_TESTS")
FileUtils.remove_dir(source_directory_path)
FileUtils.remove_dir(missing_cache_directory_path)
FileUtils.remove_dir(cache_directory_path)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/update_app_identifier_spec.rb | fastlane/spec/actions_specs/update_app_identifier_spec.rb | require 'xcodeproj'
include(Xcodeproj)
describe Fastlane do
describe Fastlane::FastFile do
describe "Update App Identifier Integration" do
# Variables
let(:test_path) { "/tmp/fastlane/tests/fastlane" }
let(:fixtures_path) { "./fastlane/spec/fixtures/xcodeproj" }
let(:proj_file) { "bundle.xcodeproj" }
let(:identifier_key) { 'PRODUCT_BUNDLE_IDENTIFIER' }
# Action parameters
let(:xcodeproj) { File.join(test_path, proj_file) }
let(:plist_path) { "Info.plist" }
let(:plist_path_with_srcroot) { "$(SRCROOT)/Info.plist" }
let(:app_identifier) { "com.test.plist" }
# Is there a better place for an helper function?
# Create an Info.plist file with a supplied bundle_identifier parameter
def create_plist_with_identifier(bundle_identifier)
File.write(File.join(test_path, plist_path), "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"><plist version=\"1.0\"><dict><key>CFBundleIdentifier</key><string>#{bundle_identifier}</string></dict></plist>")
end
before do
# Create test folder
FileUtils.mkdir_p(test_path)
source = File.join(fixtures_path, proj_file)
destination = File.join(test_path, proj_file)
# Copy .xcodeproj fixture, as it will be modified during the test
FileUtils.cp_r(source, destination)
end
if FastlaneCore::Helper.mac?
it "updates the info plist when product bundle identifier not in use" do
plist = create_plist_with_identifier('tools.fastlane.example')
Fastlane::FastFile.new.parse("lane :test do
update_app_identifier ({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}'
})
end").runner.execute(:test)
result = File.read(File.join(test_path, plist_path))
expect(result).to include("<string>#{app_identifier}</string>")
end
it "updates the xcode project when product bundle identifier in use" do
stub_project = 'stub project'
stub_configuration_1 = 'stub config 1'
stub_configuration_2 = 'stub config 2'
stub_object = ['object']
stub_settings_1 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.else']
stub_settings_1['INFOPLIST_FILE'] = plist_path
stub_settings_2 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.entirely.else']
stub_settings_2['INFOPLIST_FILE'] = "Other-Info.plist"
expect(Xcodeproj::Project).to receive(:open).with('/tmp/fastlane/tests/fastlane/bundle.xcodeproj').and_return(stub_project)
expect(stub_project).to receive(:objects).and_return(stub_object)
expect(stub_object).to receive(:select).and_return([stub_configuration_1, stub_configuration_2])
expect(stub_configuration_1).to receive(:build_settings).twice.and_return(stub_settings_1)
expect(stub_configuration_2).to receive(:build_settings).and_return(stub_settings_2)
expect(stub_project).to receive(:save)
create_plist_with_identifier("$(#{identifier_key})")
Fastlane::FastFile.new.parse("lane :test do
update_app_identifier({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}'
})
end").runner.execute(:test)
expect(stub_settings_1['PRODUCT_BUNDLE_IDENTIFIER']).to eq('com.test.plist')
expect(stub_settings_2['PRODUCT_BUNDLE_IDENTIFIER']).to_not(eq('com.test.plist'))
end
it "updates the xcode project when product bundle identifier in use and it uses curly brackets notation" do
stub_project = 'stub project'
stub_configuration_1 = 'stub config 1'
stub_configuration_2 = 'stub config 2'
stub_object = ['object']
stub_settings_1 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.else']
stub_settings_1['INFOPLIST_FILE'] = plist_path
stub_settings_2 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.entirely.else']
stub_settings_2['INFOPLIST_FILE'] = "Other-Info.plist"
expect(Xcodeproj::Project).to receive(:open).with('/tmp/fastlane/tests/fastlane/bundle.xcodeproj').and_return(stub_project)
expect(stub_project).to receive(:objects).and_return(stub_object)
expect(stub_object).to receive(:select).and_return([stub_configuration_1, stub_configuration_2])
expect(stub_configuration_1).to receive(:build_settings).twice.and_return(stub_settings_1)
expect(stub_configuration_2).to receive(:build_settings).and_return(stub_settings_2)
expect(stub_project).to receive(:save)
create_plist_with_identifier("${#{identifier_key}}")
Fastlane::FastFile.new.parse("lane :test do
update_app_identifier({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}'
})
end").runner.execute(:test)
expect(stub_settings_1['PRODUCT_BUNDLE_IDENTIFIER']).to eq('com.test.plist')
expect(stub_settings_2['PRODUCT_BUNDLE_IDENTIFIER']).to_not(eq('com.test.plist'))
end
it "updates the xcode project when info plist path contains $(SRCROOT)" do
stub_project = 'stub project'
stub_configuration_1 = 'stub config 1'
stub_configuration_2 = 'stub config 2'
stub_object = ['object']
stub_settings_1 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.else']
stub_settings_1['INFOPLIST_FILE'] = plist_path_with_srcroot
stub_settings_2 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.entirely.else']
stub_settings_2['INFOPLIST_FILE'] = "Other-Info.plist"
expect(Xcodeproj::Project).to receive(:open).with('/tmp/fastlane/tests/fastlane/bundle.xcodeproj').and_return(stub_project)
expect(stub_project).to receive(:objects).and_return(stub_object)
expect(stub_object).to receive(:select).and_return([stub_configuration_1, stub_configuration_2])
expect(stub_configuration_1).to receive(:build_settings).twice.and_return(stub_settings_1)
expect(stub_configuration_2).to receive(:build_settings).and_return(stub_settings_2)
expect(stub_project).to receive(:save)
create_plist_with_identifier("$(#{identifier_key})")
Fastlane::FastFile.new.parse("lane :test do
update_app_identifier({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path_with_srcroot}',
app_identifier: '#{app_identifier}'
})
end").runner.execute(:test)
expect(stub_settings_1['PRODUCT_BUNDLE_IDENTIFIER']).to eq('com.test.plist')
expect(stub_settings_2['PRODUCT_BUNDLE_IDENTIFIER']).to_not(eq('com.test.plist'))
end
it "updates the xcode project when info plist path not contains $(SRCROOT)" do
stub_project = 'stub project'
stub_configuration_1 = 'stub config 1'
stub_configuration_2 = 'stub config 2'
stub_object = ['object']
stub_settings_1 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.else']
stub_settings_1['INFOPLIST_FILE'] = plist_path_with_srcroot
stub_settings_2 = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.entirely.else']
stub_settings_2['INFOPLIST_FILE'] = "Other-Info.plist"
expect(Xcodeproj::Project).to receive(:open).with('/tmp/fastlane/tests/fastlane/bundle.xcodeproj').and_return(stub_project)
expect(stub_project).to receive(:objects).and_return(stub_object)
expect(stub_object).to receive(:select).and_return([stub_configuration_1, stub_configuration_2])
expect(stub_configuration_1).to receive(:build_settings).twice.and_return(stub_settings_1)
expect(stub_configuration_2).to receive(:build_settings).and_return(stub_settings_2)
expect(stub_project).to receive(:save)
create_plist_with_identifier("$(#{identifier_key})")
Fastlane::FastFile.new.parse("lane :test do
update_app_identifier({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}'
})
end").runner.execute(:test)
expect(stub_settings_1['PRODUCT_BUNDLE_IDENTIFIER']).to eq('com.test.plist')
expect(stub_settings_2['PRODUCT_BUNDLE_IDENTIFIER']).to_not(eq('com.test.plist'))
end
it "should raise an exception when PRODUCT_BUNDLE_IDENTIFIER in info plist but project doesn't use this info plist" do
stub_project = 'stub project'
stub_configuration = 'stub config'
stub_object = ['object']
stub_settings = Hash['PRODUCT_BUNDLE_IDENTIFIER', 'com.something.else']
expect(Xcodeproj::Project).to receive(:open).with('/tmp/fastlane/tests/fastlane/bundle.xcodeproj').and_return(stub_project)
expect(stub_project).to receive(:objects).and_return(stub_object)
expect(stub_object).to receive(:select).and_return([stub_configuration])
expect(stub_configuration).to receive(:build_settings).and_return(stub_settings)
create_plist_with_identifier("$(#{identifier_key})")
expect do
Fastlane::FastFile.new.parse("lane :test do
update_app_identifier({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}'
})
end").runner.execute(:test)
end.to raise_error("Xcodeproj doesn't have configuration with info plist #{plist_path}.")
end
it "should raise an exception when PRODUCT_BUNDLE_IDENTIFIER in info plist but not project" do
stub_project = 'stub project'
stub_configuration = 'stub config'
stub_object = ['object']
expect(Xcodeproj::Project).to receive(:open).with('/tmp/fastlane/tests/fastlane/bundle.xcodeproj').and_return(stub_project)
expect(stub_project).to receive(:objects).and_return(stub_object)
expect(stub_object).to receive(:select).and_return([])
create_plist_with_identifier("$(#{identifier_key})")
expect do
Fastlane::FastFile.new.parse("lane :test do
update_app_identifier({
xcodeproj: '#{xcodeproj}',
plist_path: '#{plist_path}',
app_identifier: '#{app_identifier}'
})
end").runner.execute(:test)
end.to raise_error("Info plist uses #{identifier_key}, but xcodeproj does not")
end
end
after do
# Clean up files
FileUtils.rm_r(test_path)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/download_dsyms_spec.rb | fastlane/spec/actions_specs/download_dsyms_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "download_dsyms" do
# 1 app, 2 trains/versions, 2 builds each
let(:app) { double('app') }
let(:build_resp) { double('build_resp') }
let(:tunes_client) { double('tunes_client') }
let(:version) { double('version') }
let(:live_version) { double('live_version') }
let(:build1) { double('build1') }
let(:build2) { double('build2') }
let(:build3) { double('build3') }
let(:build4) { double('build4') }
let(:build5) { double('build5') }
let(:build6) { double('build6') }
let(:build_bundle) { double('build_bundle') }
let(:not_processed_build_bundle) { double('not_processed_build_bundle') }
let(:no_symbols_build_bundle) { double('no_symbols_build_bundle') }
let(:not_processed_build) { double('not_processed_build') }
let(:no_symbols_build) { double('no_symbols_build') }
let(:download_url) { 'https://example.com/myapp-dsym' }
before do
allow(Spaceship::Tunes).to receive(:client).and_return(tunes_client)
# login
allow(Spaceship::ConnectAPI).to receive(:login)
allow(Spaceship::ConnectAPI::App). to receive(:find).and_return(app)
allow(app).to receive(:id).and_return("id")
allow(app).to receive(:bundle_id).and_return('tools.fastlane.myapp')
# builds
allow(Spaceship::ConnectAPI).to receive(:get_builds).and_return(build_resp)
allow(build_resp).to receive(:all_pages).and_return([build_resp])
allow(build1).to receive(:build_bundles).and_return([build_bundle])
allow(build2).to receive(:build_bundles).and_return([build_bundle])
allow(build3).to receive(:build_bundles).and_return([build_bundle])
allow(build4).to receive(:build_bundles).and_return([build_bundle])
allow(build5).to receive(:build_bundles).and_return([build_bundle])
allow(build6).to receive(:build_bundles).and_return([build_bundle])
allow(not_processed_build).to receive(:build_bundles).and_return([not_processed_build_bundle])
allow(no_symbols_build).to receive(:build_bundles).and_return([no_symbols_build_bundle])
allow(build_bundle).to receive(:dsym_url).and_return(download_url)
allow(build_bundle).to receive(:includes_symbols).and_return(true)
allow(not_processed_build_bundle).to receive(:dsym_url).and_return(nil)
allow(not_processed_build_bundle).to receive(:includes_symbols).and_return(true)
allow(no_symbols_build_bundle).to receive(:dsym_url).and_return(nil)
allow(no_symbols_build_bundle).to receive(:includes_symbols).and_return(false)
allow(Fastlane::Actions::DownloadDsymsAction).to receive(:download)
end
# before do
# # login
# allow(Spaceship::Tunes).to receive(:login)
# allow(Spaceship::Tunes).to receive(:select_team)
# allow(Spaceship::Application).to receive(:find).and_return(app)
# # trains
# allow(app).to receive(:tunes_all_build_trains).and_return([train, train2, train3])
# # build_detail + download
# allow(build_detail).to receive(:dsym_url).and_return(download_url)
# allow(empty_build_detail).to receive(:dsym_url).and_return(nil)
# allow(app).to receive(:bundle_id).and_return('tools.fastlane.myapp')
# allow(train).to receive(:version_string).and_return('1.0.0')
# allow(train2).to receive(:version_string).and_return('1.7.0')
# allow(train3).to receive(:version_string).and_return('2.0.0')
# allow(build).to receive(:build_version).and_return('1')
# allow(build2).to receive(:build_version).and_return('2')
# allow(build3).to receive(:build_version).and_return('3')
# allow(build4).to receive(:build_version).and_return('4')
# allow(empty_build).to receive(:build_version).and_return('5')
# allow(Fastlane::Actions::DownloadDsymsAction).to receive(:download)
# end
context 'with no special options' do
it 'downloads all dsyms of all builds in all trains' do
expect(build_resp).to receive(:all_pages_each).and_yield(build1)
.and_yield(build2)
.and_yield(build3)
.and_yield(build4)
.and_yield(build5)
.and_yield(build6)
[[build1, '1.0.0', '1', '2020-09-12T10:00:00+01:00'],
[build2, '1.0.0', '2', '2020-09-12T11:00:00+01:00'],
[build3, '1.7.0', '4', '2020-09-12T12:00:00+01:00'],
[build4, '2.0.0', '1', '2020-09-12T13:00:00+01:00'],
[build5, '2.0.0', '2', '2020-09-12T14:00:00+01:00'],
[build6, '2.0.0', '5', '2020-09-12T15:00:00+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
end
expect(Fastlane::Actions::DownloadDsymsAction).not_to(receive(:download))
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp')
end").runner.execute(:test)
end
end
context 'with wait_for_dsym_processing' do
it 'downloads all dsyms of all builds in all trains' do
expect(build_resp).to receive(:all_pages_each).and_yield(not_processed_build)
# Returns not processed build (no dsym url)
build = not_processed_build
build_id = 1
version = '2.0.0'
build_number = '5'
uploaded_date = '2020-09-12T15:00:00+01:00'
expect(build).to receive(:id).and_return(build_id)
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
# Refetches build info
expect(Spaceship::ConnectAPI::Build).to receive(:get).with(build_id: build_id).and_return(build1)
build = build1
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
expect(Fastlane::Actions::DownloadDsymsAction).not_to(receive(:download))
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp', wait_for_dsym_processing: true)
end").runner.execute(:test)
end
end
context 'with version with leading zero' do
it 'downloads all dsyms of all builds in train 1.07.0' do
expect(build_resp).to receive(:all_pages_each).and_yield(build1)
[[build1, '1.07.0', '3', '2020-09-12T14:10:30+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
end
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp', version: '1.07.0')
end").runner.execute(:test)
end
end
context 'when build_number is an integer' do
it 'downloads the correct dsyms' do
expect(build_resp).to receive(:all_pages_each).and_yield(build1)
[[build1, '2.0.0', '2', '2020-09-12T14:10:30+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
end
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp', version: '2.0.0', build_number: 2)
end").runner.execute(:test)
end
end
context 'when version is latest' do
it 'downloads only dsyms of latest build in latest train' do
expect(Spaceship::ConnectAPI).to receive(:get_builds).and_return([build2, build1])
expect(build_resp).to receive(:all_pages_each).and_yield(build1)
.and_yield(build2)
[[build1, '2.0.0', '2', '2020-09-12T10:00:00+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
end
[[build2, '2.0.0', '3', '2020-09-12T11:00:00+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version).twice
expect(build).to receive(:version).and_return(build_number).exactly(2).times
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
end
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp', version: 'latest')
end").runner.execute(:test)
end
end
context 'when version is live' do
it 'downloads only dsyms of live build' do
expect(app).to receive(:get_live_app_store_version).and_return(version)
expect(version).to receive(:version_string).and_return('1.0.0')
version_build = double('version_build')
expect(version_build).to receive(:version).and_return('42')
expect(version).to receive(:build).and_return(version_build)
expect(build_resp).to receive(:all_pages_each).and_yield(build1)
.and_yield(build2)
[[build1, '1.0.0', '33', '2020-09-12T14:10:30+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
end
[[build2, '1.0.0', '42', '2020-09-12T14:10:30+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
end
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp', version: 'live')
end").runner.execute(:test)
end
end
context 'when min_version is set' do
it 'downloads only dsyms of trains newer than or equal min_version' do
expect(build_resp).to receive(:all_pages_each).and_yield(build1)
.and_yield(build2)
[[build1, '1.0.0', '33', '2020-09-12T14:10:30+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
end
[[build2, '2.0.0', '42', '2020-09-12T14:10:30+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
end
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp', min_version: '2.0.0')
end").runner.execute(:test)
end
end
context 'with after_uploaded_date' do
it 'downloads dsyms with more recent uploaded_date' do
expect(build_resp).to receive(:all_pages_each).and_yield(build1)
.and_yield(build2)
.and_yield(build3)
.and_yield(build4)
.and_yield(build5)
.and_yield(build6)
# after after_uploaded_date
[[build1, '2.0.0', '5', '2020-09-12T15:00:00+01:00'],
[build2, '2.0.0', '2', '2020-09-12T14:00:00+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
expect(Fastlane::Actions::DownloadDsymsAction).to receive(:download).with(download_url, build, app, nil)
end
# on after_uploaded_date
[[build3, '2.0.0', '1', '2020-09-12T13:00:00+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).to receive(:app_version).and_return(version)
expect(build).to receive(:version).and_return(build_number)
expect(build).to receive(:uploaded_date).and_return(uploaded_date)
end
# before after_uploaded_date
[[build4, '1.7.0', '4', '2020-09-12T12:00:00+01:00'],
[build5, '1.0.0', '2', '2020-09-12T11:00:00+01:00'],
[build6, '1.0.0', '1', '2020-09-12T10:00:00+01:00']].each do |build, version, build_number, uploaded_date|
expect(build).not_to(receive(:app_version))
expect(build).not_to(receive(:version))
expect(build).not_to(receive(:uploaded_date))
end
expect(Fastlane::Actions::DownloadDsymsAction).not_to(receive(:download))
Fastlane::FastFile.new.parse("lane :test do
download_dsyms(username: 'user@fastlane.tools', app_identifier: 'tools.fastlane.myapp', after_uploaded_date: '2020-09-12T13:00:00+01:00')
end").runner.execute(:test)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/oclint_spec.rb | fastlane/spec/actions_specs/oclint_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "OCLint Integration" do
before :each do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
end
it "raises an exception when the default compile_commands.json is not present" do
expect do
Fastlane::FastFile.new.parse("lane :test do
oclint
end").runner.execute(:test)
end.to raise_error("Could not find json compilation database at path 'compile_commands.json'")
end
it "works given the path to compile_commands.json" do
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint/compile_commands.json'
)
end").runner.execute(:test)
expect(result).to match(%r{cd .* && oclint -report-type=html -o=oclint_report.html -p ./fastlane/spec/fixtures/oclint \".*})
end
it "works given a path to the directory containing compile_commands.json" do
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint'
)
end").runner.execute(:test)
expect(result).to match(%r{cd .* && oclint -report-type=html -o=oclint_report.html -p ./fastlane/spec/fixtures/oclint \".*})
end
it "works with all parameters" do
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint/compile_commands.json',
select_regex: /.*/,
exclude_regex: /Test.m/,
report_type: 'pmd',
report_path: 'report_path.xml',
max_priority_1: 10,
max_priority_2: 20,
max_priority_3: 30,
thresholds: ['LONG_LINE=200', 'LONG_METHOD=200'],
enable_rules: ['DoubleNegative', 'DeadCode'],
disable_rules: ['GotoStatement', 'ShortVariableName'],
list_enabled_rules: true,
enable_clang_static_analyzer: true,
enable_global_analysis: true,
allow_duplicated_violations: true,
extra_arg: '-Wno-everything'
)
end").runner.execute(:test)
expect(result).to include(' oclint -report-type=pmd -o=report_path.xml ')
expect(result).to include(' -max-priority-1=10 ')
expect(result).to include(' -max-priority-2=20 ')
expect(result).to include(' -max-priority-3=30 ')
expect(result).to include(' -rc=LONG_LINE=200 -rc=LONG_METHOD=200 ')
expect(result).to include(' -rule DoubleNegative -rule DeadCode ')
expect(result).to include(' -disable-rule GotoStatement -disable-rule ShortVariableName ')
expect(result).to include(' -list-enabled-rules ')
expect(result).to include(' -enable-clang-static-analyzer ')
expect(result).to include(' -enable-global-analysis ')
expect(result).to include(' -allow-duplicated-violations ')
expect(result).to include(' -extra-arg=-Wno-everything ')
end
it "works with single quote in rule name" do
rule = "CoveredSwitchStatementsDon'tNeedDefault"
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint/compile_commands.json',
enable_rules: [\"#{rule}\"],
disable_rules: [\"#{rule}\"]
)
end").runner.execute(:test)
expect(result).to include(" -rule #{rule.shellescape} ")
expect(result).to include(" -disable-rule #{rule.shellescape} ")
end
it "works with select regex" do
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint/compile_commands.json',
select_regex: /AppDelegate/
)
end").runner.execute(:test)
expect(result).to include('"fastlane/spec/fixtures/oclint/src/AppDelegate.m"')
end
it "works with select regex when regex is string" do
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint/compile_commands.json',
select_regex: \"\/AppDelegate\"
)
end").runner.execute(:test)
expect(result).to include('"fastlane/spec/fixtures/oclint/src/AppDelegate.m"')
end
it "works with exclude regex" do
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint/compile_commands.json',
exclude_regex: /Test/
)
end").runner.execute(:test)
expect(result).not_to(include('"fastlane/spec/fixtures/oclint/src/Test.m"'))
end
it "works with both select and exclude regex" do
result = Fastlane::FastFile.new.parse("lane :test do
oclint(
compile_commands: './fastlane/spec/fixtures/oclint/compile_commands.json',
select_regex: /\.*m/,
exclude_regex: /Test/
)
end").runner.execute(:test)
expect(result).to include('"fastlane/spec/fixtures/oclint/src/AppDelegate.m"')
expect(result).not_to(include('Test'))
end
context 'with valid path to compile_commands.json' do
context 'with no path to oclint' do
let(:result) do
Fastlane::FastFile.new.parse('lane :test do
oclint( compile_commands: "./fastlane/spec/fixtures/oclint/compile_commands.json" )
end').runner.execute(:test)
end
let(:command) { "cd #{File.expand_path('.').shellescape} && oclint -report-type=html -o=oclint_report.html" }
it 'uses system wide oclint' do
expect(result).to include(command)
end
end
context 'with given path to oclint' do
let(:result) do
Fastlane::FastFile.new.parse('lane :test do
oclint(
compile_commands: "./fastlane/spec/fixtures/oclint/compile_commands.json",
oclint_path: "test/bin/oclint"
)
end').runner.execute(:test)
end
let(:command) { "cd #{File.expand_path('.').shellescape} && test/bin/oclint -report-type=html -o=oclint_report.html" }
it 'uses oclint provided' do
expect(result).to include(command)
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/actions_specs/clean_cocoapods_cache_spec.rb | fastlane/spec/actions_specs/clean_cocoapods_cache_spec.rb | describe Fastlane do
describe Fastlane::FastFile do
describe "Clean Cocoapods Cache Integration" do
it "default use case" do
result = Fastlane::FastFile.new.parse("lane :test do
clean_cocoapods_cache
end").runner.execute(:test)
expect(result).to eq("pod cache clean --all")
end
it "adds pod name to command" do
result = Fastlane::FastFile.new.parse("lane :test do
clean_cocoapods_cache(
name: 'Name'
)
end").runner.execute(:test)
expect(result).to eq("pod cache clean Name --all")
end
it "raise an exception if name is empty" do
expect do
Fastlane::FastFile.new.parse("lane :test do
clean_cocoapods_cache(
name: ''
)
end").runner.execute(:test)
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/podspec_helper_spec.rb | fastlane/spec/helper/podspec_helper_spec.rb | require "stringio"
describe Fastlane::Actions do
describe "#podspechelper" do
before do
@version_podspec_file = Fastlane::Helper::PodspecHelper.new
end
it "raises an exception when an incorrect path is given" do
expect do
Fastlane::Helper::PodspecHelper.new('invalid_podspec')
end.to raise_error("Could not find podspec file at path 'invalid_podspec'")
end
it "raises an exception when there is no version in podspec" do
expect do
Fastlane::Helper::PodspecHelper.new.parse("")
end.to raise_error("Could not find version in podspec content ''")
end
it "raises an exception when the version is commented-out in podspec" do
test_content = '# s.version = "1.3.2"'
expect do
Fastlane::Helper::PodspecHelper.new.parse(test_content)
end.to raise_error("Could not find version in podspec content '#{test_content}'")
end
context "when semantic version" do
it "returns the current version once parsed" do
test_content = 'spec.version = "1.3.2"'
result = @version_podspec_file.parse(test_content)
expect(result).to eq('1.3.2')
expect(@version_podspec_file.version_value).to eq('1.3.2')
expect(@version_podspec_file.version_match[:major]).to eq('1')
expect(@version_podspec_file.version_match[:minor]).to eq('3')
expect(@version_podspec_file.version_match[:patch]).to eq('2')
end
context "with appendix" do
it "returns the current version once parsed with appendix" do
test_content = 'spec.version = "1.3.2.4"'
result = @version_podspec_file.parse(test_content)
expect(result).to eq('1.3.2.4')
expect(@version_podspec_file.version_value).to eq('1.3.2.4')
expect(@version_podspec_file.version_match[:major]).to eq('1')
expect(@version_podspec_file.version_match[:minor]).to eq('3')
expect(@version_podspec_file.version_match[:patch]).to eq('2')
expect(@version_podspec_file.version_match[:appendix]).to eq('.4')
end
it "returns the current version once parsed with longer appendix" do
test_content = 'spec.version = "1.3.2.4.5"'
result = @version_podspec_file.parse(test_content)
expect(result).to eq('1.3.2.4.5')
expect(@version_podspec_file.version_value).to eq('1.3.2.4.5')
expect(@version_podspec_file.version_match[:major]).to eq('1')
expect(@version_podspec_file.version_match[:minor]).to eq('3')
expect(@version_podspec_file.version_match[:patch]).to eq('2')
expect(@version_podspec_file.version_match[:appendix]).to eq('.4.5')
end
end
it "returns the current version once parsed with prerelease" do
test_content = 'spec.version = "1.3.2-SNAPSHOT"'
result = @version_podspec_file.parse(test_content)
expect(result).to eq('1.3.2-SNAPSHOT')
expect(@version_podspec_file.version_value).to eq('1.3.2-SNAPSHOT')
expect(@version_podspec_file.version_match[:major]).to eq('1')
expect(@version_podspec_file.version_match[:minor]).to eq('3')
expect(@version_podspec_file.version_match[:patch]).to eq('2')
expect(@version_podspec_file.version_match[:prerelease]).to eq('SNAPSHOT')
end
it "returns the current version once parsed with appendix and prerelease" do
test_content = 'spec.version = "1.3.2.4-SNAPSHOT"'
result = @version_podspec_file.parse(test_content)
expect(result).to eq('1.3.2.4-SNAPSHOT')
expect(@version_podspec_file.version_value).to eq('1.3.2.4-SNAPSHOT')
expect(@version_podspec_file.version_match[:major]).to eq('1')
expect(@version_podspec_file.version_match[:minor]).to eq('3')
expect(@version_podspec_file.version_match[:patch]).to eq('2')
expect(@version_podspec_file.version_match[:appendix]).to eq('.4')
expect(@version_podspec_file.version_match[:prerelease]).to eq('SNAPSHOT')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/xcodeproj_helper_spec.rb | fastlane/spec/helper/xcodeproj_helper_spec.rb | require 'fileutils'
require 'tmpdir'
describe Fastlane::Actions do
describe '#xcodeproj_helper' do
PATH = 'Project.xcodeproj'.freeze
SECONDARY_PATH = 'Secondary/Project.xcodeproj'.freeze
COCOAPODS_PATH = 'Pods/Pod.xcodeproj'.freeze
COCOAPODS_FRAMEWORK_EXAMPLE_PATH = 'Pods/Alamofire/Example/iOS Example.xcodeproj'.freeze
CARTHAGE_FRAMEWORK_PATH = 'Carthage/Checkouts/Alamofire/Alamofire.xcodeproj'.freeze
CARTHAGE_FRAMEWORK_EXAMPLE_PATH = 'Carthage/Checkouts/Alamofire/Example iOS Example.xcodeproj'.freeze
let(:dir) { Dir.mktmpdir }
it 'finds one' do
path = File.join(dir, PATH)
FileUtils.mkdir_p(path)
paths = Fastlane::Helper::XcodeprojHelper.find(dir)
expect(paths).to contain_exactly(path)
end
it 'finds multiple nested' do
path = File.join(dir, PATH)
FileUtils.mkdir_p(path)
secondary_path = File.join(dir, SECONDARY_PATH)
FileUtils.mkdir_p(secondary_path)
paths = Fastlane::Helper::XcodeprojHelper.find(dir)
expect(paths).to contain_exactly(path, secondary_path)
end
it 'finds multiple nested, ignoring dependencies' do
path = File.join(dir, PATH)
FileUtils.mkdir_p(path)
secondary_path = File.join(dir, SECONDARY_PATH)
FileUtils.mkdir_p(secondary_path)
FileUtils.mkdir_p(File.join(dir, COCOAPODS_PATH))
FileUtils.mkdir_p(File.join(dir, COCOAPODS_FRAMEWORK_EXAMPLE_PATH))
FileUtils.mkdir_p(File.join(dir, CARTHAGE_FRAMEWORK_PATH))
FileUtils.mkdir_p(File.join(dir, CARTHAGE_FRAMEWORK_EXAMPLE_PATH))
paths = Fastlane::Helper::XcodeprojHelper.find(dir)
expect(paths).to contain_exactly(path, secondary_path)
end
after do
FileUtils.rm_rf(dir)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/lane_helper_spec.rb | fastlane/spec/helper/lane_helper_spec.rb | require "stringio"
describe Fastlane::Actions do
describe "#lanespechelper" do
describe "current_platform" do
it "no platform" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::PLATFORM_NAME] = nil
expect(Fastlane::Helper::LaneHelper.current_platform).to eq(nil)
end
it "ios platform" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::PLATFORM_NAME] = :ios
expect(Fastlane::Helper::LaneHelper.current_platform).to eq(:ios)
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::PLATFORM_NAME] = nil
end
it "android platform" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::PLATFORM_NAME] = :android
expect(Fastlane::Helper::LaneHelper.current_platform).to eq(:android)
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::PLATFORM_NAME] = nil
end
end
describe "current_lane" do
it "no lane" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::LANE_NAME] = nil
expect(Fastlane::Helper::LaneHelper.current_lane).to eq(nil)
end
it "test" do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::LANE_NAME] = :test
expect(Fastlane::Helper::LaneHelper.current_lane).to eq(:test)
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::LANE_NAME] = nil
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/tool_name_formatting_helper_spec.rb | fastlane/spec/helper/tool_name_formatting_helper_spec.rb | require_relative '../../helper/tool_name_formatting_helper.rb'
describe Fastlane::Helper::ToolNameFormattingHelper do
let(:fixture_path) { 'fastlane/spec/fixtures/fastfiles/tool_name_formatting.txt' }
before(:each) do
@helper = Fastlane::Helper::ToolNameFormattingHelper.new(path: fixture_path, is_documenting_invalid_examples: true)
end
describe 'when parsing fixture file' do
it 'should match array of expected errors' do
expected_errors = [
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:17': FastLane makes code signing management easy.",
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:18': Fastlane makes code signing management easy.",
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:19': _FastLane_ makes code signing management easy.",
"fastlane tools have to be formatted in lowercase: fastlane in '#{fixture_path}:23': A sentence that contains a _FastLane_ keyword, but also an env var: `FASTLANE_SKIP_CHANGELOG`."
]
expect(@helper.find_tool_name_formatting_errors).to match_array(expected_errors)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/sh_helper_spec.rb | fastlane/spec/helper/sh_helper_spec.rb | require "stringio"
describe Fastlane::Actions do
describe "#sh" do
before do
allow(FastlaneCore::Helper).to receive(:sh_enabled?).and_return(true)
end
context "external commands are failed" do
context "with error_callback" do
it "doesn't raise shell_error" do
allow(FastlaneCore::UI).to receive(:error)
called = false
expect_command("exit 1", exitstatus: 1)
Fastlane::Actions.sh("exit 1", error_callback: ->(_) { called = true })
expect(called).to be(true)
expect(FastlaneCore::UI).to have_received(:error).with("Exit status of command 'exit 1' was 1 instead of 0.\n")
end
end
context "without error_callback" do
it "raise shell_error" do
allow(FastlaneCore::UI).to receive(:shell_error!)
expect_command("exit 1", exitstatus: 1)
Fastlane::Actions.sh("exit 1")
expect(UI).to have_received(:shell_error!).with("Exit status of command 'exit 1' was 1 instead of 0.\n")
end
end
end
context "passing command arguments to the system" do
it "passes a string as a string" do
expect_command("git commit")
Fastlane::Actions.sh("git commit")
end
it "passes a list" do
expect_command("git", "commit")
Fastlane::Actions.sh("git", "commit")
end
it "passes an environment Hash" do
expect_command({ "PATH" => "/usr/local/bin" }, "git", "commit")
Fastlane::Actions.sh({ "PATH" => "/usr/local/bin" }, "git", "commit")
end
it "allows override of argv[0]" do
expect_command(["/usr/local/bin/git", "git"], "commit", "-m", "A message")
Fastlane::Actions.sh(["/usr/local/bin/git", "git"], "commit", "-m", "A message")
end
it "allows a single array to be passed to support older Fastlane syntax" do
expect_command("ls -la /tmp")
Fastlane::Actions.sh(["ls -la", "/tmp"])
end
it "does not automatically escape array arguments from older fastlane syntax" do
expect_command('git log --oneline')
Fastlane::Actions.sh(["git", "log --oneline"])
end
end
context "with a postfix block" do
it "yields the status, result and command" do
expect_command("ls", "-la")
Fastlane::Actions.sh("ls", "-la") do |status, result, command|
expect(status.exitstatus).to eq(0)
expect(result).to be_empty
expect(command).to eq("ls -la")
end
end
it "yields any error result" do
expect_command("ls", "-la", exitstatus: 1)
Fastlane::Actions.sh("ls", "-la") do |status, result|
expect(status.exitstatus).to eq(1)
expect(result).to be_empty
end
end
it "yields command output" do
expect_command("ls", "-la", exitstatus: 1, output: "Heeeelp! Something went wrong.")
Fastlane::Actions.sh("ls", "-la") do |status, result|
expect(status.exitstatus).to eq(1)
expect(result).to eq("Heeeelp! Something went wrong.")
end
end
it "returns the return value of the block if present" do
expect_command("ls", "-la")
return_value = Fastlane::Actions.sh("ls", "-la") do |status, result|
42
end
expect(return_value).to eq(42)
end
end
end
describe "shell_command_from_args" do
it 'returns the string when a string is passed' do
command = command_from_args("git commit -m 'A message'")
expect(command).to eq("git commit -m 'A message'")
end
it 'raises when no argument passed' do
expect do
command_from_args
end.to raise_error(ArgumentError)
end
it 'shelljoins multiple args' do
message = "A message"
command = command_from_args("git", "commit", "-m", message)
expect(command).to eq("git commit -m #{message.shellescape}")
end
it 'adds an environment Hash at the beginning' do
message = "A message"
command = command_from_args({ "PATH" => "/usr/local/bin" }, "git", "commit", "-m", message)
expect(command).to eq("PATH=/usr/local/bin git commit -m #{message.shellescape}")
end
it 'shell-escapes environment variable values' do
message = "A message"
path = "/usr/my local/bin"
command = command_from_args({ "PATH" => path }, "git", "commit", "-m", message)
expect(command).to eq("PATH=#{path.shellescape} git commit -m #{message.shellescape}")
end
it 'recognizes an array as the only element of a command' do
command = command_from_args(["/usr/local/bin/git", "git"])
expect(command).to eq("/usr/local/bin/git")
end
it 'recognizes an array as the first element of a command' do
message = "A message"
command = command_from_args(["/usr/local/bin/git", "git"], "commit", "-m", message)
expect(command).to eq("/usr/local/bin/git commit -m #{message.shellescape}")
end
end
end
def command_from_args(*args)
Fastlane::Actions.shell_command_from_args(*args)
end
def expect_command(*command, exitstatus: 0, output: "")
mock_input = double(:input)
mock_output = StringIO.new(output)
mock_status = double(:status, exitstatus: exitstatus)
mock_thread = double(:thread, value: mock_status)
expect(Open3).to receive(:popen2e).with(*command).and_yield(mock_input, mock_output, mock_thread)
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/dotenv_helper_spec.rb | fastlane/spec/helper/dotenv_helper_spec.rb | require 'dotenv'
describe Fastlane::Helper::DotenvHelper do
describe "#load_dot_env" do
it "does not load dotenvs when there is no directory" do
expect(subject.class).to receive(:find_dotenv_directory).and_return(nil)
expect(subject.class).to_not(receive(:load_dot_envs_from))
subject.class.load_dot_env(nil)
end
it "loads dotenvs when there is a directory" do
expect(subject.class).to receive(:find_dotenv_directory).and_return("./some/path")
expect(subject.class).to receive(:load_dot_envs_from).with("one", "./some/path")
subject.class.load_dot_env("one")
end
end
describe "#find_dotenv_directory" do
it "discovers in fastlane directory" do
expect(FastlaneCore::FastlaneFolder).to receive(:path).and_return("./fastlane/spec/fixtures/dotenvs/withFastfiles/fastlaneonly/fastlane").at_least(:once)
expect(subject.class.find_dotenv_directory).to eq("./fastlane/spec/fixtures/dotenvs/withFastfiles/fastlaneonly/fastlane")
end
it "discovers in the parent directory" do
expect(FastlaneCore::FastlaneFolder).to receive(:path).and_return("./fastlane/spec/fixtures/dotenvs/withFastfiles/parentonly/fastlane").at_least(:once)
expect(subject.class.find_dotenv_directory).to eq("./fastlane/spec/fixtures/dotenvs/withFastfiles/parentonly/fastlane/..")
end
it "prioritises fastlane directory" do
expect(FastlaneCore::FastlaneFolder).to receive(:path).and_return("./fastlane/spec/fixtures/dotenvs/withFastfiles/parentandfastlane/fastlane").at_least(:once)
expect(subject.class.find_dotenv_directory).to eq("./fastlane/spec/fixtures/dotenvs/withFastfiles/parentandfastlane/fastlane")
end
it "returns nil when no .env files exist" do
expect(FastlaneCore::FastlaneFolder).to receive(:path).and_return("./fastlane/spec/fixtures/fastfiles").at_least(:once)
expect(subject.class.find_dotenv_directory).to eq(nil)
end
end
describe "#load_dot_envs_from" do
it "loads the .env and .env.default files" do
expect(Dotenv).to receive(:load).with('/base/path/.env', '/base/path/.env.default')
expect(Dotenv).not_to(receive(:overload))
subject.class.load_dot_envs_from(nil, '/base/path')
end
it "overloads additional files with param" do
expect(Dotenv).to receive(:load).with('/base/path/.env', '/base/path/.env.default')
expect(Dotenv).to receive(:overload).with('/base/path/.env.one')
expect(Dotenv).to receive(:overload).with('/base/path/.env.two')
subject.class.load_dot_envs_from('one,two', '/base/path')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/adb_helper_spec.rb | fastlane/spec/helper/adb_helper_spec.rb | describe Fastlane::Helper::AdbHelper do
before do
stub_const('ENV', { 'ANDROID_HOME' => '/usr/local/android-sdk' })
end
describe "#load_all_devices" do
context 'adb host' do
it 'no host specified' do
devices = Fastlane::Helper::AdbHelper.new
expect(devices.host_option).to eq(nil)
end
it 'host specified' do
devices = Fastlane::Helper::AdbHelper.new(adb_host: 'device_farm')
expect(devices.host_option).to eq("-H device_farm")
end
end
context 'no devices' do
it 'does not find any active devices' do
adb_response = strip_heredoc(<<-ADB_OUTPUT)
List of devices attached
ADB_OUTPUT
allow(Fastlane::Actions).to receive(:sh).and_return(adb_response)
devices = Fastlane::Helper::AdbHelper.new.load_all_devices
expect(devices.count).to eq(0)
end
end
context 'one device with spurious ADB output mixed in' do
it 'finds an active device' do
adb_response = strip_heredoc(<<-ADB_OUTPUT)
List of devices attached
adb server version (39) doesn't match this client (36); killing...
* daemon started successfully
T065002LTT device usb:437387264X product:ghost_retail model:XT1053 device:ghost
ADB_OUTPUT
allow(Fastlane::Actions).to receive(:sh).and_return(adb_response)
devices = Fastlane::Helper::AdbHelper.new.load_all_devices
expect(devices.count).to eq(1)
expect(devices[0].serial).to eq("T065002LTT")
end
end
context 'one device' do
it 'finds an active device' do
adb_response = strip_heredoc(<<-ADB_OUTPUT)
List of devices attached
T065002LTT device usb:437387264X product:ghost_retail model:XT1053 device:ghost
ADB_OUTPUT
allow(Fastlane::Actions).to receive(:sh).and_return(adb_response)
devices = Fastlane::Helper::AdbHelper.new.load_all_devices
expect(devices.count).to eq(1)
expect(devices[0].serial).to eq("T065002LTT")
end
end
context 'multiple devices' do
it 'finds an active device' do
adb_response = strip_heredoc(<<-ADB_OUTPUT)
List of devices attached
emulator-5554 device product:sdk_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64
T065002LTT device usb:437387264X product:ghost_retail model:XT1053 device:ghost
ADB_OUTPUT
allow(Fastlane::Actions).to receive(:sh).and_return(adb_response)
devices = Fastlane::Helper::AdbHelper.new.load_all_devices
expect(devices.count).to eq(2)
expect(devices[0].serial).to eq("emulator-5554")
expect(devices[1].serial).to eq("T065002LTT")
end
end
context 'one device booting' do
it 'finds an active device' do
adb_response = strip_heredoc(<<-ADB_OUTPUT)
List of devices attached
emulator-5554 offline
T065002LTT device usb:437387264X product:ghost_retail model:XT1053 device:ghost
ADB_OUTPUT
allow(Fastlane::Actions).to receive(:sh).and_return(adb_response)
devices = Fastlane::Helper::AdbHelper.new.load_all_devices
expect(devices.count).to eq(1)
expect(devices[0].serial).to eq("T065002LTT")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/plugin_scores_helper_spec.rb | fastlane/spec/helper/plugin_scores_helper_spec.rb | require_relative '../../helper/plugin_scores_helper.rb'
describe Fastlane::Helper::PluginScoresHelper::FastlaneActionFileParser do
describe 'parsing' do
it "parses single line action's description" do
action_file = './fastlane/spec/fixtures/plugins/single_line_description_action.rb'
actions = Fastlane::Helper::PluginScoresHelper::FastlaneActionFileParser.new.parse_file(File.expand_path(action_file))
expect(actions.length).to equal(1)
expect(actions.first.description).to match('This is single line description.') if actions.length == 1
end
it "parses multi line action's description" do
action_file = './fastlane/spec/fixtures/plugins/multi_line_description_action.rb'
actions = Fastlane::Helper::PluginScoresHelper::FastlaneActionFileParser.new.parse_file(File.expand_path(action_file))
expect(actions.length).to equal(1)
expect(actions.first.description).to match('This is multi line description.') if actions.length == 1
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/xcodes_helper_spec.rb | fastlane/spec/helper/xcodes_helper_spec.rb | describe Fastlane::Helper::XcodesHelper do
describe ".read_xcode_version_file" do
let(:xcode_version_path) { ".xcode-version" }
context ".xcode-version file exists" do
before do
allow(Dir).to receive(:glob).with(".xcode-version").and_return([xcode_version_path])
allow(File).to receive(:read).with(xcode_version_path).and_return("14")
end
it "returns its content" do
expect(subject.class.read_xcode_version_file).to eq("14")
end
end
context "no .xcode-version file exists" do
before do
allow(Dir).to receive(:glob).with(".xcode-version").and_return([])
end
it "returns nil" do
expect(subject.class.read_xcode_version_file).to eq(nil)
end
end
end
describe ".find_xcodes_binary_path" do
it "returns the binary path when it's installed" do
expect(subject.class).to receive(:find_xcodes_binary_path).and_return("/path/to/bin/xcodes")
expect(subject.class.find_xcodes_binary_path).to eq("/path/to/bin/xcodes")
end
it "returns an error message instead of a valid path when it's not installed" do
expect(subject.class).to receive(:find_xcodes_binary_path).and_return("xcodes not found")
expect(File.exist?(subject.class.find_xcodes_binary_path)).to eq(false)
end
end
describe "Verify" do
describe ".requirement" do
context "when argument is missing or empty" do
let(:argument) { nil }
it "raises user error" do
expect { subject.class::Verify.requirement(argument) }.to raise_error(FastlaneCore::Interface::FastlaneError, 'Version must be specified')
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/spec/helper/s3_client_helper_spec.rb | fastlane/spec/helper/s3_client_helper_spec.rb | describe Fastlane::Helper::S3ClientHelper do
subject { described_class.new(s3_client: instance_double('Aws::S3::Client')) }
describe '#find_bucket!' do
before { class_double('Aws::S3::Bucket', new: bucket).as_stubbed_const }
context 'when bucket found' do
let(:bucket) { instance_double('Aws::S3::Bucket', exists?: true) }
it 'returns bucket' do
expect(subject.find_bucket!('foo')).to eq(bucket)
end
end
context 'when bucket not found' do
let(:bucket) { instance_double('Aws::S3::Bucket', exists?: false) }
it 'raises error' do
expect { subject.find_bucket!('foo') }.to raise_error("Bucket 'foo' not found")
end
end
end
describe '#delete_file' do
it 'deletes s3 object' do
object = instance_double('Aws::S3::Object', delete: true)
bucket = instance_double('Aws::S3::Bucket', object: object)
expect(subject).to receive(:find_bucket!).and_return(bucket)
expect(object).to receive(:delete)
subject.delete_file('foo', 'bar')
end
end
describe 'underlying client creation' do
let(:s3_client) { instance_double('Aws::S3::Client', list_buckets: []) }
let(:s3_credentials) { instance_double('Aws::Credentials') }
before { class_double('Aws::Credentials', new: s3_credentials).as_stubbed_const }
it 'does create with any parameters if none are given' do
expect(Aws::S3::Client).to receive(:new).with({}).and_return(s3_client)
described_class.new.list_buckets
end
it 'passes region if given' do
expect(Aws::S3::Client).to receive(:new).with({ region: 'aws-region' }).and_return(s3_client)
described_class.new(region: 'aws-region').list_buckets
end
it 'creates credentials if access_key and secret are given' do
expect(Aws::S3::Client).to receive(:new).with({ credentials: s3_credentials }).and_return(s3_client)
described_class.new(access_key: 'access_key', secret_access_key: 'secret_access_key').list_buckets
end
it 'does not create credentials if access_key and secret are blank' do
expect(Aws::S3::Client).to receive(:new).with({}).and_return(s3_client)
described_class.new(access_key: '', secret_access_key: '').list_buckets
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/helper/tool_name_formatting_helper.rb | fastlane/helper/tool_name_formatting_helper.rb | module Fastlane
module Helper
class ToolNameFormattingHelper
attr_accessor :path, :is_documenting_invalid_examples
# @param [String] path Path to the file to be checked for tool formatting
# @param [Bool] is_documenting_invalid_examples
# Ignore checks if line starts with "^\s*- โ" (i.e. if it's a line that's already been marked as incorrect)
# Typically used for files like `CONTRIBUTING.md`` (i.e. if it's the branding guidelines section)
#
def initialize(path:, is_documenting_invalid_examples: false)
@path = path
@is_documenting_invalid_examples = is_documenting_invalid_examples
end
def find_tool_name_formatting_errors
errors = []
File.readlines(path, mode: 'rb:BOM|UTF-8').each_with_index do |line, index|
line_number = index + 1
line.chomp! # Remove \n at end of line, to avoid including it in the error messages
Fastlane::TOOLS.each do |tool|
next if is_documenting_invalid_examples && line =~ /^\s*- โ/
errors << "Use _#{tool}_ instead of `#{tool}` to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("`#{tool}`")
errors << "Use _#{tool}_ instead of `_#{tool}_` to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("`_#{tool}_`")
errors << "Use [_#{tool}_] instead of [#{tool}] to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("[#{tool}]")
errors << "Use _#{tool}_ instead of **#{tool}** to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("**#{tool}**")
errors << "Use <em>#{tool}<em> instead of <code>#{tool}</code> to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("<code>#{tool}</code>")
errors << "Use <em>#{tool}<em> or _#{tool}_ instead of <ins>#{tool}</ins> to mention a tool in the docs in '#{path}:#{line_number}': #{line}" if line.include?("<ins>#{tool}</ins>")
" #{line} ".scan(/([A-Z_]*)([_ `"])(#{Regexp.escape(tool.to_s)})\2([A-Z_]*)/i) do |prefix, delimiter, tool_name, suffix|
is_lowercase = tool_name == tool.to_s.downcase
looks_like_an_env_var = (tool_name == tool_name.upcase) && delimiter == '_' && (!prefix.empty? || !suffix.empty?)
looks_like_ruby_module = line == "module #{tool_name}"
is_valid_case = is_lowercase || looks_like_an_env_var || looks_like_ruby_module
errors << "fastlane tools have to be formatted in lowercase: #{tool} in '#{path}:#{line_number}': #{line}" unless is_valid_case
end
end
end
errors
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/helper/plugin_scores_helper.rb | fastlane/helper/plugin_scores_helper.rb | module Fastlane
module Helper
module PluginScoresHelper
require 'faraday'
require 'faraday_middleware'
require 'yaml'
class FastlanePluginRating
attr_accessor :key
attr_accessor :description
attr_accessor :value
def initialize(key: nil, description: nil, value: nil)
self.key = key
self.description = description
self.value = value
end
end
class FastlanePluginAction
attr_accessor :name
attr_accessor :category
attr_accessor :description
attr_accessor :details
def initialize(name: nil, category: nil, description: nil, details: nil)
self.name = name
self.category = category
self.description = description
self.details = details
end
end
class FastlanePluginScore
attr_accessor :name
attr_accessor :downloads
attr_accessor :info
attr_accessor :homepage
attr_accessor :raw_hash
attr_accessor :data
attr_accessor :cache
def initialize(hash, cache_path)
if ENV["GITHUB_USER_NAME"].to_s.length == 0 || ENV["GITHUB_API_TOKEN"].to_s.length == 0
raise "Missing ENV variables GITHUB_USER_NAME and/or GITHUB_API_TOKEN"
end
self.name = hash["name"]
self.downloads = hash["downloads"]
self.info = hash["info"]
self.homepage = hash["homepage_uri"] || hash["documentation_uri"]
self.raw_hash = hash
has_github_page = self.homepage.to_s.start_with?("https://github.com") # Here we can add non GitHub support one day
self.data = {
has_homepage: self.homepage.to_s.length > 5,
has_info: self.info.to_s.length > 5,
downloads: self.downloads,
has_github_page: has_github_page,
has_mit_license: includes_license?("MIT"),
has_gnu_license: includes_license?("GNU") || includes_license?("GPL"),
major_release: Gem::Version.new(hash["version"]) >= Gem::Version.new("1.0.0"),
actions: [],
sha: hash["sha"]
}
if File.exist?(cache_path)
self.cache = YAML.safe_load(
File.read(cache_path),
permitted_classes: [Date, Time, Symbol, FastlanePluginAction],
aliases: true
)
else
self.cache = {}
end
if has_github_page
is_cached = self.load_cache
unless is_cached
self.append_git_data
self.append_github_data
end
end
File.open(cache_path, 'w') do |file|
file.write(self.cache.to_yaml)
end
self.data[:overall_score] = 0
self.data[:ratings] = self.ratings.collect do |current_rating|
[
current_rating.key,
current_rating.value
]
end.to_h
self.ratings.each do |current_rating|
self.data[:overall_score] += current_rating.value
end
end
def ratings
[
FastlanePluginRating.new(key: :contributors,
description: "The more contributors a project has, the more likely it is it stays alive",
value: self.data[:github_contributors].to_i * 6),
FastlanePluginRating.new(key: :subscribers,
description: "More subscribers = more popular project",
value: self.data[:github_subscribers].to_i * 3),
FastlanePluginRating.new(key: :stars,
description: "More stars = more popular project",
value: self.data[:github_stars].to_i),
FastlanePluginRating.new(key: :forks,
description: "More forks = more people seem to use/modify this project",
value: self.data[:github_forks].to_i * 5),
FastlanePluginRating.new(key: :has_mit_license,
description: "fastlane is MIT licensed, it's good to have plugins use MIT too",
value: (self.data[:has_mit_license] ? 20 : -50)),
FastlanePluginRating.new(key: :readme_score,
description: "How well is the README of the document written",
value: self.data[:readme_score].to_i / 2),
FastlanePluginRating.new(key: :age,
description: "Project that have been around for longer tend to be more stable",
value: self.data[:age_in_days].to_i / 60),
FastlanePluginRating.new(key: :major_release,
description: "Post 1.0 releases are great",
value: (self.data[:major_release] ? 30 : 0)),
FastlanePluginRating.new(key: :github_issues,
description: "Lots of open issues are not a good sign usually, unless the project is really popular",
value: (self.data[:github_issues].to_i * -1)),
FastlanePluginRating.new(key: :downloads,
description: "More downloads = more users have been using the plugin for a while",
value: (self.data[:downloads].to_i / 250)),
FastlanePluginRating.new(key: :tests,
description: "The more tests a plugin has, the better",
value: [self.data[:tests].to_i * 3, 80].min)
]
end
# What colors should the overall score be printed in
def color_to_use
case self.data[:overall_score]
when -1000...40
'ff6666'
when 40...100
'558000'
when 100...250
'63b319'
when 250...10_000
'72CC1D'
else
'558000' # this shouldn't happen
end
end
def includes_license?(license)
# e.g. "licenses"=>["MIT"],
self.raw_hash["licenses"].any? { |l| l.include?(license) }
end
def load_cache
if self.cache.key?(self.name)
cache_data = self.cache[self.name]
else
cache_data = {}
end
self.cache[self.name] = cache_data
if self.data[:sha] == cache_data[:sha]
self.data[:initial_commit] = cache_data[:initial_commit]
self.data[:age_in_days] = (DateTime.now - self.data[:initial_commit]).to_i
self.data[:readme_score] = cache_data[:readme_score]
self.data[:tests] = cache_data[:tests]
self.data[:actions] = cache_data[:actions]
self.data[:sha] = cache_data[:sha]
self.data[:github_stars] = cache_data[:github_stars]
self.data[:github_subscribers] = cache_data[:github_subscribers]
self.data[:github_issues] = cache_data[:github_issues]
self.data[:github_forks] = cache_data[:github_forks]
self.data[:github_contributors] = cache_data[:github_contributors]
return true
end
return false
end
# Everything that needs to be fetched from the content of the Git repo
def append_git_data
Dir.mktmpdir("fastlane-plugin") do |tmp|
clone_folder = File.join(tmp, self.name)
`GIT_TERMINAL_PROMPT=0 git clone #{self.homepage.shellescape} #{clone_folder.shellescape}`
break unless File.directory?(clone_folder)
Dir.chdir(clone_folder) do
# Taken from https://github.com/CocoaPods/cocoadocs.org/blob/master/classes/stats_generator.rb
self.data[:initial_commit] = DateTime.parse(`git rev-list --all|tail -n1|xargs git show|grep -v diff|head -n3|tail -1|cut -f2-8 -d' '`.strip).to_date
self.data[:age_in_days] = (DateTime.now - self.data[:initial_commit]).to_i
readme_score = 100
if File.exist?("README.md")
readme_content = File.read("README.md").downcase
readme_score -= 50 if readme_content.include?("note to author")
readme_score -= 50 if readme_content.include?("todo")
else
readme_score = 0
end
self.data[:readme_score] = readme_score
# Detect how many tests this plugin has
tests_count = 0
Dir["spec/**/*_spec.rb"].each do |spec_file|
# poor person's way to detect the number of tests, good enough to get a sense
tests_count += File.read(spec_file).scan(/ it /).count
end
self.data[:tests] = tests_count
actions = Dir["**/actions/*.rb"].map do |action_file|
FastlaneActionFileParser.new.parse_file(action_file)
end
# Result of the above is an array of arrays, this merges all of them into data[:actions]
self.data[:actions] = actions.flatten
cache_data = self.cache[self.name]
cache_data[:initial_commit] = self.data[:initial_commit]
cache_data[:age_in_days] = self.data[:age_in_days]
cache_data[:readme_score] = self.data[:readme_score]
cache_data[:tests] = self.data[:tests]
cache_data[:actions] = self.data[:actions]
cache_data[:sha] = self.data[:sha]
end
end
end
# Everything from the GitHub API (e.g. open issues and stars)
def append_github_data
# e.g. https://api.github.com/repos/fastlane/fastlane
url = self.homepage.gsub("github.com/", "api.github.com/repos/")
url = url[0..-2] if url.end_with?("/") # what is this, 2001? We got to remove the trailing `/` otherwise GitHub will fail
puts("Fetching #{url}")
conn = Faraday.new(url: url) do |builder|
# The order below IS important
# See bug here https://github.com/lostisland/faraday_middleware/issues/105
builder.use(FaradayMiddleware::FollowRedirects)
builder.adapter(Faraday.default_adapter)
end
conn.basic_auth(ENV["GITHUB_USER_NAME"], ENV["GITHUB_API_TOKEN"])
response = conn.get('')
repo_details = JSON.parse(response.body)
url += "/stats/contributors"
puts("Fetching #{url}")
conn = Faraday.new(url: url) do |builder|
# The order below IS important
# See bug here https://github.com/lostisland/faraday_middleware/issues/105
builder.use(FaradayMiddleware::FollowRedirects)
builder.adapter(Faraday.default_adapter)
end
conn.basic_auth(ENV["GITHUB_USER_NAME"], ENV["GITHUB_API_TOKEN"])
response = conn.get('')
contributor_details = JSON.parse(response.body)
self.data[:github_stars] = repo_details["stargazers_count"].to_i
self.data[:github_subscribers] = repo_details["subscribers_count"].to_i
self.data[:github_issues] = repo_details["open_issues_count"].to_i
self.data[:github_forks] = repo_details["forks_count"].to_i
self.data[:github_contributors] = contributor_details.count
cache_data = self.cache[self.name]
cache_data[:github_stars] = self.data[:github_stars]
cache_data[:github_subscribers] = self.data[:github_subscribers]
cache_data[:github_issues] = self.data[:github_issues]
cache_data[:github_forks] = self.data[:github_forks]
cache_data[:github_contributors] = self.data[:github_contributors]
rescue => ex
puts("error fetching #{self}")
puts(self.homepage)
puts("Chances are high you exceeded the GitHub API limit")
puts(ex)
puts(ex.backtrace)
raise ex
end
end
class FastlaneActionFileParser
attr_accessor :state
def initialize
self.state = []
end
# Parses the file to find all included actions
# rubocop:disable Metrics/PerceivedComplexity
def parse_file(file, debug_state: false)
lines = File.read(file).lines
actions = []
# Class state information
name = nil
description = nil
category = nil
details = nil
# Method state information
last_method_name = nil
last_string_statement = nil
lines.each do |line|
case self.state.last
when nil
name = action_name_from_line(line)
self.state << :in_class if is_class?(line)
when :in_class
if (method_name = method_name_from_line(line))
last_method_name = method_name
self.state << :in_method
end
if is_end?(line)
self.state.pop
# Make sure to skip helper classes where the name is nil
actions << FastlanePluginAction.new(name: name.fastlane_underscore, category: category, description: description, details: details) unless name.nil?
name = category = description = details = nil
end
when :in_method
if (string_statement = string_statement_from_line(line))
# Multiline support for `description` method
if last_method_name == 'description' && !last_string_statement.nil?
last_string_statement.concat(string_statement)
else
last_string_statement = string_statement
end
end
if is_block?(line)
self.state << :in_block
end
if is_end?(line)
category = last_string_statement if last_method_name == "category"
description = last_string_statement if last_method_name == "description"
details = last_string_statement if last_method_name == "details"
last_method_name = last_string_statement = nil
self.state.pop
end
when :in_block
if is_block?(line)
self.state << :in_block
end
self.state.pop if is_end?(line)
end
next unless debug_state
puts("Current line: #{line}")
puts("Full State: #{state}")
puts("Current action name: #{name}, category: #{category}, description: \"#{description}\", details: \"#{details}\"")
puts("Last string statement: #{last_string_statement}, last method name: #{last_method_name}")
end
actions
end
def is_block?(line)
# Matches beginning block statement from the list of keywords
# `do` has to be handled separately because it can be preceded by a function call
!!line.match(/^(?:[\s\w]*=)?\s*(if|unless|case|while|loop|for|until|begin)/) \
|| !!line.match(/^(?:[\s\w]*=)?\s*.*\s+do\s*(?:\|.*\|)?\s*(?:#.*)?$/)
end
def is_end?(line)
!!line.match(/^\s*end\s*/)
end
def is_class?(line)
!!line.match(/^\s*class\s+/)
end
def action_name_from_line(line)
# matches `class <action name>Action < Action` and returns action_name
line.match(/^\s*class\s+(\w+)Action\s+<\s+Action\s*(?:#.*)?$/) do |matching|
matching.captures.first
end
end
def method_name_from_line(line)
# matches `def <method>`, strips self. if is there, returns <method>
line.match(/^\s*def\s+(?:self\.)?(\w+)/) do |matching|
matching.captures.first
end
end
def string_statement_from_line(line)
# All the ways ruby can represent single-line strings
regex = [
"[\"]([^\"]+)\"", # Matches strings with "
"[\']([^\']+)\'", # Matches strings with '
":([@$_a-zA-Z]\\w*[!=?\\w])", # Matches `:<symbol>`
"%(?:[Q]?|[qs])(?:#{[ # Matches `%Q`, `%q`, `%s` and just `%`, with subexpression:
'([\\W_])([^\\4]*)\\4', # Matches <symbol><string><symbol>, returns <string>
'\[([^\\]]*)\]', # Matches [<string>]
'\(([^\\)]*)\)', # Matches (<string>)
'\{([^\\]]*)\}' # Matches {<string>}
].join('|')})"
].join('|')
line.match(regex) do |matching|
matching.captures.compact.last
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane.rb | fastlane/lib/fastlane.rb | require 'fastlane_core'
require 'fastlane/version'
require 'fastlane/features'
require 'fastlane/shells'
require 'fastlane/tools'
require 'fastlane/documentation/actions_list'
require 'fastlane/actions/actions_helper' # has to be before fast_file
require 'fastlane/fast_file'
require 'fastlane/runner'
require 'fastlane/setup/setup'
require 'fastlane/lane'
require 'fastlane/junit_generator'
require 'fastlane/lane_manager'
require 'fastlane/lane_manager_base'
require 'fastlane/swift_lane_manager'
require 'fastlane/action'
require 'fastlane/action_collector'
require 'fastlane/supported_platforms'
require 'fastlane/configuration_helper'
require 'fastlane/one_off'
require 'fastlane/server/socket_server_action_command_executor'
require 'fastlane/server/socket_server'
require 'fastlane/command_line_handler'
require 'fastlane/documentation/docs_generator'
require 'fastlane/other_action'
require 'fastlane/plugins/plugins'
require 'fastlane/fastlane_require'
require "fastlane/swift_fastlane_api_generator.rb"
module Fastlane
Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
UI = FastlaneCore::UI
ROOT = Pathname.new(File.expand_path('../..', __FILE__))
class << self
def load_actions
Fastlane::Actions.load_default_actions
Fastlane::Actions.load_helpers
if FastlaneCore::FastlaneFolder.path
actions_path = File.join(FastlaneCore::FastlaneFolder.path, 'actions')
@external_actions = Fastlane::Actions.load_external_actions(actions_path) if File.directory?(actions_path)
end
end
attr_reader :external_actions
def plugin_manager
@plugin_manager ||= Fastlane::PluginManager.new
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/assets/custom_action_template.rb | fastlane/lib/assets/custom_action_template.rb | module Fastlane
module Actions
module SharedValues
[[NAME_UP]]_CUSTOM_VALUE = :[[NAME_UP]]_CUSTOM_VALUE
end
class [[NAME_CLASS]] < Action
def self.run(params)
# fastlane will take care of reading in the parameter and fetching the environment variable:
UI.message("Parameter API Token: #{params[:api_token]}")
# sh "shellcommand ./path"
# Actions.lane_context[SharedValues::[[NAME_UP]]_CUSTOM_VALUE] = "my_val"
end
#####################################################
# @!group Documentation
#####################################################
def self.description
'A short description with <= 80 characters of what this action does'
end
def self.details
# Optional:
# this is your chance to provide a more detailed description of this action
'You can use this action to do cool things...'
end
def self.available_options
# Define all options your action supports.
# Below a few examples
[
FastlaneCore::ConfigItem.new(key: :api_token,
# The name of the environment variable
env_name: 'FL_[[NAME_UP]]_API_TOKEN',
# a short description of this parameter
description: 'API Token for [[NAME_CLASS]]',
verify_block: proc do |value|
unless value && !value.empty?
UI.user_error!("No API token for [[NAME_CLASS]] given, pass using `api_token: 'token'`")
end
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :development,
env_name: 'FL_[[NAME_UP]]_DEVELOPMENT',
description: 'Create a development certificate instead of a distribution one',
# true: verifies the input is a string, false: every kind of value
is_string: false,
# the default value if the user didn't provide one
default_value: false)
]
end
def self.output
# Define the shared values you are going to provide
# Example
[
['[[NAME_UP]]_CUSTOM_VALUE', 'A description of what this value contains']
]
end
def self.return_value
# If your method provides a return value, you can describe here what it does
end
def self.authors
# So no one will ever forget your contribution to fastlane :) You are awesome btw!
['Your GitHub/Twitter Name']
end
def self.is_supported?(platform)
# you can do things like
#
# true
#
# platform == :ios
#
# [:ios, :mac].include?(platform)
#
platform == :ios
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/markdown_table_formatter.rb | fastlane/lib/fastlane/markdown_table_formatter.rb | module Fastlane
class MarkdownTableFormatter
# taken from: https://github.com/benbalter/markdown-table-formatter
def initialize(string, header = true)
@doc = string
@header = header
end
# converts the markdown string into an array of arrays
def parse
@table = []
rows = @doc.split(/\r?\n/)
rows.each do |row|
row_array = row.split("|")
row_array.each(&:strip!)
@table.push(row_array)
end
@table.delete_at(1) if @header # strip header separator
@table
end
def table
@table ||= parse
end
def column_width(column)
width = 0
table.each do |row|
length = row[column].strip.length
width = length if length > width
end
width
end
def pad(string, length)
string.strip.ljust(length, ' ')
end
def separator(length)
"".ljust(length, '-')
end
def header_separator_row
output = []
[*0...table.first.length].each do |column|
output.push(separator(column_width(column)))
end
output
end
def to_md
output = ""
t = table.clone
t.insert(1, header_separator_row) if @header
t.each_with_index do |row, index|
row.map!.with_index { |cell_row, index_row| pad(cell_row, column_width(index_row)) }
output += "#{row.join(' | ').lstrip} |\n"
end
output
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/environment_printer.rb | fastlane/lib/fastlane/environment_printer.rb | module Fastlane
class EnvironmentPrinter
def self.output
env_info = get
# Remove sensitive option values
FastlaneCore::Configuration.sensitive_strings.compact.each do |sensitive_element|
env_info.gsub!(sensitive_element, "#########")
end
puts(env_info)
UI.important("Take notice that this output may contain sensitive information, or simply information that you don't want to make public.")
if FastlaneCore::Helper.mac? && UI.interactive? && UI.confirm("๐ Wow, that's a lot of markdown text... should fastlane put it into your clipboard, so you can easily paste it on GitHub?")
copy_to_clipboard(env_info)
UI.success("Successfully copied markdown into your clipboard ๐จ")
end
UI.success("Open https://github.com/fastlane/fastlane/issues/new to submit a new issue โ
")
end
def self.get
UI.important("Generating fastlane environment output, this might take a few seconds...")
require "fastlane/markdown_table_formatter"
env_output = ""
env_output << print_system_environment
env_output << print_system_locale
env_output << print_fastlane_files
env_output << print_loaded_fastlane_gems
env_output << print_loaded_plugins
env_output << print_loaded_gems
env_output << print_date
# Adding title
status = (env_output.include?("๐ซ") ? "๐ซ" : "โ
")
env_header = "<details><summary>#{status} fastlane environment #{status}</summary>\n\n"
env_tail = "</details>"
final_output = ""
if FastlaneCore::Globals.captured_output?
final_output << "### Captured Output\n\n"
final_output << "Command Used: `#{ARGV.join(' ')}`\n"
final_output << "<details><summary>Output/Log</summary>\n\n```\n\n#{FastlaneCore::Globals.captured_output}\n\n```\n\n</details>\n\n"
end
final_output << env_header + env_output + env_tail
end
def self.print_date
date = Time.now.strftime("%Y-%m-%d")
"\n*generated on:* **#{date}**\n"
end
def self.print_loaded_plugins
env_output = "### Loaded fastlane plugins:\n"
env_output << "\n"
plugin_manager = Fastlane::PluginManager.new
plugin_manager.load_plugins(print_table: false)
if plugin_manager.available_plugins.length <= 0
env_output << "**No plugins Loaded**\n"
else
table = ""
table << "| Plugin | Version | Update-Status |\n"
table << "|--------|---------|\n"
plugin_manager.available_plugins.each do |plugin|
begin
installed_version = Fastlane::ActionCollector.determine_version(plugin)
latest_version = FastlaneCore::UpdateChecker.fetch_latest(plugin)
if Gem::Version.new(installed_version) == Gem::Version.new(latest_version)
update_status = "โ
Up-To-Date"
else
update_status = "๐ซ Update available"
end
rescue
update_status = "๐ฅ Check failed"
end
table << "| #{plugin} | #{installed_version} | #{update_status} |\n"
end
rendered_table = MarkdownTableFormatter.new(table)
env_output << rendered_table.to_md
end
env_output << "\n\n"
env_output
end
# We have this as a separate method, as this has to be handled
# slightly differently, depending on how fastlane is being called
def self.gems_to_check
if Helper.contained_fastlane?
Gem::Specification
else
Gem.loaded_specs.values
end
end
def self.print_loaded_fastlane_gems
# fastlanes internal gems
env_output = "### fastlane gems\n\n"
table = ""
table << "| Gem | Version | Update-Status |\n"
table << "|-----|---------|------------|\n"
fastlane_tools = Fastlane::TOOLS + [:fastlane_core, :credentials_manager]
gems_to_check.each do |current_gem|
update_status = "N/A"
next unless fastlane_tools.include?(current_gem.name.to_sym)
begin
latest_version = FastlaneCore::UpdateChecker.fetch_latest(current_gem.name)
if Gem::Version.new(current_gem.version) >= Gem::Version.new(latest_version)
update_status = "โ
Up-To-Date"
else
update_status = "๐ซ Update available"
end
rescue
update_status = "๐ฅ Check failed"
end
table << "| #{current_gem.name} | #{current_gem.version} | #{update_status} |\n"
end
rendered_table = MarkdownTableFormatter.new(table)
env_output << rendered_table.to_md
env_output << "\n\n"
return env_output
end
def self.print_loaded_gems
env_output = "<details>"
env_output << "<summary><b>Loaded gems</b></summary>\n\n"
table = "| Gem | Version |\n"
table << "|-----|---------|\n"
gems_to_check.each do |current_gem|
unless Fastlane::TOOLS.include?(current_gem.name.to_sym)
table << "| #{current_gem.name} | #{current_gem.version} |\n"
end
end
rendered_table = MarkdownTableFormatter.new(table)
env_output << rendered_table.to_md
env_output << "</details>\n\n"
return env_output
end
def self.print_system_locale
env_output = "### System Locale\n\n"
found_one = false
env_table = ""
["LANG", "LC_ALL", "LANGUAGE"].each do |e|
env_icon = "๐ซ"
if ENV[e] && ENV[e].end_with?("UTF-8")
env_icon = "โ
"
found_one = true
end
if ENV[e].nil?
env_icon = ""
end
env_table << "| #{e} | #{ENV[e]} | #{env_icon} |\n"
end
if !found_one
table = "| Error |\n"
table << "|-----|\n"
table << "| No Locale with UTF8 found ๐ซ|\n"
else
table = "| Variable | Value | |\n"
table << "|-----|---------|----|\n"
table << env_table
end
rendered_table = MarkdownTableFormatter.new(table)
env_output << rendered_table.to_md
env_output << "\n\n"
end
def self.print_system_environment
require "openssl"
env_output = "### Stack\n\n"
product, version, build = "Unknown"
os_version = "UNKNOWN"
if Helper.mac?
product, version, build = `sw_vers`.strip.split("\n").map { |line| line.split(':').last.strip }
os_version = version
end
if Helper.linux?
# this should work on pretty much all linux distros
os_version = `uname -a`.strip
version = ""
build = `uname -r`.strip
product = `cat /etc/issue.net`.strip
distro_guesser = {
fedora: "/etc/fedora-release",
debian_based: "/etc/debian_version",
suse: "/etc/SUSE-release",
mandrake: "/etc/mandrake-release"
}
distro_guesser.each do |dist, vers|
os_version = "#{dist} " + File.read(vers).strip if File.exist?(vers)
version = os_version
end
end
table_content = {
"fastlane" => Fastlane::VERSION,
"OS" => os_version,
"Ruby" => RUBY_VERSION,
"Bundler?" => Helper.bundler?,
"Git" => git_version,
"Installation Source" => anonymized_path($PROGRAM_NAME),
"Host" => "#{product} #{version} (#{build})",
"Ruby Lib Dir" => anonymized_path(RbConfig::CONFIG['libdir']),
"OpenSSL Version" => OpenSSL::OPENSSL_VERSION,
"Is contained" => Helper.contained_fastlane?.to_s,
"Is homebrew" => Helper.homebrew?.to_s,
"Is installed via Fabric.app" => Helper.mac_app?.to_s
}
if Helper.mac?
table_content["Xcode Path"] = anonymized_path(Helper.xcode_path)
begin
table_content["Xcode Version"] = Helper.xcode_version
rescue => ex
UI.error(ex)
UI.error("Could not get Xcode Version")
end
table_content["Swift Version"] = Helper.swift_version || "N/A"
end
table = ["| Key | Value |"]
table += table_content.collect { |k, v| "| #{k} | #{v} |" }
begin
rendered_table = MarkdownTableFormatter.new(table.join("\n"))
env_output << rendered_table.to_md
rescue => ex
UI.error(ex)
UI.error("Error rendering markdown table using the following text:")
UI.message(table.join("\n"))
env_output << table.join("\n")
end
env_output << "\n\n"
env_output
end
def self.print_fastlane_files
env_output = "### fastlane files:\n\n"
fastlane_path = FastlaneCore::FastlaneFolder.fastfile_path
if fastlane_path && File.exist?(fastlane_path)
env_output << "<details>"
env_output << "<summary>`#{fastlane_path}`</summary>\n"
env_output << "\n"
env_output << "```ruby\n"
env_output << File.read(fastlane_path, encoding: "utf-8")
env_output << "\n```\n"
env_output << "</details>"
else
env_output << "**No Fastfile found**\n"
end
env_output << "\n\n"
appfile_path = CredentialsManager::AppfileConfig.default_path
if appfile_path && File.exist?(appfile_path)
env_output << "<details>"
env_output << "<summary>`#{appfile_path}`</summary>\n"
env_output << "\n"
env_output << "```ruby\n"
env_output << File.read(appfile_path, encoding: "utf-8")
env_output << "\n```\n"
env_output << "</details>"
else
env_output << "**No Appfile found**\n"
end
env_output << "\n\n"
env_output
end
def self.anonymized_path(path, home = ENV['HOME'])
return home ? path.gsub(%r{^#{home}(?=/(.*)|$)}, '~\2') : path
end
# Copy a given string into the clipboard
# Make sure to ask the user first, as some people don't
# use a clipboard manager, so they might lose something important
def self.copy_to_clipboard(string)
require 'open3'
Open3.popen3('pbcopy') { |input, _, _| input << string }
end
def self.git_version
return `git --version`.strip.split("\n").first
rescue
return "not found"
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/version.rb | fastlane/lib/fastlane/version.rb | module Fastlane
VERSION = '2.230.0'.freeze
SUMMARY = "The easiest way to build and release mobile apps.".freeze
DESCRIPTION = "The easiest way to automate beta deployments and releases for your iOS and Android apps".freeze
MINIMUM_XCODE_RELEASE = "7.0".freeze
RUBOCOP_REQUIREMENT = '1.50.2'.freeze
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/swift_fastlane_api_generator.rb | fastlane/lib/fastlane/swift_fastlane_api_generator.rb | require 'fastlane/swift_fastlane_function.rb'
module Fastlane
class SwiftToolDetail
attr_accessor :swift_class
attr_accessor :swift_protocol
attr_accessor :command_line_tool_name
def initialize(command_line_tool_name: nil, swift_class: nil, swift_protocol: nil)
self.command_line_tool_name = command_line_tool_name
self.swift_class = swift_class
self.swift_protocol = swift_protocol
end
end
class SwiftAPIGenerator
end
class SwiftFastlaneAPIGenerator < SwiftAPIGenerator
def initialize(target_output_path: "swift")
@target_filename = "Fastlane.swift"
@target_output_path = File.expand_path(target_output_path)
@generated_paths = []
super()
self.actions_not_supported = ["import", "import_from_git"].to_set
self.action_options_to_ignore = {
"precheck" => [
"negative_apple_sentiment",
"placeholder_text",
"other_platforms",
"future_functionality",
"test_words",
"curse_words",
"custom_text",
"copyright_date",
"unreachable_urls"
].to_set
}
end
def extend_content(file_content, tool_details)
file_content << "" # newline because we're adding an extension
file_content << "// These are all the parsing functions needed to transform our data into the expected types"
file_content << generate_lanefile_parsing_functions
tool_objects = generate_lanefile_tool_objects(classes: tool_details.map(&:swift_class))
file_content << tool_objects
old_file_content = File.read(fastlane_swift_api_path)
new_file_content = file_content.join("\n")
# compare old file content to potential new file content
api_version = determine_api_version(new_file_content: new_file_content, old_file_content: old_file_content)
old_api_version = find_api_version_string(content: old_file_content)
# if there is a change, we need to write out the new file
if api_version != old_api_version
file_content << autogen_version_warning_text(api_version: api_version)
else
file_content = nil
end
return file_content
end
end
class SwiftActionsAPIGenerator < SwiftAPIGenerator
def initialize(target_output_path: "swift")
@target_filename = "Actions.swift"
@target_output_path = File.expand_path(target_output_path)
@generated_paths = []
super()
# Excludes all actions that aren't external actions (including plugins)
available_external_actions = Fastlane.external_actions || []
available_actions = []
ActionsList.all_actions do |action|
next unless action.respond_to?(:action_name)
available_actions << action.action_name unless available_external_actions.include?(action)
end
self.actions_not_supported = (["import", "import_from_git"] + available_actions).to_set
self.action_options_to_ignore = {}
end
end
class SwiftPluginsAPIGenerator < SwiftAPIGenerator
def initialize(target_output_path: "swift")
@target_filename = "Plugins.swift"
@target_output_path = File.expand_path(target_output_path)
@generated_paths = []
super()
# Gets list of plugin actions
plugin_actions = Fastlane.plugin_manager.plugin_references.values.flat_map do |info|
info[:actions]
end
# Action references from plugins
available_plugins = plugin_actions.map do |plugin_action|
Fastlane::Runner.new.class_reference_from_action_name(plugin_action)
end
# Excludes all actions that aren't pluign actions (including external actions)
available_actions = []
ActionsList.all_actions do |action|
next unless action.respond_to?(:action_name)
available_actions << action.action_name unless available_plugins.include?(action)
end
self.actions_not_supported = (["import", "import_from_git"] + available_actions).to_set
self.action_options_to_ignore = {}
end
end
class SwiftAPIGenerator
DEFAULT_API_VERSION_STRING = "0.9.1"
attr_accessor :tools_option_files
attr_accessor :actions_not_supported
attr_accessor :action_options_to_ignore
attr_accessor :target_output_path
attr_accessor :target_filename
attr_accessor :generated_paths # stores all file names of generated files (as they are generated)
attr_accessor :fastlane_swift_api_path
def initialize
require 'fastlane'
require 'fastlane/documentation/actions_list'
Fastlane.load_actions
# Tools that can be used with <Toolname>file, like Deliverfile, Screengrabfile
# this is important because we need to generate the proper api for these by creating a protocol
# with default implementation we can use in the Fastlane.swift API if people want to use
# <Toolname>file.swift files.
self.tools_option_files = TOOL_CONFIG_FILES.map { |config_file| config_file.downcase.chomp("file") }.to_set
@fastlane_swift_api_path = File.join(@target_output_path, @target_filename)
end
def extend_content(content, tool_details)
return content
end
def generate_swift
self.generated_paths = [] # reset generated paths in case we're called multiple times
file_content = []
file_content << "import Foundation"
tool_details = []
ActionsList.all_actions do |action|
next unless action.respond_to?(:action_name)
next if self.actions_not_supported.include?(action.action_name)
swift_function = process_action(action: action)
if defined?(swift_function.class_name)
tool_details << SwiftToolDetail.new(
command_line_tool_name: action.action_name,
swift_class: swift_function.class_name,
swift_protocol: swift_function.protocol_name
)
end
unless swift_function
next
end
file_content << swift_function.swift_code
end
file_content = extend_content(file_content, tool_details)
if file_content
new_file_content = file_content.join("\n")
File.write(fastlane_swift_api_path, new_file_content)
UI.success(fastlane_swift_api_path)
self.generated_paths << fastlane_swift_api_path
end
default_implementations_path = generate_default_implementations(tool_details: tool_details)
# we might not have any changes, like if it's a hotpatch
self.generated_paths += default_implementations_path if default_implementations_path.length > 0
return self.generated_paths
end
def write_lanefile(lanefile_implementation_opening: nil, class_name: nil, tool_name: nil)
disclaimer = []
disclaimer << "// *bait*" # As we are using a custom common header, we have to bait with a random comment so it does not remove important text.
disclaimer << ""
disclaimer << "// This class is automatically included in FastlaneRunner during build"
disclaimer << ""
disclaimer << "// This autogenerated file will be overwritten or replaced during build time, or when you initialize `#{tool_name}`"
disclaimer << lanefile_implementation_opening
disclaimer << "// If you want to enable `#{tool_name}`, run `fastlane #{tool_name} init`"
disclaimer << "// After, this file will be replaced with a custom implementation that contains values you supplied"
disclaimer << "// during the `init` process, and you won't see this message"
disclaimer << "}"
disclaimer << ""
disclaimer << ""
disclaimer << ""
disclaimer << ""
disclaimer << ""
disclaimer << "// Generated with fastlane #{Fastlane::VERSION}"
disclaimer << ""
file_content = disclaimer.join("\n")
target_path = File.join(@target_output_path, "#{class_name}.swift")
File.write(target_path, file_content)
UI.success(target_path)
return target_path
end
def generate_default_implementations(tool_details: nil)
files_generated = []
tool_details.each do |tool_detail|
header = []
header << "//"
header << "// ** NOTE **"
header << "// This file is provided by fastlane and WILL be overwritten in future updates"
header << "// If you want to add extra functionality to this project, create a new file in a"
header << "// new group so that it won't be marked for upgrade"
header << "//"
header << ""
header << "public class #{tool_detail.swift_class}: #{tool_detail.swift_protocol} {"
lanefile_implementation_opening = header.join("\n")
files_generated << write_lanefile(
lanefile_implementation_opening: lanefile_implementation_opening,
class_name: tool_detail.swift_class,
tool_name: tool_detail.command_line_tool_name
)
end
return files_generated
end
def generate_lanefile_parsing_functions
parsing_functions = 'func parseArray(fromString: String, function: String = #function) -> [String] {
verbose(message: "parsing an Array from data: \(fromString), from function: \(function)")
let potentialArray: String
if fromString.count < 2 {
potentialArray = "[\(fromString)]"
} else {
potentialArray = fromString
}
let array: [String] = try! JSONSerialization.jsonObject(with: potentialArray.data(using: .utf8)!, options: []) as! [String]
return array
}
func parseDictionary(fromString: String, function: String = #function) -> [String : String] {
return parseDictionaryHelper(fromString: fromString, function: function) as! [String: String]
}
func parseDictionary(fromString: String, function: String = #function) -> [String : Any] {
return parseDictionaryHelper(fromString: fromString, function: function)
}
func parseDictionaryHelper(fromString: String, function: String = #function) -> [String : Any] {
verbose(message: "parsing an Array from data: \(fromString), from function: \(function)")
let potentialDictionary: String
if fromString.count < 2 {
verbose(message: "Dictionary value too small: \(fromString), from function: \(function)")
potentialDictionary = "{}"
} else {
potentialDictionary = fromString
}
let dictionary: [String : Any] = try! JSONSerialization.jsonObject(with: potentialDictionary.data(using: .utf8)!, options: []) as! [String : Any]
return dictionary
}
func parseBool(fromString: String, function: String = #function) -> Bool {
verbose(message: "parsing a Bool from data: \(fromString), from function: \(function)")
return NSString(string: fromString.trimmingCharacters(in: .punctuationCharacters)).boolValue
}
func parseInt(fromString: String, function: String = #function) -> Int {
verbose(message: "parsing an Int from data: \(fromString), from function: \(function)")
return NSString(string: fromString.trimmingCharacters(in: .punctuationCharacters)).integerValue
}
'
return parsing_functions
end
def generate_lanefile_tool_objects(classes: nil)
objects = classes.map do |filename|
"public let #{filename.downcase}: #{filename} = #{filename}()"
end
return objects
end
def autogen_version_warning_text(api_version: nil)
warning_text_array = []
warning_text_array << ""
warning_text_array << "// Please don't remove the lines below"
warning_text_array << "// They are used to detect outdated files"
warning_text_array << "// FastlaneRunnerAPIVersion [#{api_version}]"
warning_text_array << ""
return warning_text_array.join("\n")
end
# compares the new file content to the old and figures out what api_version the new content should be
def determine_api_version(new_file_content: nil, old_file_content: nil)
# we know 100% there is a difference, so no need to compare
unless old_file_content.length >= new_file_content.length
old_api_version = find_api_version_string(content: old_file_content)
return DEFAULT_API_VERSION_STRING if old_api_version.nil?
return increment_api_version_string(api_version_string: old_api_version)
end
relevant_old_file_content = old_file_content[0..(new_file_content.length - 1)]
if relevant_old_file_content == new_file_content
# no changes at all, just return the same old api version string
return find_api_version_string(content: old_file_content)
else
# there are differences, so calculate a new api_version_string
old_api_version = find_api_version_string(content: old_file_content)
return DEFAULT_API_VERSION_STRING if old_api_version.nil?
return increment_api_version_string(api_version_string: old_api_version)
end
end
# expects format to be "X.Y.Z" where each value is a number
def increment_api_version_string(api_version_string: nil, increment_by: :patch)
versions = api_version_string.split(".")
major = versions[0].to_i
minor = versions[1].to_i
patch = versions[2].to_i
case increment_by
when :patch
patch += 1
when :minor
minor += 1
patch = 0
when :major
major += 1
minor = 0
patch = 0
end
new_version_string = [major, minor, patch].join(".")
return new_version_string
end
def find_api_version_string(content: nil)
regex = SwiftRunnerUpgrader::API_VERSION_REGEX
matches = content.match(regex)
if matches.length > 0
return matches[1]
else
return nil
end
end
def generate_tool_protocol(tool_swift_function: nil)
protocol_content_array = []
protocol_name = tool_swift_function.protocol_name
protocol_content_array << "public protocol #{protocol_name}: AnyObject {"
protocol_content_array += tool_swift_function.swift_vars
protocol_content_array << "}"
protocol_content_array << ""
protocol_content_array << "public extension #{protocol_name} {"
protocol_content_array += tool_swift_function.swift_default_implementations
protocol_content_array << "}"
protocol_content_array << ""
new_file_content = protocol_content_array.join("\n")
target_path = File.join(@target_output_path, "#{protocol_name}.swift")
old_file_content = ""
# we might have a new file here, unlikely, but possible
if File.exist?(target_path)
old_file_content = File.read(target_path)
end
# compare old file content to potential new file content
api_version = determine_api_version(new_file_content: new_file_content, old_file_content: old_file_content)
old_api_version = find_api_version_string(content: old_file_content)
# we don't need to write this file out because the file versions are exactly the same
return nil if api_version == old_api_version
# use api_version to generate the disclaimer
api_version_disclaimer = autogen_version_warning_text(api_version: api_version)
new_file_content.concat(api_version_disclaimer)
target_path = File.join(@target_output_path, "#{protocol_name}.swift")
File.write(target_path, new_file_content)
UI.success(target_path)
return target_path
end
def ignore_param?(function_name: nil, param_name: nil)
option_set = @action_options_to_ignore[function_name.to_s]
unless option_set
return false
end
return option_set.include?(param_name.to_s)
end
def process_action(action: nil)
options = action.available_options || []
action_name = action.action_name
keys = []
key_descriptions = []
key_default_values = []
key_optionality_values = []
key_type_overrides = []
key_is_strings = []
if options.kind_of?(Array)
options.each do |current|
next unless current.kind_of?(FastlaneCore::ConfigItem)
if ignore_param?(function_name: action_name, param_name: current.key)
next
end
keys << current.key.to_s
key_descriptions << current.description
key_default_values << current.code_gen_default_value
key_optionality_values << current.optional
key_type_overrides << current.data_type
key_is_strings << current.is_string
end
end
action_return_type = action.return_type
if self.tools_option_files.include?(action_name.to_s.downcase)
tool_swift_function = ToolSwiftFunction.new(
action_name: action_name,
action_description: action.description,
action_details: action.details,
keys: keys,
key_descriptions: key_descriptions,
key_default_values: key_default_values,
key_optionality_values: key_optionality_values,
key_type_overrides: key_type_overrides,
key_is_strings: key_is_strings,
return_type: action_return_type,
return_value: action.return_value,
sample_return_value: action.sample_return_value
)
generated_protocol_file_path = generate_tool_protocol(tool_swift_function: tool_swift_function)
self.generated_paths << generated_protocol_file_path unless generated_protocol_file_path.nil?
return tool_swift_function
else
return SwiftFunction.new(
action_name: action_name,
action_description: action.description,
action_details: action.details,
keys: keys,
key_descriptions: key_descriptions,
key_default_values: key_default_values,
key_optionality_values: key_optionality_values,
key_type_overrides: key_type_overrides,
key_is_strings: key_is_strings,
return_type: action_return_type,
return_value: action.return_value,
sample_return_value: action.sample_return_value
)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/shells.rb | fastlane/lib/fastlane/shells.rb | module Fastlane
SHELLS = [
:bash,
:zsh
]
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/tools.rb | fastlane/lib/fastlane/tools.rb | module Fastlane
TOOLS = [
:fastlane,
:pilot,
:spaceship,
:produce,
:deliver,
:frameit,
:pem,
:snapshot,
:screengrab,
:supply,
:cert,
:sigh,
:match,
:scan,
:gym,
:precheck,
:trainer
]
# a list of all the config files we currently expect
TOOL_CONFIG_FILES = [
"Appfile",
"Deliverfile",
"Fastfile",
"Gymfile",
"Matchfile",
"Precheckfile",
"Scanfile",
"Screengrabfile",
"Snapshotfile"
]
TOOL_ALIASES = {
"get_certificates": "cert",
"upload_to_app_store": "deliver",
"frame_screenshots": "frameit",
"build_app": "gym",
"build_ios_app": "gym",
"build_mac_app": "gym",
"sync_code_signing": "match",
"get_push_certificate": "pem",
"check_app_store_metadata": "precheck",
"capture_android_screenshots": "screengrab",
"get_provisioning_profile": "sigh",
"capture_ios_screenshots": "snapshot",
"upload_to_play_store": "supply"
}
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/swift_runner_upgrader.rb | fastlane/lib/fastlane/swift_runner_upgrader.rb | require 'xcodeproj'
require 'fileutils'
module Fastlane
# current logic:
# - find all groups in existing project
# -- if a group is missing, add it
# --- add all files for group into new group, build target, and compile phase
# - iterate through existing groups
# -- update all files needing updating
# - iterate through existing groups
# -- if a file from the manifest is new, add it to group, build target, and compile phase
# - Save and return true if any action was taken to modify any file (project included)
# build project
class SwiftRunnerUpgrader
API_VERSION_REGEX = /FastlaneRunnerAPIVersion\s*\[\s*([0-9]+.[0-9]+.[0-9]+)\s*\]/ # also used by SwiftFastlaneAPIGenerator
attr_accessor :target_project # project we'll be updating
attr_accessor :fastlane_runner_target # FastlaneRunner xcodeproj target
attr_accessor :manifest_hash # hash of file names to group names they belong to
attr_accessor :manifest_groups # unique list of group names that came from the manifest
attr_accessor :target_swift_code_file_folder_path # location in filesystem where all swift files should exist when we're done
attr_accessor :source_swift_code_file_folder_path # source location of where we're copying file from during the upgrade process
RELATIVE_SOURCE_FILE_PATH = "../"
def initialize
@source_swift_code_file_folder_path = File.expand_path(File.join(Fastlane::ROOT, "/swift"))
@target_swift_code_file_folder_path = FastlaneCore::FastlaneFolder.swift_folder_path
Fastlane::Setup.setup_swift_support
manifest_file = File.join(@source_swift_code_file_folder_path, "/upgrade_manifest.json")
UI.success("loading manifest: #{manifest_file}")
@manifest_hash = JSON.parse(File.read(manifest_file))
@manifest_groups = @manifest_hash.values.uniq
runner_project_path = FastlaneCore::FastlaneFolder.swift_runner_project_path
@target_project = Xcodeproj::Project.open(runner_project_path)
@root_group = @target_project.groups.select { |group| group.name == "Fastlane Runner" }.first
@fastlane_runner_target = @target_project.targets.select { |target| target.name == "FastlaneRunner" }.first
end
def upgrade_if_needed!(dry_run: false)
upgraded = add_missing_flags!(dry_run: dry_run)
upgraded = add_missing_copy_phase!(dry_run: dry_run) || upgraded
upgraded = add_missing_groups_and_files!(dry_run: dry_run) || upgraded
upgraded = upgrade_files!(dry_run: dry_run) || upgraded
upgraded = add_new_files_to_groups! || upgraded
UI.verbose("FastlaneRunner project has been updated and can be written back to disk") if upgraded
unless dry_run
UI.verbose("FastlaneRunner project changes have been stored") if upgraded
target_project.save if upgraded
end
return upgraded
end
def upgrade_files!(dry_run: false)
upgraded_anything = false
self.manifest_hash.each do |filename, group|
upgraded_anything = copy_file_if_needed!(filename: filename, dry_run: dry_run) || upgraded_anything
end
return upgraded_anything
end
def find_missing_groups
missing_groups = []
existing_group_names_set = @root_group.groups.map { |group| group.name.downcase }.to_set
self.manifest_groups.each do |group_name|
unless existing_group_names_set.include?(group_name.downcase)
missing_groups << group_name
end
end
return missing_groups
end
# compares source file against the target file's FastlaneRunnerAPIVersion and returned `true` if there is a difference
def file_needs_update?(filename: nil)
# looking for something like: FastlaneRunnerAPIVersion [0.9.1]
regex_to_use = API_VERSION_REGEX
source = File.join(self.source_swift_code_file_folder_path, "/#{filename}")
target = File.join(self.target_swift_code_file_folder_path, "/#{filename}")
# target doesn't have the file yet, so ya, I'd say it needs to be updated
return true unless File.exist?(target)
source_file_content = File.read(source)
target_file_content = File.read(target)
# ignore if files don't contain FastlaneRunnerAPIVersion
return false unless source_file_content.include?("FastlaneRunnerAPIVersion")
return false unless target_file_content.include?("FastlaneRunnerAPIVersion")
bundled_version = source_file_content.match(regex_to_use)[1]
target_version = target_file_content.match(regex_to_use)[1]
file_versions_are_different = bundled_version != target_version
UI.verbose("#{filename} FastlaneRunnerAPIVersion (bundled/target): #{bundled_version}/#{target_version}")
files_are_different = source_file_content != target_file_content
if files_are_different && !file_versions_are_different
UI.verbose("File versions are the same, but the two files are not equal, so that's a problem, setting needs update to 'true'")
end
needs_update = file_versions_are_different || files_are_different
return needs_update
end
# currently just copies file, even if not needed.
def copy_file_if_needed!(filename: nil, dry_run: false)
needs_update = file_needs_update?(filename: filename)
UI.verbose("file #{filename} needs an update") if needs_update
# Ok, we know if this file needs an update, can return now if it's a dry run
return needs_update if dry_run
unless needs_update
# no work needed, just return
return false
end
source = File.join(self.source_swift_code_file_folder_path, "/#{filename}")
target = File.join(self.target_swift_code_file_folder_path, "/#{filename}")
FileUtils.cp(source, target)
UI.verbose("Copied #{source} to #{target}")
return true
end
def add_new_files_to_groups!
inverted_hash = {}
# need {group => [file1, file2, etc..]} instead of: {file1 => group, file2 => group, etc...}
self.manifest_hash.each do |filename, group_name|
group_name = group_name.downcase
files_in_group = inverted_hash[group_name]
if files_in_group.nil?
files_in_group = []
inverted_hash[group_name] = files_in_group
end
files_in_group << filename
end
# this helps us signal to the user that we made changes
updated_project = false
# iterate through the groups and collect all the swift files in each
@root_group.groups.each do |group|
# current group's filenames
existing_group_files_set = group.files
.select { |file| !file.name.nil? && file.name.end_with?(".swift") }
.map(&:name)
.to_set
group_name = group.name.downcase
manifest_group_filenames = inverted_hash[group_name]
# compare the current group files to what the manifest says should minimally be there
manifest_group_filenames.each do |filename|
# current group is missing a file from the manifest, need to add it
next if existing_group_files_set.include?(filename)
UI.verbose("Adding new file #{filename} to group: `#{group.name}`")
new_file_reference = group.new_file("#{RELATIVE_SOURCE_FILE_PATH}#{filename}")
# add references to the target, and make sure they are added to the build phase to
self.fastlane_runner_target.source_build_phase.add_file_reference(new_file_reference)
updated_project = true
end
end
return updated_project
end
# adds new groups, and the files inside those groups
# Note: this does not add new files to existing groups, that is in add_new_files_to_groups!
def add_missing_groups_and_files!(dry_run: false)
missing_groups = self.find_missing_groups.to_set
unless missing_groups.length > 0
UI.verbose("No missing groups found, so we don't need to worry about adding new groups")
return false
end
# well, we know we have some changes to make, so if this is a dry run,
# don't bother doing anything and just return true
return true if dry_run
missing_groups.each do |missing_group_name|
new_group = @root_group.new_group(missing_group_name)
# find every file in the manifest that belongs to the new group, and add it to the new group
self.manifest_hash.each do |filename, group|
next unless group.casecmp(missing_group_name.downcase).zero?
# assumes this is a new file, we don't handle moving files between groups
new_file_reference = new_group.new_file("#{RELATIVE_SOURCE_FILE_PATH}#{filename}")
# add references to the target, and make sure they are added to the build phase to
self.fastlane_runner_target.source_build_phase.add_file_reference(new_file_reference)
end
end
return true # yup, we definitely updated groups
end
# adds build_settings flags to fastlane_runner_target
def add_missing_flags!(dry_run: false)
# Check if upgrade is needed
# If fastlane build settings exists already, we don't need any more changes to the Xcode project
self.fastlane_runner_target.build_configurations.each { |config|
return true if dry_run && config.build_settings["CODE_SIGN_IDENTITY"].nil?
return true if dry_run && config.build_settings["MACOSX_DEPLOYMENT_TARGET"].nil?
}
return false if dry_run
# Proceed to upgrade
self.fastlane_runner_target.build_configurations.each { |config|
config.build_settings["CODE_SIGN_IDENTITY"] = "-"
config.build_settings["MACOSX_DEPLOYMENT_TARGET"] = "10.12"
}
target_project.save
end
# adds new copy files build phase to fastlane_runner_target
def add_missing_copy_phase!(dry_run: false)
# Check if upgrade is needed
# Check if Copy Files build phase contains FastlaneRunner target.
phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.map(&:files).flatten.select { |file| file.display_name == "FastlaneRunner" }.first
# If fastlane copy files build phase exists already, we don't need any more changes to the Xcode project
phase_copy_sign = self.fastlane_runner_target.copy_files_build_phases.select { |phase_copy| phase_copy.name == "FastlaneRunnerCopySigned" }.first unless phase_copy_sign
return true if dry_run && phase_copy_sign.nil?
return false if dry_run
# Proceed to upgrade
old_phase_copy_sign = self.fastlane_runner_target.shell_script_build_phases.select { |phase_copy| phase_copy.shell_script == "cd \"${SRCROOT}\"\ncd ../..\ncp \"${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}\" .\n" }.first
old_phase_copy_sign.remove_from_project unless old_phase_copy_sign.nil?
unless phase_copy_sign
# Create a copy files build phase
phase_copy_sign = self.fastlane_runner_target.new_copy_files_build_phase("FastlaneRunnerCopySigned")
phase_copy_sign.dst_path = "$SRCROOT/../.."
phase_copy_sign.dst_subfolder_spec = "0"
phase_copy_sign.run_only_for_deployment_postprocessing = "0"
targetBinaryReference = self.fastlane_runner_target.product_reference
phase_copy_sign.add_file_reference(targetBinaryReference)
# Set "Code sign on copy" flag on Xcode for fastlane_runner_target
targetBinaryReference.build_files.each { |target_binary_build_file_reference|
target_binary_build_file_reference.settings = { "ATTRIBUTES": ["CodeSignOnCopy"] }
}
end
target_project.save
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/new_action.rb | fastlane/lib/fastlane/new_action.rb | module Fastlane
# Guides the new user through creating a new action
module NewAction
def self.run(new_action_name: nil)
name = new_action_name && check_action_name_from_args(new_action_name) ? new_action_name : fetch_name
generate_action(name)
end
def self.fetch_name
puts("Must be lowercase, and use a '_' between words. Do not use '.'".green)
puts("examples: 'testflight', 'upload_to_s3'".green)
name = UI.input("Name of your action: ")
until name_valid?(name)
puts("Name is invalid. Please ensure the name is all lowercase, free of spaces and without special characters! Try again.")
name = UI.input("Name of your action: ")
end
name
end
def self.generate_action(name)
template = File.read("#{Fastlane::ROOT}/lib/assets/custom_action_template.rb")
template.gsub!('[[NAME]]', name)
template.gsub!('[[NAME_UP]]', name.upcase)
template.gsub!('[[NAME_CLASS]]', name.fastlane_class + 'Action')
actions_path = File.join((FastlaneCore::FastlaneFolder.path || Dir.pwd), 'actions')
FileUtils.mkdir_p(actions_path) unless File.directory?(actions_path)
path = File.join(actions_path, "#{name}.rb")
File.write(path, template)
UI.success("Created new action file '#{path}'. Edit it to implement your custom action.")
end
def self.check_action_name_from_args(new_action_name)
if name_valid?(new_action_name)
new_action_name
else
puts("Name is invalid. Please ensure the name is all lowercase, free of spaces and without special characters! Try again.")
end
end
def self.name_valid?(name)
name =~ /^[a-z0-9_]+$/
end
private_class_method :name_valid?
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/supported_platforms.rb | fastlane/lib/fastlane/supported_platforms.rb | module Fastlane
class SupportedPlatforms
class << self
attr_accessor :extra
attr_reader :default
def extra=(value)
value ||= []
UI.important("Setting '#{value}' as extra SupportedPlatforms")
@extra = value
end
end
@default = [:ios, :mac, :android]
@extra = []
def self.all
(@default + @extra).flatten
end
# this will log a warning if the passed platform is not supported
def self.verify!(platform)
unless all.include?(platform.to_s.to_sym)
UI.important("Platform '#{platform}' is not officially supported. Currently supported platforms are #{self.all}.")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/erb_template_helper.rb | fastlane/lib/fastlane/erb_template_helper.rb | require 'ostruct'
module Fastlane
class ErbTemplateHelper
require "erb"
def self.load(template_name)
path = "#{Fastlane::ROOT}/lib/assets/#{template_name}.erb"
load_from_path(path)
end
def self.load_from_path(template_filepath)
unless File.exist?(template_filepath)
UI.user_error!("Could not find template at path '#{template_filepath}'")
end
File.read(template_filepath)
end
def self.render(template, template_vars_hash, trim_mode = nil)
Fastlane::ErbalT.new(template_vars_hash, trim_mode).render(template)
end
end
class ErbalT < OpenStruct
def initialize(hash, trim_mode = nil)
super(hash)
@trim_mode = trim_mode
end
def render(template)
# From Ruby 2.6, ERB.new takes keyword arguments and positional ones are deprecated
# https://bugs.ruby-lang.org/issues/14256
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
ERB.new(template, trim_mode: @trim_mode).result(binding)
else
ERB.new(template, nil, @trim_mode).result(binding)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/lane.rb | fastlane/lib/fastlane/lane.rb | module Fastlane
# Represents a lane
class Lane
attr_accessor :platform
attr_accessor :name
# @return [Array] An array containing the description of this lane
# Each item of the array is one line
attr_accessor :description
attr_accessor :block
# @return [Boolean] Is that a private lane that can't be called from the CLI?
attr_accessor :is_private
def initialize(platform: nil, name: nil, description: nil, block: nil, is_private: false)
UI.user_error!("description must be an array") unless description.kind_of?(Array)
UI.user_error!("lane name must not contain any spaces") if name.to_s.include?(" ")
UI.user_error!("lane name must start with :") unless name.kind_of?(Symbol)
self.class.verify_lane_name(name)
self.platform = platform
self.name = name
self.description = description
# We want to support _both_ lanes expecting a `Hash` (like `lane :foo do |options|`), and lanes expecting
# keyword parameters (like `lane :foo do |param1:, param2:, param3: 'default value'|`)
block_expects_keywords = !block.nil? && block.parameters.any? { |type, _| [:key, :keyreq].include?(type) }
# Conversion of the `Hash` parameters (passed by `Lane#call`) into keywords has to be explicit in Ruby 3
# https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
self.block = block_expects_keywords ? proc { |options| block.call(**options) } : block
self.is_private = is_private
end
# Execute this lane
#
# @param [Hash] parameters The Hash of parameters to pass to the lane
#
def call(parameters)
block.call(parameters || {})
end
# @return [String] The lane + name of the lane. If there is no platform, it will only be the lane name
def pretty_name
[platform, name].reject(&:nil?).join(' ')
end
class << self
# Makes sure the lane name is valid
def verify_lane_name(name)
if self.deny_list.include?(name.to_s)
UI.error("Lane name '#{name}' is invalid! Invalid names are #{self.deny_list.join(', ')}.")
UI.user_error!("Lane name '#{name}' is invalid")
end
if self.gray_list.include?(name.to_sym)
UI.error("------------------------------------------------")
UI.error("Lane name '#{name}' should not be used because it is the name of a fastlane tool")
UI.error("It is recommended to not use '#{name}' as the name of your lane")
UI.error("------------------------------------------------")
# We still allow it, because we're nice
# Otherwise we might break existing setups
return
end
self.ensure_name_not_conflicts(name.to_s)
end
def deny_list
%w(
run
init
new_action
lanes
list
docs
action
actions
enable_auto_complete
new_plugin
add_plugin
install_plugins
update_plugins
search_plugins
help
env
update_fastlane
)
end
def gray_list
Fastlane::TOOLS
end
def ensure_name_not_conflicts(name)
# First, check if there is a predefined method in the actions folder
return unless Actions.action_class_ref(name)
UI.error("------------------------------------------------")
UI.error("Name of the lane '#{name}' is already taken by the action named '#{name}'")
UI.error("------------------------------------------------")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/lane_manager_base.rb | fastlane/lib/fastlane/lane_manager_base.rb | module Fastlane
# Base class for all LaneManager classes
# Takes care of all common things like printing the lane description tables and loading .env files
class LaneManagerBase
def self.skip_docs?
Helper.test? || FastlaneCore::Env.truthy?("FASTLANE_SKIP_DOCS")
end
# All the finishing up that needs to be done
def self.finish_fastlane(ff, duration, error, skip_message: false)
# Sometimes we don't have a fastfile because we're using Fastfile.swift
unless ff.nil?
ff.runner.did_finish
end
# Finished with all the lanes
Fastlane::JUnitGenerator.generate(Fastlane::Actions.executed_actions)
print_table(Fastlane::Actions.executed_actions)
Fastlane::PluginUpdateManager.show_update_status
if error
UI.error('fastlane finished with errors') unless skip_message
raise error
elsif duration > 5
UI.success("fastlane.tools just saved you #{duration} minutes! ๐") unless skip_message
else
UI.success('fastlane.tools finished successfully ๐') unless skip_message
end
end
# Print a table as summary of the executed actions
def self.print_table(actions)
return if actions.count == 0
return if FastlaneCore::Env.truthy?('FASTLANE_SKIP_ACTION_SUMMARY') # User disabled table output
require 'terminal-table'
rows = []
actions.each_with_index do |current, i|
is_error_step = !current[:error].to_s.empty?
name = current[:name][0..60]
name = name.red if is_error_step
index = i + 1
index = "๐ฅ" if is_error_step
rows << [index, name, current[:time].to_i]
end
puts("")
puts(Terminal::Table.new(
title: "fastlane summary".green,
headings: ["Step", "Action", "Time (in s)"],
rows: FastlaneCore::PrintTable.transform_output(rows)
))
puts("")
end
def self.print_lane_context
return if Actions.lane_context.empty?
if FastlaneCore::Globals.verbose?
UI.important('Lane Context:'.yellow)
UI.message(Actions.lane_context)
return
end
# Print a nice table unless in FastlaneCore::Globals.verbose? mode
rows = Actions.lane_context.collect do |key, content|
[key, content.to_s]
end
require 'terminal-table'
puts(Terminal::Table.new({
title: "Lane Context".yellow,
rows: FastlaneCore::PrintTable.transform_output(rows)
}))
end
def self.print_error_line(ex)
lines = ex.backtrace_locations&.select { |loc| loc.path == 'Fastfile' }&.map(&:lineno)
return if lines.nil? || lines.empty?
fastfile_content = File.read(FastlaneCore::FastlaneFolder.fastfile_path, encoding: "utf-8")
if ex.backtrace_locations.first&.path == 'Fastfile'
# If exception happened directly in the Fastfile itself (e.g. ArgumentError)
UI.error("Error in your Fastfile at line #{lines.first}")
UI.content_error(fastfile_content, lines.first)
lines.shift
end
unless lines.empty?
# If exception happened directly in the Fastfile, also print the caller (still from the Fastfile).
# If exception happened in _fastlane_ internal code, print the line from the Fastfile that called it
UI.error("Called from Fastfile at line #{lines.first}")
UI.content_error(fastfile_content, lines.first)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/lane_list.rb | fastlane/lib/fastlane/lane_list.rb | module Fastlane
class LaneList
# Print out the result of `generate`
SWIFT_FUNCTION_REGEX = /\s*func\s*(\w*)\s*\((.*)\)\s*/
SWIFT_DESC_REGEX = /\s*desc\s*\(\s*"(.*)"\s*\)\s*/
def self.output(path)
puts(generate(path))
puts("Execute using `fastlane [lane_name]`".yellow)
end
def self.generate_swift_lanes(path)
return unless (path || '').length > 0
UI.user_error!("Could not find Fastfile.swift at path '#{path}'") unless File.exist?(path)
path = File.expand_path(path)
lane_content = File.read(path)
current_lane_name = nil
lanes_by_name = {}
lane_content.split("\n").reject(&:empty?).each do |line|
line.strip!
if line.start_with?("func") && (current_lane_name = self.lane_name_from_swift_line(potential_lane_line: line))
lanes_by_name[current_lane_name] = Fastlane::Lane.new(platform: nil, name: current_lane_name.to_sym, description: [])
elsif line.start_with?("desc")
lane_description = self.desc_entry_for_swift_lane(named: current_lane_name, potential_desc_line: line)
unless lane_description
next
end
lanes_by_name[current_lane_name].description = [lane_description]
current_lane_name = nil
end
end
# "" because that will be interpreted as general platform
# (we don't detect platform right now)
return { "" => lanes_by_name }
end
def self.desc_entry_for_swift_lane(named: nil, potential_desc_line: nil)
unless named
return nil
end
desc_match = SWIFT_DESC_REGEX.match(potential_desc_line)
unless desc_match
return nil
end
return desc_match[1]
end
def self.lane_name_from_swift_line(potential_lane_line: nil)
function_name_match = SWIFT_FUNCTION_REGEX.match(potential_lane_line)
unless function_name_match
return nil
end
unless function_name_match[1].downcase.end_with?("lane")
return nil
end
return function_name_match[1]
end
def self.generate(path)
lanes = {}
if FastlaneCore::FastlaneFolder.swift?
lanes = generate_swift_lanes(path)
else
ff = Fastlane::FastFile.new(path)
lanes = ff.runner.lanes
end
output = ""
all_keys = lanes.keys.reject(&:nil?)
all_keys.unshift(nil) # because we want root elements on top. always! They have key nil
all_keys.each do |platform|
next if (lanes[platform] || []).count == 0
plat_text = platform
plat_text = "general" if platform.to_s.empty?
output += "\n--------- #{plat_text}---------\n".yellow
value = lanes[platform]
next unless value
value.each do |lane_name, lane|
next if lane.is_private
output += "----- fastlane #{lane.pretty_name}".green
if lane.description.count > 0
output += "\n" + lane.description.join("\n") + "\n\n"
else
output += "\n\n"
end
end
end
output
end
def self.output_json(path)
puts(JSON.pretty_generate(self.generate_json(path)))
end
# Returns a hash
def self.generate_json(path)
output = {}
return output if path.nil?
ff = Fastlane::FastFile.new(path)
all_keys = ff.runner.lanes.keys
all_keys.each do |platform|
next if (ff.runner.lanes[platform] || []).count == 0
output[platform] ||= {}
value = ff.runner.lanes[platform]
next unless value
value.each do |lane_name, lane|
next if lane.is_private
output[platform][lane_name] = {
description: lane.description.join("\n")
}
end
end
return output
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.