gnawrnip 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +0 -3
- data/example/spec/spec_helper.rb +2 -3
- data/gnawrnip.gemspec +1 -1
- data/lib/gnawrnip/developer.rb +1 -1
- data/lib/gnawrnip/gnawrnip.js +48 -0
- data/lib/gnawrnip/gnawrnip.scss +47 -0
- data/lib/gnawrnip/image.rb +15 -10
- data/lib/gnawrnip/photographer.rb +0 -8
- data/lib/gnawrnip/rspec.rb +4 -2
- data/lib/gnawrnip/screenshot.rb +20 -16
- data/lib/gnawrnip/step_screenshot.rb +46 -133
- data/lib/gnawrnip/version.rb +1 -1
- data/lib/gnawrnip.rb +11 -13
- data/spec/gemfiles/Gemfile-rspec-2.14.x +4 -0
- data/spec/gemfiles/Gemfile-rspec-2.99.x +4 -0
- data/spec/gemfiles/Gemfile-rspec-3.0.x +4 -0
- data/spec/gnawrnip/developer_spec.rb +12 -14
- data/spec/gnawrnip/image_spec.rb +4 -4
- data/spec/gnawrnip/photographer_spec.rb +2 -4
- data/spec/gnawrnip/rspec_spec.rb +2 -2
- data/spec/gnawrnip/screenshot_spec.rb +4 -4
- data/spec/gnawrnip/step_screenshot_spec.rb +16 -21
- metadata +13 -6
- data/lib/gnawrnip/publisher.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6af6f42bf91fd705297fbffe6ae646ab12b61f34
|
4
|
+
data.tar.gz: b63314cda20223f47b9085b9ce6812f77b131b56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79aec3026d063787269ba122e935eb42c22aa5ac174c65e1328700f82d29bc62d35a62620a3f76024a803ca55734271724e48bf9a2555fa9a43870ada44fe2ab
|
7
|
+
data.tar.gz: 544a546b864326be38eff60454eea7b83aaba559ac5656de9535ce1c7817922aedd315afffc84db0c39bf18f0e6cd74d0d6ecfb5f241947c85b2704e0c31aa2b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -49,15 +49,12 @@ You can do to customize a screenshot.
|
|
49
49
|
|
50
50
|
```ruby
|
51
51
|
Gnawrnip.configure do |c|
|
52
|
-
c.frame_interval_ms = 1000 # milliseconds
|
53
52
|
c.make_animation = true
|
54
53
|
c.max_frame_size = 1024 # pixel
|
55
54
|
end
|
56
55
|
```
|
57
56
|
|
58
57
|
* `make_animation` (Boolean) Whether to make animation GIF. (Default: true)
|
59
|
-
* `frame_interval_ms` (Integer) A time (millisecond) between each image in an animation. Default is `1000`.
|
60
|
-
* This option is enabled only when the `make_animation = true`.
|
61
58
|
* `max_frame_size` (Integer) Maximum size that use to resize of image.
|
62
59
|
* If given, it resize the image to fit to this value.
|
63
60
|
* Ignored if this value is greater than original width and height.
|
data/example/spec/spec_helper.rb
CHANGED
@@ -21,7 +21,6 @@ Capybara.default_driver = :poltergeist
|
|
21
21
|
Capybara.javascript_driver = :selenium
|
22
22
|
|
23
23
|
Gnawrnip.configure do |c|
|
24
|
-
c.
|
25
|
-
c.
|
26
|
-
c.max_frame_size = 1024 # pixel
|
24
|
+
c.make_animation = true
|
25
|
+
c.max_frame_size = 1024 # pixel
|
27
26
|
end
|
data/gnawrnip.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency 'capybara', "~> 2.2"
|
22
|
-
spec.add_dependency 'turnip_formatter', '~> 0.
|
22
|
+
spec.add_dependency 'turnip_formatter', '~> 0.3.0'
|
23
23
|
spec.add_dependency 'oily_png'
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "rake"
|
data/lib/gnawrnip/developer.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
$(function() {
|
2
|
+
$('.screenshot.animation').each(function() {
|
3
|
+
var slide = $(this).find('.slides').cycle({
|
4
|
+
timeout: 1000,
|
5
|
+
autoHeight: "calc",
|
6
|
+
pager: $(this).find('div.nav .pager')
|
7
|
+
});
|
8
|
+
|
9
|
+
var nav = $(this).find('div.nav');
|
10
|
+
var playButton = nav.find('.play');
|
11
|
+
var pauseButton = nav.find('.pause');
|
12
|
+
var prevButton = nav.find('.prev');
|
13
|
+
var nextButton = nav.find('.next');
|
14
|
+
|
15
|
+
var setPauseManipulate = function() {
|
16
|
+
playButton.show();
|
17
|
+
pauseButton.hide();
|
18
|
+
prevButton.show();
|
19
|
+
nextButton.show();
|
20
|
+
};
|
21
|
+
|
22
|
+
var setPlayManipulate = function() {
|
23
|
+
playButton.hide();
|
24
|
+
pauseButton.show();
|
25
|
+
prevButton.hide();
|
26
|
+
nextButton.hide();
|
27
|
+
};
|
28
|
+
|
29
|
+
playButton.click(function() { slide.cycle('resume'); });
|
30
|
+
pauseButton.click(function() { slide.cycle('pause'); });
|
31
|
+
prevButton.click(function() { slide.cycle('prev'); });
|
32
|
+
nextButton.click(function() { slide.cycle('next'); });
|
33
|
+
|
34
|
+
setPlayManipulate();
|
35
|
+
|
36
|
+
slide.on('cycle-pager-activated', function(event, opts) {
|
37
|
+
slide.cycle('pause');
|
38
|
+
});
|
39
|
+
|
40
|
+
slide.on('cycle-paused', function(event, opts) {
|
41
|
+
setPauseManipulate();
|
42
|
+
});
|
43
|
+
|
44
|
+
slide.on('cycle-resumed', function(event, opts) {
|
45
|
+
setPlayManipulate();
|
46
|
+
});
|
47
|
+
});
|
48
|
+
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
div#steps-statistics section.scenario {
|
2
|
+
div.steps {
|
3
|
+
div.screenshot {
|
4
|
+
img {
|
5
|
+
max-width: 90%;
|
6
|
+
border: 2px solid black;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
div.screenshot.animation {
|
11
|
+
> div.nav {
|
12
|
+
text-align: center;
|
13
|
+
|
14
|
+
.pager {
|
15
|
+
margin-left: auto;
|
16
|
+
margin-right: auto;
|
17
|
+
|
18
|
+
span {
|
19
|
+
font-size: 50px;
|
20
|
+
display: inline;
|
21
|
+
color: #999999;
|
22
|
+
cursor: pointer;
|
23
|
+
|
24
|
+
&.cycle-pager-active {
|
25
|
+
color: red;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
.manipulate {
|
31
|
+
margin-bottom: 1em;
|
32
|
+
|
33
|
+
i {
|
34
|
+
color: black;
|
35
|
+
cursor: pointer;
|
36
|
+
margin-left: 0.3em;
|
37
|
+
margin-right: 0.3em;
|
38
|
+
|
39
|
+
&:hover {
|
40
|
+
color: #aa0000;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
data/lib/gnawrnip/image.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'oily_png'
|
2
3
|
|
3
4
|
module Gnawrnip
|
4
5
|
class Image
|
5
6
|
#
|
6
|
-
# @parma [
|
7
|
+
# @parma [String] filepath Screenshot image filepath
|
7
8
|
#
|
8
|
-
def initialize(
|
9
|
-
@
|
9
|
+
def initialize(filepath)
|
10
|
+
@filepath = filepath
|
10
11
|
analysis
|
11
12
|
end
|
12
13
|
|
14
|
+
def to_html(format = :png)
|
15
|
+
width = width
|
16
|
+
height = height
|
17
|
+
src = "data:image/#{format};base64,#{to_base64}"
|
18
|
+
|
19
|
+
%Q(<img width="#{width}" height="#{height}" src="#{src}"/>)
|
20
|
+
end
|
21
|
+
|
13
22
|
#
|
14
23
|
# @return [Fixnum] Width of image
|
15
24
|
#
|
@@ -25,18 +34,14 @@ module Gnawrnip
|
|
25
34
|
end
|
26
35
|
|
27
36
|
def to_base64
|
28
|
-
Base64.strict_encode64(File.read(@
|
37
|
+
Base64.strict_encode64(File.read(@filepath))
|
29
38
|
end
|
30
39
|
|
31
40
|
def resize(width, height)
|
32
|
-
canvas.resample_bilinear(width, height).save(@
|
41
|
+
canvas.resample_bilinear(width, height).save(@filepath)
|
33
42
|
analysis
|
34
43
|
end
|
35
44
|
|
36
|
-
def close!
|
37
|
-
@file.close!
|
38
|
-
end
|
39
|
-
|
40
45
|
private
|
41
46
|
|
42
47
|
#
|
@@ -47,7 +52,7 @@ module Gnawrnip
|
|
47
52
|
end
|
48
53
|
|
49
54
|
def canvas
|
50
|
-
OilyPNG::Canvas.from_file(@
|
55
|
+
OilyPNG::Canvas.from_file(@filepath)
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
data/lib/gnawrnip/rspec.rb
CHANGED
@@ -5,6 +5,10 @@ RSpec.configure do |config|
|
|
5
5
|
Gnawrnip.ready!
|
6
6
|
end
|
7
7
|
|
8
|
+
config.after(:all) do
|
9
|
+
Gnawrnip.finish!
|
10
|
+
end
|
11
|
+
|
8
12
|
# https://github.com/jnicklas/capybara/blob/master/lib/capybara/rspec.rb
|
9
13
|
fetch_current_example = RSpec.respond_to?(:current_example) ?
|
10
14
|
proc { RSpec.current_example } : proc { |context| context.example }
|
@@ -22,8 +26,6 @@ RSpec.configure do |config|
|
|
22
26
|
Gnawrnip.photographer.take_shot
|
23
27
|
screenshots = Gnawrnip.photographer.frames.compact
|
24
28
|
example.metadata[:gnawrnip][:screenshot] = screenshots
|
25
|
-
else
|
26
|
-
Gnawrnip.photographer.discard!
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
data/lib/gnawrnip/screenshot.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require 'tempfile'
|
2
1
|
require 'time'
|
3
2
|
require 'capybara'
|
4
|
-
require '
|
3
|
+
require 'securerandom'
|
4
|
+
require 'fileutils'
|
5
5
|
|
6
6
|
module Gnawrnip
|
7
7
|
class Screenshot
|
8
8
|
class << self
|
9
|
-
|
10
9
|
#
|
11
10
|
# Screenshot of current capybara session
|
12
11
|
#
|
@@ -22,7 +21,7 @@ module Gnawrnip
|
|
22
21
|
#
|
23
22
|
#
|
24
23
|
# @param [Fixnum] wait_second Second to repeat the retry
|
25
|
-
# @return [
|
24
|
+
# @return [String] Image filename of screenshot
|
26
25
|
#
|
27
26
|
def take(wait_second = Capybara.default_wait_time)
|
28
27
|
start_time = Time.now
|
@@ -44,20 +43,25 @@ module Gnawrnip
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
|
46
|
+
def session
|
47
|
+
Capybara.current_session
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
#
|
51
|
+
# @return [Gnawrnip::Image]
|
52
|
+
#
|
53
|
+
def shot
|
54
|
+
path = filepath
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
FileUtils.touch(path)
|
57
|
+
session.save_screenshot(path)
|
58
|
+
|
59
|
+
path
|
60
|
+
end
|
61
|
+
|
62
|
+
def filepath
|
63
|
+
SCREENSHOT_OUTPUT_DIR + '/gnawrnip-' + SecureRandom.uuid + '.png'
|
64
|
+
end
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
@@ -1,26 +1,32 @@
|
|
1
1
|
require 'base64'
|
2
|
-
require 'turnip_formatter/
|
3
|
-
require '
|
2
|
+
require 'turnip_formatter/step_template/exception'
|
3
|
+
require 'gnawrnip/developer'
|
4
4
|
|
5
5
|
module Gnawrnip
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
class StepScreenshot < TurnipFormatter::StepTemplate::Exception
|
7
|
+
on_failed :build
|
8
|
+
|
9
|
+
def self.scss
|
10
|
+
File.read(File.dirname(__FILE__) + '/gnawrnip.scss')
|
11
|
+
end
|
12
|
+
|
13
|
+
def build(example)
|
14
|
+
images = example.metadata[:gnawrnip][:screenshot]
|
15
|
+
|
16
|
+
case images.length
|
17
|
+
when 0
|
18
|
+
''
|
19
|
+
when 1
|
20
|
+
single_image(images.first)
|
21
|
+
else
|
22
|
+
animation_image(images)
|
20
23
|
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
21
27
|
|
22
|
-
|
23
|
-
|
28
|
+
def animation_image(paths)
|
29
|
+
text = <<-EOS
|
24
30
|
<div class="screenshot animation">
|
25
31
|
<div class="nav">
|
26
32
|
<div class="pager"></div>
|
@@ -33,128 +39,35 @@ module Gnawrnip
|
|
33
39
|
</div>
|
34
40
|
<div class="slides">
|
35
41
|
EOS
|
36
|
-
|
37
|
-
|
42
|
+
text += develop(paths)
|
43
|
+
text + <<-EOS
|
38
44
|
</div>
|
39
45
|
</div>
|
40
46
|
EOS
|
41
|
-
end
|
42
|
-
|
43
|
-
def single_image(path)
|
44
|
-
text = '<div class="screenshot">'
|
45
|
-
text += Gnawrnip.publisher.single(path)
|
46
|
-
text + '</div>'
|
47
|
-
end
|
48
47
|
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
module TurnipFormatter
|
53
|
-
Template.add_js_file('http://cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20130801/jquery.cycle2.min.js')
|
54
|
-
Template.add_css_file('http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css')
|
55
|
-
|
56
|
-
Template.add_js(<<-EOS)
|
57
|
-
$(function() {
|
58
|
-
$('.screenshot.animation').each(function() {
|
59
|
-
var slide = $(this).find('.slides').cycle({
|
60
|
-
timeout: #{Gnawrnip.frame_interval_ms},
|
61
|
-
autoHeight: "calc",
|
62
|
-
pager: $(this).find('div.nav .pager')
|
63
|
-
});
|
64
|
-
|
65
|
-
var nav = $(this).find('div.nav');
|
66
|
-
var playButton = nav.find('.play');
|
67
|
-
var pauseButton = nav.find('.pause');
|
68
|
-
var prevButton = nav.find('.prev');
|
69
|
-
var nextButton = nav.find('.next');
|
70
|
-
|
71
|
-
var setPauseManipulate = function() {
|
72
|
-
playButton.show();
|
73
|
-
pauseButton.hide();
|
74
|
-
prevButton.show();
|
75
|
-
nextButton.show();
|
76
|
-
};
|
77
|
-
|
78
|
-
var setPlayManipulate = function() {
|
79
|
-
playButton.hide();
|
80
|
-
pauseButton.show();
|
81
|
-
prevButton.hide();
|
82
|
-
nextButton.hide();
|
83
|
-
};
|
84
48
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
setPlayManipulate();
|
91
|
-
|
92
|
-
slide.on('cycle-pager-activated', function(event, opts) {
|
93
|
-
slide.cycle('pause');
|
94
|
-
});
|
95
|
-
|
96
|
-
slide.on('cycle-paused', function(event, opts) {
|
97
|
-
setPauseManipulate();
|
98
|
-
});
|
99
|
-
|
100
|
-
slide.on('cycle-resumed', function(event, opts) {
|
101
|
-
setPlayManipulate();
|
102
|
-
});
|
103
|
-
});
|
104
|
-
});
|
105
|
-
EOS
|
106
|
-
|
107
|
-
Template.add_scss(<<-EOS)
|
108
|
-
div#steps-statistics section.scenario {
|
109
|
-
ul.steps {
|
110
|
-
div.screenshot {
|
111
|
-
img {
|
112
|
-
max-width: 90%;
|
113
|
-
border: 2px solid black;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
div.screenshot.animation {
|
118
|
-
> div.nav {
|
119
|
-
text-align: center;
|
120
|
-
|
121
|
-
.pager {
|
122
|
-
margin-left: auto;
|
123
|
-
margin-right: auto;
|
124
|
-
|
125
|
-
span {
|
126
|
-
font-size: 50px;
|
127
|
-
display: inline;
|
128
|
-
color: #999999;
|
129
|
-
cursor: pointer;
|
130
|
-
|
131
|
-
&.cycle-pager-active {
|
132
|
-
color: red;
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
49
|
+
def single_image(path)
|
50
|
+
text = '<div class="screenshot">'
|
51
|
+
text += develop([path])
|
52
|
+
text + '</div>'
|
53
|
+
end
|
136
54
|
|
137
|
-
|
138
|
-
|
55
|
+
def develop(paths)
|
56
|
+
paths.map do |path|
|
57
|
+
image = developer.develop(path)
|
58
|
+
image.to_html
|
59
|
+
end.join
|
60
|
+
end
|
139
61
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
62
|
+
def developer
|
63
|
+
@developer ||= Developer.new
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
145
67
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}
|
155
|
-
EOS
|
68
|
+
TurnipFormatter.configure do |c|
|
69
|
+
c.add_javascript('http://cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20130801/jquery.cycle2.min.js')
|
70
|
+
c.add_stylesheet('http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css')
|
156
71
|
|
157
|
-
|
158
|
-
example.metadata[:gnawrnip][:screenshot] || []
|
159
|
-
end
|
72
|
+
c.add_javascript(File.dirname(__FILE__) + '/gnawrnip.js')
|
160
73
|
end
|
data/lib/gnawrnip/version.rb
CHANGED
data/lib/gnawrnip.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require "gnawrnip/version"
|
2
|
+
require 'turnip_formatter'
|
2
3
|
require 'gnawrnip/rspec'
|
3
4
|
require 'gnawrnip/photographer'
|
4
|
-
require 'gnawrnip/publisher'
|
5
5
|
|
6
6
|
module Gnawrnip
|
7
|
-
|
8
|
-
#
|
9
|
-
# [Integer] Time (millisecond) between each image in animation
|
10
|
-
#
|
11
|
-
attr_accessor :frame_interval_ms
|
7
|
+
SCREENSHOT_OUTPUT_DIR = File.expand_path('./gnawrnip_tmp')
|
12
8
|
|
9
|
+
class << self
|
13
10
|
#
|
14
11
|
# [Boolean] Whether to make animation GIF
|
15
12
|
#
|
@@ -38,6 +35,12 @@ module Gnawrnip
|
|
38
35
|
def ready!
|
39
36
|
require 'gnawrnip/ext/capybara/session' if animation?
|
40
37
|
require 'gnawrnip/step_screenshot'
|
38
|
+
|
39
|
+
FileUtils.mkdir_p(SCREENSHOT_OUTPUT_DIR)
|
40
|
+
end
|
41
|
+
|
42
|
+
def finish!
|
43
|
+
FileUtils.rm_rf(SCREENSHOT_OUTPUT_DIR)
|
41
44
|
end
|
42
45
|
|
43
46
|
def animation?
|
@@ -48,18 +51,13 @@ module Gnawrnip
|
|
48
51
|
@photographer ||= Photographer.new
|
49
52
|
end
|
50
53
|
|
51
|
-
def
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def publisher_driver=(driver)
|
56
|
-
warn "DEPRECATED: `publisher_driver` option is deprecated (not used)."
|
54
|
+
def frame_interval_ms=(_)
|
55
|
+
warn 'DEPRECATED: `frame_interval_ms` option is deprecated (not used).'
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
60
|
Gnawrnip.configure do |c|
|
62
|
-
c.frame_interval_ms = 1000
|
63
61
|
c.make_animation = true
|
64
62
|
c.max_frame_size = nil
|
65
63
|
end
|
@@ -3,19 +3,17 @@ require 'gnawrnip/developer'
|
|
3
3
|
|
4
4
|
module Gnawrnip
|
5
5
|
describe Developer do
|
6
|
-
let(:developer)
|
7
|
-
Developer.new
|
8
|
-
end
|
6
|
+
let(:developer) { described_class.new }
|
9
7
|
|
10
8
|
before do
|
11
|
-
Image.
|
9
|
+
allow_any_instance_of(Image).to receive(:analysis)
|
12
10
|
end
|
13
11
|
|
14
12
|
context 'No given Gnawrnip.max_frame_size' do
|
15
13
|
describe '.develop' do
|
16
14
|
before do
|
17
15
|
Gnawrnip.max_frame_size = nil
|
18
|
-
Developer.
|
16
|
+
expect(Developer).not_to receive(:resize)
|
19
17
|
end
|
20
18
|
|
21
19
|
it { developer.develop(nil) }
|
@@ -27,9 +25,9 @@ module Gnawrnip
|
|
27
25
|
describe '.develop' do
|
28
26
|
before do
|
29
27
|
Gnawrnip.max_frame_size = 300
|
30
|
-
Image.
|
31
|
-
Image.
|
32
|
-
Image.
|
28
|
+
allow_any_instance_of(Image).to receive(:width).and_return(640)
|
29
|
+
allow_any_instance_of(Image).to receive(:height).and_return(480)
|
30
|
+
expect_any_instance_of(Image).to receive(:resize).with(300, 225)
|
33
31
|
end
|
34
32
|
|
35
33
|
it { developer.develop(nil) }
|
@@ -40,9 +38,9 @@ module Gnawrnip
|
|
40
38
|
describe '.develop' do
|
41
39
|
before do
|
42
40
|
Gnawrnip.max_frame_size = 400
|
43
|
-
Image.
|
44
|
-
Image.
|
45
|
-
Image.
|
41
|
+
allow_any_instance_of(Image).to receive(:width).and_return(480)
|
42
|
+
allow_any_instance_of(Image).to receive(:height).and_return(640)
|
43
|
+
expect_any_instance_of(Image).to receive(:resize).with(300, 400)
|
46
44
|
end
|
47
45
|
|
48
46
|
it { developer.develop(nil) }
|
@@ -53,9 +51,9 @@ module Gnawrnip
|
|
53
51
|
describe '.develop' do
|
54
52
|
before do
|
55
53
|
Gnawrnip.max_frame_size = 1024
|
56
|
-
Image.
|
57
|
-
Image.
|
58
|
-
Image.
|
54
|
+
allow_any_instance_of(Image).to receive(:width).and_return(640)
|
55
|
+
allow_any_instance_of(Image).to receive(:height).and_return(480)
|
56
|
+
expect_any_instance_of(Image).not_to receive(:resize)
|
59
57
|
end
|
60
58
|
|
61
59
|
it { developer.develop(nil) }
|
data/spec/gnawrnip/image_spec.rb
CHANGED
@@ -4,12 +4,12 @@ require 'gnawrnip/image'
|
|
4
4
|
module Gnawrnip
|
5
5
|
describe Image do
|
6
6
|
before do
|
7
|
-
Image.
|
7
|
+
allow_any_instance_of(Image).to receive(:canvas).and_return(canvas)
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:image) do
|
11
11
|
Image.new(GnawrnipTest.image('gnawrnip/image'))
|
12
|
-
|
12
|
+
end
|
13
13
|
|
14
14
|
context 'image size is 640x480' do
|
15
15
|
let(:canvas) do
|
@@ -33,12 +33,12 @@ module Gnawrnip
|
|
33
33
|
describe '.resize' do
|
34
34
|
let(:canvas) do
|
35
35
|
canvas = super()
|
36
|
-
canvas.
|
36
|
+
expect(canvas).to receive(:resample_bilinear).with(320, 240).and_return(canvas)
|
37
37
|
canvas
|
38
38
|
end
|
39
39
|
|
40
40
|
before do
|
41
|
-
Image.
|
41
|
+
expect_any_instance_of(Image).to receive(:analysis).twice
|
42
42
|
end
|
43
43
|
|
44
44
|
it { image.resize(320, 240) }
|
@@ -3,12 +3,10 @@ require 'gnawrnip/photographer'
|
|
3
3
|
|
4
4
|
module Gnawrnip
|
5
5
|
describe Photographer do
|
6
|
-
let(:photographer)
|
7
|
-
Photographer.new
|
8
|
-
end
|
6
|
+
let(:photographer) { described_class.new }
|
9
7
|
|
10
8
|
before do
|
11
|
-
Screenshot.
|
9
|
+
allow(Screenshot).to receive(:take).and_return('foo')
|
12
10
|
photographer.reset!
|
13
11
|
photographer.take_shot
|
14
12
|
photographer.take_shot
|
data/spec/gnawrnip/rspec_spec.rb
CHANGED
@@ -16,8 +16,8 @@ module Gnawrnip
|
|
16
16
|
end
|
17
17
|
|
18
18
|
before do
|
19
|
-
Gnawrnip.photographer.
|
20
|
-
Gnawrnip.photographer.
|
19
|
+
allow(Gnawrnip.photographer).to receive(:take_shot)
|
20
|
+
allow(Gnawrnip.photographer).to receive(:frames) { ['aiueo', nil, 'lllll'] }
|
21
21
|
end
|
22
22
|
|
23
23
|
context '"turnip" spec group' do
|
@@ -6,7 +6,7 @@ module Gnawrnip
|
|
6
6
|
context 'Not support save_screenshot' do
|
7
7
|
describe '.tale' do
|
8
8
|
before do
|
9
|
-
GnawrnipTest::Session.
|
9
|
+
allow_any_instance_of(GnawrnipTest::Session).to receive(:save_screenshot) do
|
10
10
|
raise Capybara::NotSupportedByDriverError
|
11
11
|
end
|
12
12
|
end
|
@@ -20,7 +20,7 @@ module Gnawrnip
|
|
20
20
|
context 'raise unknown error' do
|
21
21
|
describe '.take' do
|
22
22
|
before do
|
23
|
-
GnawrnipTest::Session.
|
23
|
+
allow_any_instance_of(GnawrnipTest::Session).to receive(:save_screenshot) do
|
24
24
|
raise Timeout::Error
|
25
25
|
end
|
26
26
|
end
|
@@ -28,7 +28,7 @@ module Gnawrnip
|
|
28
28
|
context 'timeout' do
|
29
29
|
before do
|
30
30
|
now = Time.now
|
31
|
-
Time.
|
31
|
+
allow(Time).to receive(:now).and_return(now, now + 3)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should raise Timeout Error' do
|
@@ -45,7 +45,7 @@ module Gnawrnip
|
|
45
45
|
context 'success screenshot' do
|
46
46
|
describe '.take' do
|
47
47
|
before do
|
48
|
-
Screenshot.
|
48
|
+
expect(Screenshot).to receive(:shot).once
|
49
49
|
end
|
50
50
|
|
51
51
|
it { Screenshot.take }
|
@@ -3,44 +3,39 @@ require 'gnawrnip/step_screenshot'
|
|
3
3
|
|
4
4
|
module Gnawrnip
|
5
5
|
describe StepScreenshot do
|
6
|
-
let(:template) {
|
7
|
-
|
8
|
-
it 'exists failure step template' do
|
9
|
-
expect(TurnipFormatter::Step::Failure.templates).to have_key template
|
10
|
-
end
|
6
|
+
let(:template) { described_class.new }
|
11
7
|
|
12
8
|
describe '.build' do
|
13
|
-
|
9
|
+
before :each do
|
10
|
+
allow(template).to receive(:develop).and_return('')
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:example) do
|
14
|
+
metadata = { gnawrnip: { screenshot: paths } }
|
15
|
+
double('example', metadata: metadata)
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { template.build(example) }
|
14
19
|
|
15
20
|
context 'has multiple data' do
|
16
|
-
let(:
|
17
|
-
[
|
18
|
-
double(to_base64: 'aiueo', width: 640, height: 480),
|
19
|
-
double(to_base64: '12345', width: 512, height: 200),
|
20
|
-
double(to_base64: 'abcde', width: 640, height: 320)
|
21
|
-
]
|
22
|
-
end
|
21
|
+
let(:paths) { ['/path/to/A.png', '/path/to/B.png', '/path/to/C.png'] }
|
23
22
|
|
24
23
|
it 'should get image tag and source that base64 encoded' do
|
25
24
|
should include '<div class="screenshot animation">'
|
26
|
-
should include '<img width="640" height="480" src="data:image/png;base64,aiueo"/>'
|
27
|
-
should include '<img width="512" height="200" src="data:image/png;base64,12345"/>'
|
28
|
-
should include '<img width="640" height="320" src="data:image/png;base64,abcde"/>'
|
29
25
|
should include '<div class="nav">'
|
30
26
|
end
|
31
27
|
end
|
32
28
|
|
33
29
|
context 'has single data' do
|
34
|
-
let(:
|
35
|
-
it
|
30
|
+
let(:paths) { ['/path/to/A.png'] }
|
31
|
+
it do
|
36
32
|
should include '<div class="screenshot">'
|
37
|
-
should include '<img width="640" height="480" src="data:image/png;base64,abcde"/></div>'
|
38
33
|
should_not include '<div class="nav">'
|
39
|
-
|
34
|
+
end
|
40
35
|
end
|
41
36
|
|
42
37
|
context 'has no data' do
|
43
|
-
let(:
|
38
|
+
let(:paths) { [] }
|
44
39
|
it { should eq '' }
|
45
40
|
end
|
46
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnawrnip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wataru MIYAGUNI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.3.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: oily_png
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,14 +132,18 @@ files:
|
|
132
132
|
- lib/gnawrnip.rb
|
133
133
|
- lib/gnawrnip/developer.rb
|
134
134
|
- lib/gnawrnip/ext/capybara/session.rb
|
135
|
+
- lib/gnawrnip/gnawrnip.js
|
136
|
+
- lib/gnawrnip/gnawrnip.scss
|
135
137
|
- lib/gnawrnip/image.rb
|
136
138
|
- lib/gnawrnip/no_screenshot.png
|
137
139
|
- lib/gnawrnip/photographer.rb
|
138
|
-
- lib/gnawrnip/publisher.rb
|
139
140
|
- lib/gnawrnip/rspec.rb
|
140
141
|
- lib/gnawrnip/screenshot.rb
|
141
142
|
- lib/gnawrnip/step_screenshot.rb
|
142
143
|
- lib/gnawrnip/version.rb
|
144
|
+
- spec/gemfiles/Gemfile-rspec-2.14.x
|
145
|
+
- spec/gemfiles/Gemfile-rspec-2.99.x
|
146
|
+
- spec/gemfiles/Gemfile-rspec-3.0.x
|
143
147
|
- spec/gnawrnip/developer_spec.rb
|
144
148
|
- spec/gnawrnip/image_spec.rb
|
145
149
|
- spec/gnawrnip/photographer_spec.rb
|
@@ -167,11 +171,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
171
|
version: '0'
|
168
172
|
requirements: []
|
169
173
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.2.
|
174
|
+
rubygems_version: 2.2.2
|
171
175
|
signing_key:
|
172
176
|
specification_version: 4
|
173
177
|
summary: Add-on for TurnipFormatter with Capybara
|
174
178
|
test_files:
|
179
|
+
- spec/gemfiles/Gemfile-rspec-2.14.x
|
180
|
+
- spec/gemfiles/Gemfile-rspec-2.99.x
|
181
|
+
- spec/gemfiles/Gemfile-rspec-3.0.x
|
175
182
|
- spec/gnawrnip/developer_spec.rb
|
176
183
|
- spec/gnawrnip/image_spec.rb
|
177
184
|
- spec/gnawrnip/photographer_spec.rb
|
data/lib/gnawrnip/publisher.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module Gnawrnip
|
4
|
-
class Publisher
|
5
|
-
|
6
|
-
#
|
7
|
-
# @params [Array] images Array of Gnawrnip::Image
|
8
|
-
#
|
9
|
-
def animation(images)
|
10
|
-
images.map { |image| image_tag(image) }.join
|
11
|
-
end
|
12
|
-
|
13
|
-
#
|
14
|
-
# @params [Gnawrnip::Image] image
|
15
|
-
#
|
16
|
-
def single(image)
|
17
|
-
image_tag(image)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def image_tag(image, format = :png)
|
23
|
-
width = image.width
|
24
|
-
height = image.height
|
25
|
-
data = image.to_base64
|
26
|
-
%Q|<img width="#{width}" height="#{height}" src="data:image/#{format.to_s};base64,#{data}"/>|
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|