autopsy 0.0.6 → 0.1.0

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: 9c6431b186109062b32916ace9f772444490b935
4
- data.tar.gz: 5a4ecf1e19dfb3d04ec62b513b2a2d2c8dc47fff
3
+ metadata.gz: 22e4947e2a2732dab014286a51a11ea34bb4f526
4
+ data.tar.gz: 325a896f4d89de7f3c8f4e6d331036bd54993b03
5
5
  SHA512:
6
- metadata.gz: 533e47006c4e78ef2762924ebbba9925f722b554439ca327ce49655ed5c98a650ff117131d32ff76bf0a81b3f64a0ba0208e570c38a3e3a4bdf0ab3c117f0a58
7
- data.tar.gz: e39b3437e47463e3ba03e506b251e02c75f2ff2bca2f6a2954c3e599b5787b8a063f9f3a5413dabe6b22a8ea1a8d4fe68a89bf134d7366dee97021cb8332abfe
6
+ metadata.gz: c76004de73430501663874c5f5f49b1c679065723cc8b7c1b080dae20926178045ae8e2c3758f997afa8fb5dbb01d0675c10e5d387864a728d487e7c4271e3c0
7
+ data.tar.gz: 179741c94b593fb861e06cfdb0a4d54568aae76b8c5247eab084ad7843257bd4e8ee8cf994f8dd86c3c7e84c478b8de8a6d10dab43a54bd934841c80c9f78ea1
@@ -1,25 +1,33 @@
1
- require 'rspec'
2
- require 'capybara/rspec'
3
1
  require 'awesome_print'
2
+ require 'capybara'
3
+ require_relative 'autopsy/webkit'
4
+ require_relative 'autopsy/poltergeist'
4
5
 
5
6
  class Autopsy
6
7
  class << self
7
8
  attr_accessor :artifacts_path
9
+ end
10
+
11
+ @@driver_map = {
12
+ webkit: AutopsyWebkit,
13
+ poltergeist: AutopsyPoltergeist
14
+ }
8
15
 
9
- def perform(capybara_page, test_base, exception)
10
- file_base = "#{File.expand_path(Autopsy.artifacts_path)}/#{test_base}"
11
- if exception != nil
12
- capybara_page.save_screenshot "#{file_base}.png"
13
- capybara_page.save_page "#{file_base}.html"
14
- msgs = capybara_page.driver.console_messages.ai(html: true)
16
+ def self.perform(capybara_page, test_base, exception)
17
+ file_base = "#{File.expand_path(Autopsy.artifacts_path)}/#{test_base}"
18
+ if exception != nil
19
+ capybara_page.save_screenshot "#{file_base}.png"
20
+ capybara_page.save_page "#{file_base}.html"
21
+ if (@@driver_map[Capybara.current_driver])
22
+ msgs = @@driver_map[Capybara.current_driver].get_console_messages(capybara_page).ai(html: true)
15
23
  File.open("#{file_base}_msgs.html", 'w') {|f| f.write(msgs) }
16
- File.open("#{file_base}_error.log", 'w') do |f|
17
- f.write exception.message
24
+ end
25
+ File.open("#{file_base}_error.log", 'w') do |f|
26
+ f.write exception.message
27
+ f.write "\n"
28
+ (exception.backtrace || []).each do |l|
29
+ f.write l
18
30
  f.write "\n"
19
- (exception.backtrace || []).each do |l|
20
- f.write l
21
- f.write "\n"
22
- end
23
31
  end
24
32
  end
25
33
  end
@@ -5,8 +5,18 @@ Autopsy.artifacts_path = "./features/artifacts"
5
5
 
6
6
  After do |scenario|
7
7
  if scenario.failed?
8
- file_base = "#{scenario.file.split("/").last.split(".").first}-#{scenario.line}"
9
- Autopsy.perform(page, file_base, scenario.exception)
8
+ location = if (scenario.respond_to? :location)
9
+ scenario.location
10
+ else
11
+ scenario
12
+ end
13
+ file_base = "#{location.file.split("/").last.split(".").first}-#{location.line}"
14
+ exception = if (scenario.respond_to? :exception)
15
+ scenario.exception
16
+ else
17
+ scenario.instance_variable_get("@result").exception ## boo cucumber bug
18
+ end
19
+ Autopsy.perform(page, file_base, exception)
10
20
  end
11
21
  end
12
22
 
@@ -0,0 +1,18 @@
1
+ class AutopsyPoltergeist
2
+ class << self
3
+ def init(options = {})
4
+ @log = StringIO.new
5
+ Capybara.register_driver :poltergeist do |app|
6
+ Capybara::Poltergeist::Driver.new(app, options.merge(logger: @log))
7
+ end
8
+ end
9
+
10
+ def get_console_messages(capybara_page)
11
+ lines = []
12
+ @log.each_line do |line|
13
+ lines << line
14
+ end
15
+ lines
16
+ end
17
+ end
18
+ end
@@ -1,4 +1,4 @@
1
- require 'rspec'
1
+ require 'rspec/core'
2
2
  require 'capybara/rspec'
3
3
  require_relative '../autopsy'
4
4
 
@@ -0,0 +1,7 @@
1
+ class AutopsyWebkit
2
+ class << self
3
+ def get_console_messages(capybara_page)
4
+ capybara_page.driver.console_messages
5
+ end
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autopsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Pleasant-Ryan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -26,15 +26,17 @@ dependencies:
26
26
  version: '0'
27
27
  description: See error messages, screenshots, current HTML, and current Javascript
28
28
  console messages on feature test failures.
29
- email: krelian18@gmail.com
29
+ email: will.ryan@atomicobject.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/autopsy.rb
35
35
  - lib/autopsy/cucumber.rb
36
+ - lib/autopsy/poltergeist.rb
36
37
  - lib/autopsy/rspec.rb
37
- homepage: https://github.com/willryan/autopsy
38
+ - lib/autopsy/webkit.rb
39
+ homepage: https://github.com/atomicobject/autopsy
38
40
  licenses:
39
41
  - MIT
40
42
  metadata: {}
@@ -54,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
56
  version: '0'
55
57
  requirements: []
56
58
  rubyforge_project:
57
- rubygems_version: 2.2.2
59
+ rubygems_version: 2.4.5
58
60
  signing_key:
59
61
  specification_version: 4
60
- summary: Emit helpful artifacts for failed Capybara (Webkit) feature tests
62
+ summary: Emit helpful artifacts for failed Capybara feature tests
61
63
  test_files: []