Skip to content

Commit 711e7f7

Browse files
authored
Add a spec for the ios_update_metadata_source action (#352)
2 parents 9769c59 + fb7f954 commit 711e7f7

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'fastlane/action'
21
require_relative '../../helper/metadata_update_helper'
32

43
module Fastlane
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'spec_helper'
2+
require 'shared_examples_for_update_metadata_source_action'
3+
4+
describe Fastlane::Actions::IosUpdateMetadataSourceAction do
5+
before do
6+
# This works around the `ensure_git_status_clean` call within the action.
7+
#
8+
# We can't easily remove the need to stub the call here without removing the check in the action.
9+
# In the tests, we move into a temp folder, but then create files in that directory.
10+
# So, `ensure_git_status_clean` will fail anyway, unless we add more cruft to the tests.
11+
#
12+
# See also conversation in
13+
# https://github.com/wordpress-mobile/release-toolkit/pull/352
14+
allow(Fastlane::Actions::EnsureGitStatusCleanAction).to receive(:run)
15+
end
16+
17+
include_examples 'update_metadata_source_action', whats_new_fails: false
18+
end

spec/shared_examples_for_update_metadata_source_action.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.shared_examples 'update_metadata_source_action' do |options|
44
it 'updates any block in a given .po file with the values from the given sources' do
5-
Dir.mktmpdir do |dir|
5+
in_tmp_dir do |dir|
66
output_path = File.join(dir, 'output.po')
77
dummy_text = <<~PO
88
msgctxt "key1"
@@ -45,7 +45,7 @@
4545
it 'combines the given `release_version` and `whats_new` parameter into a new block' do
4646
pending 'this currently fails; in the long run, we might consolidate `whats_new` with `release_notes`' if options[:whats_new_fails]
4747

48-
Dir.mktmpdir do |dir|
48+
in_tmp_dir do |dir|
4949
output_path = File.join(dir, 'output.po')
5050
dummy_text = <<~PO
5151
msgctxt "v1.0-whats-new"
@@ -80,7 +80,7 @@
8080
it 'adds entries passed as input even if not part of the original `.po` file' do
8181
pending 'this currently fails and will be addressed as part of the upcoming refactor/rewrite of the functionality'
8282

83-
Dir.mktmpdir do |dir|
83+
in_tmp_dir do |dir|
8484
output_path = File.join(dir, 'output.po')
8585
dummy_text = <<~PO
8686
msgctxt "key1"
@@ -119,7 +119,7 @@
119119
end
120120

121121
it 'combines the given `release_version` and `release_notes` in a new block, keeps the n-1 ones, and deletes the others' do
122-
Dir.mktmpdir do |dir|
122+
in_tmp_dir do |dir|
123123
output_path = File.join(dir, 'output.po')
124124
dummy_text = <<~PO
125125
msgctxt "release_note_0122"

0 commit comments

Comments
 (0)