Class: Visdiff::TestRun
- Inherits:
-
Object
- Object
- Visdiff::TestRun
- Defined in:
- lib/visdiff/test_run.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
(also: #enabled?)
Returns the value of attribute enabled.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
Instance Method Summary collapse
- #enable ⇒ Object
-
#initialize ⇒ TestRun
constructor
A new instance of TestRun.
- #observe_page(identifier, page) ⇒ Object
- #revision_from_git! ⇒ Object
- #submit! ⇒ Object
Constructor Details
#initialize ⇒ TestRun
Returns a new instance of TestRun.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/visdiff/test_run.rb', line 12 def initialize visdiff = Visdiff::Client.new @revision = visdiff.revision @enabled = false submit_proc = lambda do submit! end if Minitest.respond_to?(:after_run) Minitest.after_run(&submit_proc) else # old, issues a warning on new versions of minitest MiniTest::Unit.after_tests(&submit_proc) end end |
Instance Attribute Details
#enabled ⇒ Object 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 |
#revision ⇒ Object (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
#enable ⇒ Object
35 36 37 |
# File 'lib/visdiff/test_run.rb', line 35 def enable self.enabled = true end |
#observe_page(identifier, page) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/visdiff/test_run.rb', line 46 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
39 40 41 42 43 44 |
# File 'lib/visdiff/test_run.rb', line 39 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
29 30 31 32 33 |
# File 'lib/visdiff/test_run.rb', line 29 def submit! return false unless enabled? revision.submit! end |