symilaa 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'minitest' do
5
+ watch(%r|^test/(.*)\/?test_(.*)\.rb|)
6
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
7
+ watch(%r|^test/test_helper\.rb|) { "test" }
8
+ end
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
 
4
4
  module Symilaa
5
5
  class Screenshot
6
- SIMILARITY_THRESHOLD = 0.0002
6
+ SIMILARITY_THRESHOLD = 41.4
7
7
 
8
8
  attr_reader :path
9
9
 
@@ -19,9 +19,9 @@ module Symilaa
19
19
  this_one = Magick::Image.read(@path).first
20
20
  that_one = Magick::Image.read(other.path).first
21
21
 
22
- similiarity_factor = this_one.compare_channel(that_one, Magick::MeanAbsoluteErrorMetric)[1]
22
+ similiarity_factor = this_one.compare_channel(that_one, Magick::PeakSignalToNoiseRatioMetric)[1]
23
23
 
24
- similiarity_factor <= SIMILARITY_THRESHOLD
24
+ similiarity_factor >= SIMILARITY_THRESHOLD
25
25
  rescue Magick::ImageMagickError; end
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module Symilaa
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/symilaa.gemspec CHANGED
@@ -21,5 +21,9 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # specify any dependencies here; for example:
23
23
  s.add_development_dependency "minitest"
24
+ s.add_development_dependency "guard-minitest"
25
+
26
+ s.add_development_dependency 'rb-inotify' if RUBY_PLATFORM =~ /linux/
27
+
24
28
  s.add_runtime_dependency "rmagick"
25
29
  end
@@ -4,60 +4,109 @@ require_relative '../../lib/symilaa/screenshot'
4
4
 
5
5
  module Symilaa
6
6
  class TestScreenshot < Minitest::Unit::TestCase
7
- GRYLLS = File.expand_path '../fixtures/bear_grylls.png', File.dirname(__FILE__)
8
- GRYLLS_SLIGHT_DIFF = File.expand_path '../fixtures/bear_grylls_slightly_different.png', File.dirname(__FILE__)
9
- GRYLLS_DIFF = File.expand_path '../fixtures/bear_grylls_different.png', File.dirname(__FILE__)
10
- QUEENY_POPS = File.expand_path '../fixtures/farewells.jpg', File.dirname(__FILE__)
11
-
12
7
  def test_equality_when_images_altered
13
- one = Screenshot.new GRYLLS
14
- two = Screenshot.new GRYLLS_DIFF
8
+ one = Screenshot.new grylls
9
+ two = Screenshot.new grylls_different
15
10
 
16
11
  refute one == two
17
12
  end
18
13
 
19
14
  def test_equality_when_images_similar
20
- one = Screenshot.new GRYLLS
21
- two = Screenshot.new GRYLLS_SLIGHT_DIFF
15
+ one = Screenshot.new grylls
16
+ two = Screenshot.new grylls_slightly_different
22
17
 
23
18
  refute one == two
24
19
  end
25
20
 
26
21
  def test_equality_when_identical
27
- one = Screenshot.new GRYLLS
28
- two = Screenshot.new GRYLLS
22
+ one = Screenshot.new grylls
23
+ two = Screenshot.new grylls
29
24
 
30
25
  assert one == two
31
26
  end
32
27
 
33
28
  def test_similar_when_identical
34
- one = Screenshot.new GRYLLS
35
- two = Screenshot.new GRYLLS
29
+ one = Screenshot.new grylls
30
+ two = Screenshot.new grylls
36
31
 
37
32
  assert one.similar_to? two
38
33
  end
39
34
 
40
35
  def test_similar_when_similar
41
- one = Screenshot.new GRYLLS
42
- two = Screenshot.new GRYLLS_SLIGHT_DIFF
36
+ one = Screenshot.new grylls
37
+ two = Screenshot.new grylls_slightly_different
43
38
 
44
39
  assert one.similar_to? two
45
40
  end
46
41
 
47
- def test_similar_when_different
48
- one = Screenshot.new GRYLLS
49
- two = Screenshot.new GRYLLS_DIFF
50
-
51
- refute one.similar_to? two
52
- end
53
-
54
42
  def test_different_sized_images_are_different
55
- one = Screenshot.new GRYLLS
56
- two = Screenshot.new QUEENY_POPS
43
+ one = Screenshot.new grylls
44
+ two = Screenshot.new the_queen
57
45
 
58
46
  refute one.similar_to? two
59
47
  refute one == two
60
48
  end
49
+
50
+ def test_css_font_size_change
51
+ ref = Screenshot.new fixture 'diagnostics/reference/font_size.png'
52
+ diff = Screenshot.new fixture 'diagnostics/generated/font_size.png'
53
+
54
+ refute ref == diff
55
+ refute ref.similar_to? diff
56
+ end
57
+
58
+ def test_css_change_of_gradient
59
+ ref = Screenshot.new fixture 'diagnostics/reference/gradient.png'
60
+ diff = Screenshot.new fixture 'diagnostics/generated/gradient.png'
61
+
62
+ refute ref == diff, "Images with different gradients should not be the same"
63
+ refute ref.similar_to?(diff), "Images with different gradients should not be similar"
64
+ end
65
+
66
+ def test_lightbox_difference
67
+ ref = Screenshot.new fixture 'diagnostics/reference/lightbox.png'
68
+ diff = Screenshot.new fixture 'diagnostics/generated/lightbox.png'
69
+
70
+ refute ref == diff, "Internet Explorer's rendering of a lightbox is different every time"
71
+ assert ref.similar_to?(diff), "Internet Explorer's rendering of a lightbox is similar enough each time"
72
+ end
73
+
74
+ def test_rounded_corners_in_ie9
75
+ ref = Screenshot.new fixture 'diagnostics/reference/rounded_corner_ie9.png'
76
+ diff = Screenshot.new fixture 'diagnostics/generated/rounded_corner_ie9.png'
77
+
78
+ refute ref == diff
79
+ assert ref.similar_to?(diff)
80
+ end
81
+
82
+ def test_active_input_state_in_ie9
83
+ ref = Screenshot.new fixture 'diagnostics/reference/active_input_ie9.png'
84
+ diff = Screenshot.new fixture 'diagnostics/generated/active_input_ie9.png'
85
+
86
+ refute ref == diff
87
+ assert ref.similar_to?(diff)
88
+ end
89
+
90
+ private
91
+
92
+ def fixture name
93
+ File.expand_path "../fixtures/#{name}", File.dirname(__FILE__)
94
+ end
95
+
96
+ def grylls
97
+ fixture 'bear_grylls.png'
98
+ end
99
+
100
+ def grylls_different
101
+ fixture 'bear_grylls_different.png'
102
+ end
103
+
104
+ def grylls_slightly_different
105
+ fixture 'bear_grylls_slightly_different.png'
106
+ end
107
+
108
+ def the_queen
109
+ fixture 'farewells.jpg'
110
+ end
61
111
  end
62
112
  end
63
-
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-08 00:00:00.000000000Z
12
+ date: 2012-11-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &7660100 !ruby/object:Gem::Requirement
16
+ requirement: &22820560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,32 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *7660100
24
+ version_requirements: *22820560
25
+ - !ruby/object:Gem::Dependency
26
+ name: guard-minitest
27
+ requirement: &22819920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *22819920
36
+ - !ruby/object:Gem::Dependency
37
+ name: rb-inotify
38
+ requirement: &22819220 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *22819220
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: rmagick
27
- requirement: &7659400 !ruby/object:Gem::Requirement
49
+ requirement: &22818440 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ! '>='
@@ -32,7 +54,7 @@ dependencies:
32
54
  version: '0'
33
55
  type: :runtime
34
56
  prerelease: false
35
- version_requirements: *7659400
57
+ version_requirements: *22818440
36
58
  description: ! "Using the wonders of RMagick, this wonderful gem will produce a boolean
37
59
  result based on the computed similarity\n of the two images passed."
38
60
  email:
@@ -43,6 +65,7 @@ extra_rdoc_files: []
43
65
  files:
44
66
  - .gitignore
45
67
  - Gemfile
68
+ - Guardfile
46
69
  - README.md
47
70
  - Rakefile
48
71
  - lib/symilaa.rb
@@ -52,6 +75,16 @@ files:
52
75
  - test/fixtures/bear_grylls.png
53
76
  - test/fixtures/bear_grylls_different.png
54
77
  - test/fixtures/bear_grylls_slightly_different.png
78
+ - test/fixtures/diagnostics/generated/active_input_ie9.png
79
+ - test/fixtures/diagnostics/generated/font_size.png
80
+ - test/fixtures/diagnostics/generated/gradient.png
81
+ - test/fixtures/diagnostics/generated/lightbox.png
82
+ - test/fixtures/diagnostics/generated/rounded_corner_ie9.png
83
+ - test/fixtures/diagnostics/reference/active_input_ie9.png
84
+ - test/fixtures/diagnostics/reference/font_size.png
85
+ - test/fixtures/diagnostics/reference/gradient.png
86
+ - test/fixtures/diagnostics/reference/lightbox.png
87
+ - test/fixtures/diagnostics/reference/rounded_corner_ie9.png
55
88
  - test/fixtures/farewells.jpg
56
89
  - test/symilaa/test_screenshot.rb
57
90
  homepage: https://github.com/bskyb-commerce-helpcentre/symilaa