baraviz 0.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/baraviz.gemspec +26 -0
- data/lib/baraviz/cucumber_formatter.rb +24 -0
- data/lib/baraviz/observer.rb +56 -0
- data/lib/baraviz/version.rb +3 -0
- data/lib/baraviz.rb +1 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 900176eb3b4b0996216de4f6a5d73252add19d39
|
4
|
+
data.tar.gz: 39e7d85f1b8d8f76ad2665f737722ccc65b22bb5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95f50decc62c0ffa825b0177c9a538e9a15fa29fc1bd1e5e325c0ce7870284e9d4a41882d094cfb956c11d383d406b6304aa9b2c06261cac2b0a996c7ef0759f
|
7
|
+
data.tar.gz: 787bbdb31a9c3b411caec54fb9bf1fe1864565636e44e6efa550125ebc1f8931046e2a588350c9b3321e50e2343c32073c97fc94ea7b9acb85a593158fbce075
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Simon Worthington
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/baraviz.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'baraviz/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'baraviz'
|
7
|
+
spec.version = Baraviz::VERSION
|
8
|
+
spec.authors = ['Simon Worthington']
|
9
|
+
spec.email = ['simon@simonwo.net']
|
10
|
+
|
11
|
+
spec.summary = %q{Generates Graphviz diagrams of user journeys automatically during testing.}
|
12
|
+
spec.homepage = 'https://github.com/simonwo/baraviz'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'capybara', '>= 0.3.5'
|
23
|
+
spec.add_dependency 'rgl', '>= 0.4'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'cucumber/formatter/io'
|
2
|
+
require 'rgl/dot'
|
3
|
+
require_relative 'observer'
|
4
|
+
|
5
|
+
module Baraviz
|
6
|
+
class CucumberFormatter
|
7
|
+
include Cucumber::Formatter::Io
|
8
|
+
|
9
|
+
def initialize config
|
10
|
+
@io = ensure_io config.out_stream
|
11
|
+
config.on_event :test_run_started, &method(:on_test_run_started)
|
12
|
+
config.on_event :test_run_finished, &method(:on_test_run_finished)
|
13
|
+
end
|
14
|
+
|
15
|
+
def on_test_run_started event
|
16
|
+
@observer = Baraviz::Observer.new Capybara.current_session
|
17
|
+
end
|
18
|
+
|
19
|
+
def on_test_run_finished event
|
20
|
+
@io.write @observer.clustered_graph.to_s
|
21
|
+
@io.close
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rgl/adjacency'
|
2
|
+
require 'rgl/dot'
|
3
|
+
require 'capybara'
|
4
|
+
|
5
|
+
module Baraviz
|
6
|
+
class Observer
|
7
|
+
attr_reader :graph
|
8
|
+
|
9
|
+
def initialize session
|
10
|
+
@graph = RGL::DirectedAdjacencyGraph.new
|
11
|
+
install_capybara_hooks! session
|
12
|
+
end
|
13
|
+
|
14
|
+
def install_capybara_hooks! session
|
15
|
+
this = self
|
16
|
+
Capybara::Session::DSL_METHODS.each do |method|
|
17
|
+
session.define_singleton_method :"_#{method}_old", &session.method(method)
|
18
|
+
session.define_singleton_method method do |*args, &block|
|
19
|
+
old_page = session.method(:"_current_url_old").call
|
20
|
+
result = session.method(:"_#{method}_old").call(*args, &block)
|
21
|
+
new_page = session.method(:"_current_url_old").call
|
22
|
+
|
23
|
+
if old_page != new_page
|
24
|
+
this.observe_page_change old_page, new_page
|
25
|
+
end
|
26
|
+
|
27
|
+
result
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def observe_page_change old_page, new_page
|
33
|
+
@graph.add_edge old_page, new_page
|
34
|
+
end
|
35
|
+
|
36
|
+
def clustered_graph
|
37
|
+
subgraphs = Hash.new do |h, uri|
|
38
|
+
h[uri] = RGL::DOT::Subgraph.new('name' => "cluster_#{uri[0]}:#{uri[1]}", 'label' => "#{uri[0]}:#{uri[1]}")
|
39
|
+
end
|
40
|
+
|
41
|
+
@graph.each_vertex do |v|
|
42
|
+
uri = URI.parse v.to_s
|
43
|
+
subgraph = subgraphs[[uri.host, uri.port]]
|
44
|
+
subgraph << RGL::DOT::Node.new('name' => v, 'label' => v.to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
graph = RGL::DOT::Digraph.new
|
48
|
+
subgraphs.values.each &graph.method(:<<)
|
49
|
+
@graph.each_edge do |u, v|
|
50
|
+
graph << RGL::DOT::DirectedEdge.new('from' => u, 'to' => v)
|
51
|
+
end
|
52
|
+
|
53
|
+
graph
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/baraviz.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "baraviz/version"
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: baraviz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simon Worthington
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rgl
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- simon@simonwo.net
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- baraviz.gemspec
|
80
|
+
- lib/baraviz.rb
|
81
|
+
- lib/baraviz/cucumber_formatter.rb
|
82
|
+
- lib/baraviz/observer.rb
|
83
|
+
- lib/baraviz/version.rb
|
84
|
+
homepage: https://github.com/simonwo/baraviz
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.3.1
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.6.13
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Generates Graphviz diagrams of user journeys automatically during testing.
|
108
|
+
test_files: []
|