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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 540dad59be340b8e8df8324fc40071d0ab4afcbe
4
- data.tar.gz: 59dc48f248de6e6825f54aa8c87b0d050b59e7ff
3
+ metadata.gz: 729292acdcd423e20d6c449c0e81e7485facccb9
4
+ data.tar.gz: edde170cd99ffd76847feab2ce4c6fb63196a9a0
5
5
  SHA512:
6
- metadata.gz: 12fa33651866b247ee0a0ccef3f603259411b76ade0e781d82cf6fe48aa40ac449fe19a42fe7c7b840daeced86647fe69912e67529f0380afb192eacde4e351f
7
- data.tar.gz: 539ea37b5c15ac74fe50cc001e2ad251891d31097270aefc7c2a19b6903bdd165acff7c21ef3be04de80b4cd7af55f8fa926be534fb906698be896dc4bfcf3be
6
+ metadata.gz: 25f240dcf7ac01dd2df634ab5d006000fce64c2c53315c43424bbebc852ba640565091a2ecf8358e58482ac8daa3dfda5499b9d8a4b863c7c17d824b58fcc32f
7
+ data.tar.gz: 808306fada60b3492a28f95c2786e65b7ea4662af153adf0650963b3cfa6c4ea1d69d3014cc188e5f30bc07159b51c321248e670dd3d9160ffb4fb3ca936176f
@@ -5,6 +5,8 @@ require 'visdiff/config'
5
5
  require 'visdiff/image'
6
6
  require 'visdiff/revision'
7
7
 
8
+ require 'visdiff/test_run'
9
+
8
10
  module Visdiff
9
11
  def self.config
10
12
  @config ||= Config.new
@@ -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 identifier, images=[], description=nil
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
+
@@ -1,9 +1,10 @@
1
1
  module Visdiff
2
2
  class Revision
3
- attr_reader :identifier, :images, :description, :url, :id
3
+ attr_reader :images, :url, :id
4
+ attr_accessor :identifier, :description
4
5
  attr_accessor :client
5
6
 
6
- def initialize identifier, images=[], description=nil
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
+
@@ -1,3 +1,3 @@
1
1
  module Visdiff
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
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-02-24 00:00:00.000000000 Z
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/