diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..83e16f8 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/Gemfile.lock b/Gemfile.lock index c09bdfa..59227c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,6 +20,7 @@ GEM highline (~> 1.7.2) declarative (0.0.10) declarative-option (0.1.0) + diff-lcs (1.3) digest-crc (0.4.1) domain_name (0.5.20180417) unf (>= 0.0.5, < 1.0.0) @@ -121,6 +122,19 @@ GEM uber (< 0.2.0) retriable (3.1.2) rouge (2.0.7) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.4) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) rubyzip (1.2.2) security (0.1.3) signet (0.11.0) @@ -161,6 +175,7 @@ PLATFORMS DEPENDENCIES icon-banner! + rspec (~> 3.4.0) BUNDLED WITH 1.16.4 diff --git a/icon-banner.gemspec b/icon-banner.gemspec index 7e47dd7..ad0c150 100644 --- a/icon-banner.gemspec +++ b/icon-banner.gemspec @@ -20,4 +20,6 @@ Gem::Specification.new do |spec| spec.add_dependency 'fastlane', '>= 2.100.0' spec.add_dependency 'mini_magick', '>= 4.5.1' + + spec.add_development_dependency 'rspec', '~> 3.4.0' end diff --git a/spec/Reference/facetime_Daily.png b/spec/Reference/facetime_Daily.png new file mode 100644 index 0000000..cbc98b1 Binary files /dev/null and b/spec/Reference/facetime_Daily.png differ diff --git a/spec/Reference/facetime_Production.png b/spec/Reference/facetime_Production.png new file mode 100644 index 0000000..e500337 Binary files /dev/null and b/spec/Reference/facetime_Production.png differ diff --git a/spec/Reference/facetime_QA.png b/spec/Reference/facetime_QA.png new file mode 100644 index 0000000..5ee396e Binary files /dev/null and b/spec/Reference/facetime_QA.png differ diff --git a/spec/Reference/facetime_Staging.png b/spec/Reference/facetime_Staging.png new file mode 100644 index 0000000..715a03e Binary files /dev/null and b/spec/Reference/facetime_Staging.png differ diff --git a/spec/Reference/ibooks_Daily.png b/spec/Reference/ibooks_Daily.png new file mode 100644 index 0000000..a323014 Binary files /dev/null and b/spec/Reference/ibooks_Daily.png differ diff --git a/spec/Reference/ibooks_Production.png b/spec/Reference/ibooks_Production.png new file mode 100644 index 0000000..0530044 Binary files /dev/null and b/spec/Reference/ibooks_Production.png differ diff --git a/spec/Reference/ibooks_QA.png b/spec/Reference/ibooks_QA.png new file mode 100644 index 0000000..44629cf Binary files /dev/null and b/spec/Reference/ibooks_QA.png differ diff --git a/spec/Reference/ibooks_Staging.png b/spec/Reference/ibooks_Staging.png new file mode 100644 index 0000000..5b3b710 Binary files /dev/null and b/spec/Reference/ibooks_Staging.png differ diff --git a/spec/Reference/podcasts_Daily.png b/spec/Reference/podcasts_Daily.png new file mode 100644 index 0000000..638d057 Binary files /dev/null and b/spec/Reference/podcasts_Daily.png differ diff --git a/spec/Reference/podcasts_Production.png b/spec/Reference/podcasts_Production.png new file mode 100644 index 0000000..34cb531 Binary files /dev/null and b/spec/Reference/podcasts_Production.png differ diff --git a/spec/Reference/podcasts_QA.png b/spec/Reference/podcasts_QA.png new file mode 100644 index 0000000..ae745e2 Binary files /dev/null and b/spec/Reference/podcasts_QA.png differ diff --git a/spec/Reference/podcasts_Staging.png b/spec/Reference/podcasts_Staging.png new file mode 100644 index 0000000..18b5006 Binary files /dev/null and b/spec/Reference/podcasts_Staging.png differ diff --git a/spec/Reference/testflight_Daily.png b/spec/Reference/testflight_Daily.png new file mode 100644 index 0000000..cbc5790 Binary files /dev/null and b/spec/Reference/testflight_Daily.png differ diff --git a/spec/Reference/testflight_Production.png b/spec/Reference/testflight_Production.png new file mode 100644 index 0000000..a2466d3 Binary files /dev/null and b/spec/Reference/testflight_Production.png differ diff --git a/spec/Reference/testflight_QA.png b/spec/Reference/testflight_QA.png new file mode 100644 index 0000000..55cb9ec Binary files /dev/null and b/spec/Reference/testflight_QA.png differ diff --git a/spec/Reference/testflight_Staging.png b/spec/Reference/testflight_Staging.png new file mode 100644 index 0000000..845fa84 Binary files /dev/null and b/spec/Reference/testflight_Staging.png differ diff --git a/spec/Sample.appiconset/facetime.png b/spec/Sample.appiconset/facetime.png new file mode 100644 index 0000000..8c08f5f Binary files /dev/null and b/spec/Sample.appiconset/facetime.png differ diff --git a/spec/Sample.appiconset/ibooks.png b/spec/Sample.appiconset/ibooks.png new file mode 100644 index 0000000..4376859 Binary files /dev/null and b/spec/Sample.appiconset/ibooks.png differ diff --git a/spec/Sample.appiconset/podcasts.png b/spec/Sample.appiconset/podcasts.png new file mode 100644 index 0000000..4df18e3 Binary files /dev/null and b/spec/Sample.appiconset/podcasts.png differ diff --git a/spec/Sample.appiconset/testflight.png b/spec/Sample.appiconset/testflight.png new file mode 100644 index 0000000..ed60ebc Binary files /dev/null and b/spec/Sample.appiconset/testflight.png differ diff --git a/spec/appiconset_spec.rb b/spec/appiconset_spec.rb new file mode 100644 index 0000000..8c7037d --- /dev/null +++ b/spec/appiconset_spec.rb @@ -0,0 +1,50 @@ +require 'icon_banner' +require 'icon_banner/appiconset' +require 'mini_magick' + +RSpec.describe IconBanner::AppIconSet do + REFERENCE_ICONSET = 'Reference' + SAMPLE_ICONSET = 'Sample.appiconset' + LABELS = %w{Daily QA Staging Production} + + it 'test icons' do + app_icon_set = IconBanner::AppIconSet.new + path = current_path + options = FastlaneCore::Configuration.create(IconBanner::IconBanner.available_options, Hash.new) + + app_icon_set.restore path # just make sure + + expect(options[:backup]).to be_truthy + + icons = Dir.glob(File.join(icon_path, '*.{png,PNG}')) + + LABELS.each do |label| + options[:label] = label + app_icon_set.generate path, options + + icons.each do |icon| + reference = icon.sub(SAMPLE_ICONSET, REFERENCE_ICONSET) + .sub('.png', "_#{label}.png") + + begin + compare = `compare -metric PSNR #{icon} #{reference} NULL: 2>&1` + expect(compare).to eq('inf') + end + # To regenerate images, replace this block with: + #begin + # FileUtils.copy icon, reference + #end + end + + app_icon_set.restore path + end + end + + def current_path + File.dirname __FILE__ + end + + def icon_path + File.join current_path, SAMPLE_ICONSET + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..106dd0c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,3 @@ +RSpec.configure do |config| + config.fail_fast = false +end