Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isadon committed Mar 6, 2021
1 parent 0c2df91 commit ac6549e
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions spec/update_changelog_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
expect(read_result).to eq(post_update_read_result)
end

it 'updates [Unreleased] section identifier without appending date' do
# Update [Unreleased] section identifier with new one
it 'updates [Unreleased] section identifier without appending a date' do
# Update [Unreleased] section identifier with new one - explicitly ask to not use a date.
Fastlane::FastFile.new.parse("lane :test do
update_changelog(changelog_path: '#{changelog_mock_path}',
updated_section_identifier: '#{updated_section_identifier}',
append_date: false)
append_datetime_format: nil)
end").runner.execute(:test)

# Read updated section line
Expand All @@ -80,12 +80,35 @@
expect(modifiedSectionLine).to eq("## [12.34.56]\n")
end

it 'updates [Unreleased] section identifier with appending date' do
# Update [Unreleased] section identifier with new one
it 'updates [Unreleased] section identifier appending a date via the default datetime format' do
# Update [Unreleased] section identifier with new one via the default datetime format
Fastlane::FastFile.new.parse("lane :test do
update_changelog(changelog_path: '#{changelog_mock_path}',
updated_section_identifier: '#{updated_section_identifier}')
end").runner.execute(:test)

# Read updated section line
modifiedSectionLine = ""
File.open(changelog_mock_path_hook, "r") do |file|
file.each_line do |line|
if line =~ /\#{2}\s?\[#{updated_section_identifier}\]/
modifiedSectionLine = line
break
end
end
end

# Expect the modified section line to be with current date
now = Time.now.utc.strftime("%FZ")
expect(modifiedSectionLine).to eq("## [12.34.56] - #{now}\n")
end

it 'updates [Unreleased] section identifier appending a date via a user specified datetime format' do
# Update [Unreleased] section identifier with new one via the user specified datetime format
Fastlane::FastFile.new.parse("lane :test do
update_changelog(changelog_path: '#{changelog_mock_path}',
updated_section_identifier: '#{updated_section_identifier}',
append_date: true)
append_datetime_format: '%FT:%TZ')
end").runner.execute(:test)

# Read updated section line
Expand All @@ -100,7 +123,7 @@
end

# Expect the modified section line to be with current date
now = Time.now.strftime("%Y-%m-%d")
now = Time.now.utc.strftime("%FT:%TZ")
expect(modifiedSectionLine).to eq("## [12.34.56] - #{now}\n")
end
end
Expand Down

0 comments on commit ac6549e

Please sign in to comment.