Class: Visdiff::TestRun

Inherits:
Object
  • Object
show all
Defined in:
lib/visdiff/test_run.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestRun

Returns a new instance of TestRun.



12
13
14
15
16
# File 'lib/visdiff/test_run.rb', line 12

def initialize
  visdiff = Visdiff::Client.new
  @revision = visdiff.revision
  @enabled = false
end

Instance Attribute Details

#enabledObject Also known as: enabled?

Returns the value of attribute enabled.



5
6
7
# File 'lib/visdiff/test_run.rb', line 5

def enabled
  @enabled
end

#revisionObject (readonly)

Returns the value of attribute revision.



4
5
6
# File 'lib/visdiff/test_run.rb', line 4

def revision
  @revision
end

Instance Method Details

#enableObject



24
25
26
# File 'lib/visdiff/test_run.rb', line 24

def enable
  self.enabled = true
end

#observe_page(identifier, page) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/visdiff/test_run.rb', line 35

def observe_page(identifier, page)
  return false unless enabled?

  tmppath = "tmp/visdiff/#{SecureRandom.hex}.png"
  page.driver.render(tmppath, full: true)
  revision.add_image identifier, tmppath
end

#revision_from_git!Object



28
29
30
31
32
33
# File 'lib/visdiff/test_run.rb', line 28

def revision_from_git!
  git_sha, git_desc = `git rev-list --format=%B --max-count=1 HEAD`.split("\n")
  git_sha.gsub!(/\Acommit /, '')
  self.identifier = git_sha
  self.description = git_desc
end

#submit!Object



18
19
20
21
22
# File 'lib/visdiff/test_run.rb', line 18

def submit!
  return false unless enabled?

  revision.submit!
end