visdiff 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/visdiff.rb +2 -0
- data/lib/visdiff/client.rb +2 -2
- data/lib/visdiff/minitest.rb +24 -0
- data/lib/visdiff/revision.rb +3 -2
- data/lib/visdiff/test_run.rb +60 -0
- data/lib/visdiff/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 729292acdcd423e20d6c449c0e81e7485facccb9
|
4
|
+
data.tar.gz: edde170cd99ffd76847feab2ce4c6fb63196a9a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25f240dcf7ac01dd2df634ab5d006000fce64c2c53315c43424bbebc852ba640565091a2ecf8358e58482ac8daa3dfda5499b9d8a4b863c7c17d824b58fcc32f
|
7
|
+
data.tar.gz: 808306fada60b3492a28f95c2786e65b7ea4662af153adf0650963b3cfa6c4ea1d69d3014cc188e5f30bc07159b51c321248e670dd3d9160ffb4fb3ca936176f
|
data/lib/visdiff.rb
CHANGED
data/lib/visdiff/client.rb
CHANGED
@@ -5,10 +5,10 @@ module Visdiff
|
|
5
5
|
attr_reader :config
|
6
6
|
|
7
7
|
def initialize(config=Visdiff.config)
|
8
|
-
@config = config
|
8
|
+
@config = config.dup
|
9
9
|
end
|
10
10
|
|
11
|
-
def revision
|
11
|
+
def revision(identifier=nil, images=[], description=nil)
|
12
12
|
revision = Revision.new(identifier, images, description)
|
13
13
|
revision.client = self
|
14
14
|
yield revision if block_given?
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'visdiff/test_run'
|
2
|
+
|
3
|
+
module Visdiff::Minitest
|
4
|
+
def self.included(klass)
|
5
|
+
visdiff = Visdiff::TestRun.new
|
6
|
+
mod = Module.new
|
7
|
+
mod.send(:define_method, :visdiff) { visdiff }
|
8
|
+
klass.send(:extend, mod)
|
9
|
+
klass.send(:include, mod)
|
10
|
+
end
|
11
|
+
|
12
|
+
def observe!(identifier)
|
13
|
+
visdiff.observe_page(identifier, page)
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_teardown
|
17
|
+
if !passed? && visdiff.enabled?
|
18
|
+
warn "Disabling visdiff due to test failure"
|
19
|
+
visdiff.enabled = false
|
20
|
+
end
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/lib/visdiff/revision.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Visdiff
|
2
2
|
class Revision
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :images, :url, :id
|
4
|
+
attr_accessor :identifier, :description
|
4
5
|
attr_accessor :client
|
5
6
|
|
6
|
-
def initialize
|
7
|
+
def initialize(identifier=nil, images=[], description=nil)
|
7
8
|
@identifier = identifier
|
8
9
|
@images = images
|
9
10
|
@description = description
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'visdiff/client'
|
2
|
+
|
3
|
+
class Visdiff::TestRun
|
4
|
+
attr_reader :revision
|
5
|
+
attr_accessor :enabled
|
6
|
+
|
7
|
+
alias_method :enabled?, :enabled
|
8
|
+
|
9
|
+
delegate :api_key=, :base_url=, :debug=, to: :client_config
|
10
|
+
delegate :identifier=, :description=, to: :revision
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
visdiff = Visdiff::Client.new
|
14
|
+
@revision = visdiff.revision
|
15
|
+
@enabled = false
|
16
|
+
|
17
|
+
submit_proc = lambda do
|
18
|
+
submit!
|
19
|
+
end
|
20
|
+
|
21
|
+
if Minitest.respond_to?(:after_run)
|
22
|
+
Minitest.after_run(&submit_proc)
|
23
|
+
else
|
24
|
+
# old, issues a warning on new versions of minitest
|
25
|
+
MiniTest::Unit.after_tests(&submit_proc)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def submit!
|
30
|
+
return false unless enabled?
|
31
|
+
|
32
|
+
revision.submit!
|
33
|
+
end
|
34
|
+
|
35
|
+
def enable
|
36
|
+
self.enabled = true
|
37
|
+
end
|
38
|
+
|
39
|
+
def revision_from_git!
|
40
|
+
git_sha, git_desc = `git rev-list --format=%B --max-count=1 HEAD`.split("\n")
|
41
|
+
git_sha.gsub!(/\Acommit /, '')
|
42
|
+
self.identifier = git_sha
|
43
|
+
self.description = git_desc
|
44
|
+
end
|
45
|
+
|
46
|
+
def observe_page(identifier, page)
|
47
|
+
return false unless enabled?
|
48
|
+
|
49
|
+
tmppath = "tmp/visdiff/#{SecureRandom.hex}.png"
|
50
|
+
page.driver.render(tmppath, full: true)
|
51
|
+
revision.add_image identifier, tmppath
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def client_config
|
57
|
+
revision.client.config
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/lib/visdiff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -68,7 +68,9 @@ files:
|
|
68
68
|
- lib/visdiff/client.rb
|
69
69
|
- lib/visdiff/config.rb
|
70
70
|
- lib/visdiff/image.rb
|
71
|
+
- lib/visdiff/minitest.rb
|
71
72
|
- lib/visdiff/revision.rb
|
73
|
+
- lib/visdiff/test_run.rb
|
72
74
|
- lib/visdiff/version.rb
|
73
75
|
- visdiff.gemspec
|
74
76
|
homepage: http://visdiff.com/
|