forked from diaspora/diaspora
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cucumber feature for taking screenshots of important pages
- for before/after comparisons, including rake tasks for easily generating the images from command line
- Loading branch information
Showing
8 changed files
with
167 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
<% | ||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | ||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" | ||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" | ||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | ||
format = ENV['CUCUMBER_FORMAT'] || 'pretty' | ||
# option lists for the `cucumber` command | ||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{format} features" : "--format #{format} #{rerun}" | ||
std_opts = "--format #{format} --strict --tags ~@wip --tags ~@screenshots" | ||
screenshot_opts = "--require features --format pretty" | ||
%> | ||
|
||
# 'normal' test runs | ||
default: <%= std_opts %> -r features | ||
wip: -r features --tags @wip:3 --wip features | ||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip | ||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip --tags ~@screenshots | ||
|
||
# screenshot feature | ||
ref_screens: "<%= screenshot_opts %> --tags @reference-screenshots" | ||
cmp_screens: "<%= screenshot_opts %> --tags @comparison-screenshots" | ||
all_screens: "<%= screenshot_opts %> --tags @screenshots" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@screenshots @javascript | ||
Feature: layout reference screenshots | ||
In order to be able to compare style and layout changes | ||
As a developer | ||
I want to be able to look at before/after screenshots | ||
|
||
Background: | ||
Given following users exist: | ||
| username | email | | ||
| B Robertson | bob@bob.bob | | ||
| A Aronsdottir | alice@alice.alice | | ||
And a user with email "[email protected]" is connected with "[email protected]" | ||
And "[email protected]" has a public post with text "this is a test post!" | ||
And Alice has a post mentioning Bob | ||
And "[email protected]" has a public post with text "i am using a #tag" | ||
|
||
@reference-screenshots | ||
Scenario: take the reference screenshots | ||
Given the reference screenshot directory is used | ||
When I take the screenshots while logged out | ||
|
||
And I sign in as "[email protected]" | ||
Then I take the screenshots while logged in | ||
|
||
@comparison-screenshots | ||
Scenario: take the comparison screenshots | ||
Given the comparison screenshot directory is used | ||
When I take the screenshots while logged out | ||
|
||
And I sign in as "[email protected]" | ||
Then I take the screenshots while logged in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
namespace :screenshots do | ||
|
||
Cucumber::Rake::Task.new({:reference => 'db:test:prepare'}, 'Take reference screenshots') do |t| | ||
t.profile = 'ref_screens' | ||
end | ||
|
||
Cucumber::Rake::Task.new({:comparison => 'db:test:prepare'}, 'Take comparison screenshots') do |t| | ||
t.profile = 'cmp_screens' | ||
end | ||
|
||
desc 'Take reference and comparison screenshots' | ||
task :all => [:reference, :comparison] | ||
|
||
desc 'Generate "flicker" images for easy comparison (requires RMagick)' | ||
task :flicker do | ||
require 'RMagick' | ||
screen_dir = Rails.root.join('tmp', 'screenshots') | ||
|
||
ref_dir = screen_dir.join('reference') | ||
cur_dir = screen_dir.join('current') | ||
|
||
Dir.glob("#{ref_dir}/*.png") do |img| | ||
filename = File.basename(img) | ||
|
||
if !File.exist?(cur_dir.join(filename)) | ||
raise "the comparison screenshot for #{filename} doesn't exist!" | ||
end | ||
|
||
img_list = Magick::ImageList.new(ref_dir.join(filename), cur_dir.join(filename)) | ||
img_list.delay = 65 # number of ticks between flicker img change (100 ticks/second) | ||
img_list.iterations = 0 # -> endless loop | ||
img_list.write(screen_dir.join("#{filename}.gif")) | ||
end | ||
|
||
puts %Q( | ||
Done! | ||
You can find the flicker images here: | ||
#{screen_dir} | ||
) | ||
end | ||
end |