symilaa 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/symilaa/comparison_support.rb +87 -25
- data/lib/symilaa/version.rb +1 -1
- metadata +13 -13
@@ -1,5 +1,13 @@
|
|
1
1
|
module Symilaa
|
2
2
|
module ComparisonSupport
|
3
|
+
def base_dir= dir
|
4
|
+
@base_dir = dir
|
5
|
+
end
|
6
|
+
|
7
|
+
def base_dir
|
8
|
+
@base_dir || 'artifacts'
|
9
|
+
end
|
10
|
+
|
3
11
|
def add_text_to_image text, image
|
4
12
|
txt = Magick::Draw.new
|
5
13
|
image.annotate(txt, 0, 0, 0, 50, text) {
|
@@ -18,8 +26,7 @@ module Symilaa
|
|
18
26
|
gif.write(output_file)
|
19
27
|
end
|
20
28
|
|
21
|
-
def get_unique_file_name path, extension, inc
|
22
|
-
inc = 0 unless inc
|
29
|
+
def get_unique_file_name path, extension, inc=0
|
23
30
|
inc = inc.to_int+1
|
24
31
|
|
25
32
|
new_path = "#{path}#{inc}#{extension}"
|
@@ -31,42 +38,97 @@ module Symilaa
|
|
31
38
|
end
|
32
39
|
end
|
33
40
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
def create_directories directories
|
42
|
+
directories.each do |dir|
|
43
|
+
path = File.join base_dir, dir
|
44
|
+
FileUtils.rm_rf(path) if File.exists? path
|
45
|
+
FileUtils.mkdir_p path
|
46
|
+
end
|
47
|
+
end
|
40
48
|
|
41
|
-
|
49
|
+
def browser_info
|
50
|
+
@browser_info ||= page.driver.browser.capabilities
|
51
|
+
end
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
53
|
+
def browser_name
|
54
|
+
browser_info.browser_name
|
55
|
+
end
|
46
56
|
|
47
|
-
|
57
|
+
def browser_version
|
58
|
+
browser_info.version
|
59
|
+
end
|
48
60
|
|
49
|
-
|
50
|
-
|
61
|
+
def title
|
62
|
+
find('title').text.parameterize.underscore
|
63
|
+
end
|
51
64
|
|
65
|
+
def same? reference_file, test_file
|
52
66
|
reference_screenshot = Image.new reference_file
|
53
67
|
generated_screenshot = Image.new test_file
|
54
68
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
unless same
|
62
|
-
FileUtils.mkdir_p("#{DIFFERENCES_IN_SCREENSHOTS_THIS_RUN_DIR}/#{sub_directory}")
|
63
|
-
produce_gif_showing_the_difference_between(reference_file, test_file, "#{DIFFERENCES_IN_SCREENSHOTS_THIS_RUN_DIR}/#{sub_directory}#{screenshot_name}_difference.gif")
|
64
|
-
fail "Some of the screenshots did not match"
|
69
|
+
if dodgy_browser?
|
70
|
+
reference_screenshot.similar_to? generated_screenshot
|
71
|
+
else
|
72
|
+
reference_screenshot == generated_screenshot
|
65
73
|
end
|
66
74
|
end
|
67
75
|
|
68
76
|
def dodgy_browser?
|
69
77
|
%w[chrome ie7 ie8 ie9].include? ENV['REQUIRED_BROWSER']
|
70
78
|
end
|
79
|
+
|
80
|
+
def chrome_or_firefox_3_5
|
81
|
+
browser_name == 'chrome' or (browser_name == 'firefox' and browser_version == '3.5')
|
82
|
+
end
|
83
|
+
|
84
|
+
def version_if_required
|
85
|
+
"_#{browser_info.version.gsub('.', '-')}" if chrome_or_firefox_3_5?
|
86
|
+
end
|
87
|
+
|
88
|
+
def reference_screenshots
|
89
|
+
File.join base_dir, 'reference_screenshots'
|
90
|
+
end
|
91
|
+
|
92
|
+
def screenshots_generated_this_run_dir
|
93
|
+
File.join base_dir, 'screenshots_generated_this_run'
|
94
|
+
end
|
95
|
+
|
96
|
+
def scenario_name
|
97
|
+
@gherkin_statement.parameterize.underscore if @gherkin_statement
|
98
|
+
end
|
99
|
+
|
100
|
+
def create_screenshot_directory sub_directory, scenario_name
|
101
|
+
FileUtils.mkdir_p(File.join screenshots_generated_this_run_dir, sub_directory, scenario_name)
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_screenshot_filename sub_directory
|
105
|
+
file_name = "#{browser_info.browser_name.capitalize.parameterize}#{version_if_required}_#{browser_info.platform.capitalize}_#{title}"
|
106
|
+
get_unique_file_name "#{screenshots_generated_this_run_dir}/#{sub_directory}#{file_name}", '.png'
|
107
|
+
end
|
108
|
+
|
109
|
+
def save_screenshot screenshot_path
|
110
|
+
page.driver.browser.save_screenshot screenshot_path
|
111
|
+
end
|
112
|
+
|
113
|
+
def check_screen_against_reference_shot target_sub_directory
|
114
|
+
create_directories %w[reference_screenshots screenshots_generated_this_run differences_in_screenshots_this_run]
|
115
|
+
create_screenshot_directory target_sub_directory
|
116
|
+
|
117
|
+
generated_screenshot_path = create_screenshot_filename target_sub_directory
|
118
|
+
screenshot_name = File.basename generated_screenshot_path
|
119
|
+
reference_path = File.join reference_screenshots, target_sub_directory, screenshot_name
|
120
|
+
difference_file = File.join path, "#{screenshot_name}_difference.gif"
|
121
|
+
|
122
|
+
save_screenshot generated_screenshot_path
|
123
|
+
|
124
|
+
unless same? reference_path, generated_screenshot_path
|
125
|
+
path = File.join differences_in_screenshots_this_run_dir, target_sub_directory
|
126
|
+
FileUtils.mkdir_p path
|
127
|
+
|
128
|
+
produce_gif_showing_the_difference_between reference_path, generated_screenshot_path, difference_file
|
129
|
+
|
130
|
+
fail "Some of the screenshots did not match"
|
131
|
+
end
|
132
|
+
end
|
71
133
|
end
|
72
134
|
end
|
data/lib/symilaa/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symilaa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-11-15 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &10950900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10950900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard-minitest
|
27
|
-
requirement: &
|
27
|
+
requirement: &10950400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10950400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &10949920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10949920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rb-inotify
|
49
|
-
requirement: &
|
49
|
+
requirement: &10557620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10557620
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rmagick
|
60
|
-
requirement: &
|
60
|
+
requirement: &10557040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *10557040
|
69
69
|
description: ! "Using the wonders of RMagick, this wonderful gem will produce a boolean
|
70
70
|
result based on the computed similarity\n of the two images passed."
|
71
71
|
email:
|
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
segments:
|
115
115
|
- 0
|
116
|
-
hash:
|
116
|
+
hash: 2284028661893929542
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
segments:
|
124
124
|
- 0
|
125
|
-
hash:
|
125
|
+
hash: 2284028661893929542
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project: symilaa
|
128
128
|
rubygems_version: 1.8.10
|