cucumber-cinema 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/README.rdoc +4 -0
- data/VERSION +1 -1
- data/cucumber-cinema.gemspec +5 -2
- data/lib/cucumber_cinema/camera.rb +30 -8
- data/lib/cucumber_cinema/view_strategy.rb +12 -0
- metadata +25 -11
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -18,9 +18,12 @@ GEM
|
|
18
18
|
git (>= 1.2.5)
|
19
19
|
rake
|
20
20
|
json (1.5.3)
|
21
|
+
mini_magick (3.3)
|
22
|
+
subexec (~> 0.1.0)
|
21
23
|
rake (0.9.2)
|
22
24
|
rcov (0.9.9)
|
23
25
|
shoulda (2.11.3)
|
26
|
+
subexec (0.1.0)
|
24
27
|
term-ansicolor (1.0.6)
|
25
28
|
|
26
29
|
PLATFORMS
|
@@ -31,5 +34,6 @@ DEPENDENCIES
|
|
31
34
|
cucumber
|
32
35
|
imgkit
|
33
36
|
jeweler (~> 1.6.2)
|
37
|
+
mini_magick
|
34
38
|
rcov
|
35
39
|
shoulda
|
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
data/cucumber-cinema.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cucumber-cinema}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Ilya Katz}]
|
12
|
-
s.date = %q{2011-08-
|
12
|
+
s.date = %q{2011-08-29}
|
13
13
|
s.description = %q{Take a series of screenshots while running your cucumber test suite}
|
14
14
|
s.email = %q{ilyakatz@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -65,6 +65,7 @@ Gem::Specification.new do |s|
|
|
65
65
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
66
66
|
s.add_runtime_dependency(%q<imgkit>, [">= 0"])
|
67
67
|
s.add_runtime_dependency(%q<cucumber>, [">= 0"])
|
68
|
+
s.add_runtime_dependency(%q<mini_magick>, [">= 0"])
|
68
69
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
69
70
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
71
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
@@ -72,6 +73,7 @@ Gem::Specification.new do |s|
|
|
72
73
|
else
|
73
74
|
s.add_dependency(%q<imgkit>, [">= 0"])
|
74
75
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
76
|
+
s.add_dependency(%q<mini_magick>, [">= 0"])
|
75
77
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
76
78
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
77
79
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
@@ -80,6 +82,7 @@ Gem::Specification.new do |s|
|
|
80
82
|
else
|
81
83
|
s.add_dependency(%q<imgkit>, [">= 0"])
|
82
84
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
85
|
+
s.add_dependency(%q<mini_magick>, [">= 0"])
|
83
86
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
84
87
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
85
88
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
@@ -1,20 +1,29 @@
|
|
1
1
|
module CucumberCinema
|
2
2
|
class Camera
|
3
3
|
|
4
|
+
def store_image(png_filename, html_filename, destination_dir)
|
5
|
+
`wkhtmltoimage #{Capybara.save_and_open_page_path}/#{$cucumber_cinema_dir_name}/#{html_filename} #{destination_dir}/#{png_filename}`
|
6
|
+
end
|
7
|
+
|
4
8
|
def take_screenshot(body, options={})
|
5
|
-
|
9
|
+
prepare($cucumber_cinema_dir_name)
|
10
|
+
|
6
11
|
name = options[:name] || rand(10**10)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
$
|
11
|
-
|
12
|
-
|
12
|
+
html_filename="#{$cucumber_cinema_prefix}-#{name}.html"
|
13
|
+
png_filename = "#{$cucumber_cinema_prefix}-#{name}.png"
|
14
|
+
|
15
|
+
Capybara.save_page(body.to_str, "#{$cucumber_cinema_dir_name}/#{html_filename}")
|
16
|
+
|
17
|
+
destination_dir ="#{$cucumber_cinema_location}/#{$cucumber_cinema_dir_name}"
|
18
|
+
store_image(png_filename, html_filename, destination_dir)
|
19
|
+
thumb = thumbnail(destination_dir, png_filename)
|
20
|
+
|
21
|
+
store_hash(png_filename, name, thumb)
|
13
22
|
end
|
14
23
|
|
15
24
|
protected
|
16
25
|
|
17
|
-
def
|
26
|
+
def prepare(screenshot_dir_name)
|
18
27
|
Dir.mkdir(Capybara.save_and_open_page_path) if !Dir.exist?(Capybara.save_and_open_page_path)
|
19
28
|
if !Dir.exist?("#{Capybara.save_and_open_page_path}/#{screenshot_dir_name}")
|
20
29
|
Dir.mkdir("#{Capybara.save_and_open_page_path}/#{screenshot_dir_name}")
|
@@ -25,5 +34,18 @@ module CucumberCinema
|
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
37
|
+
def thumbnail(dir, filename)
|
38
|
+
thumbnail_name = "#{dir}/thumb_#{filename}"
|
39
|
+
image = MiniMagick::Image.open("#{dir}/#{filename}")
|
40
|
+
image.resize "100x100"
|
41
|
+
image.write thumbnail_name
|
42
|
+
"thumb_#{filename}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def store_hash(file, name, thumb)
|
46
|
+
$cucumber_cinema_all_screenshots<<
|
47
|
+
{"thumbnail_url"=>"./#{thumb}", "url"=>"./#{file}", "name"=>name}
|
48
|
+
end
|
49
|
+
|
28
50
|
end
|
29
51
|
end
|
@@ -31,9 +31,21 @@ module CucumberCinema
|
|
31
31
|
$cucumber_cinema_link=options[:link_location] || "#{Rails.root}/tmp/latest_screenshots"
|
32
32
|
Dir.mkdir("#{$cucumber_cinema_location}") unless Dir.exist?($cucumber_cinema_location)
|
33
33
|
|
34
|
+
create_link
|
35
|
+
copy_assets
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.create_link
|
34
39
|
File.delete($cucumber_cinema_link) if File.exists?($cucumber_cinema_link)
|
35
40
|
`ln -s #{$cucumber_cinema_location}/#{$cucumber_cinema_dir_name} #{$cucumber_cinema_link} `
|
36
41
|
end
|
37
42
|
|
43
|
+
def self.copy_assets
|
44
|
+
Dir["#{Gem.searcher.find('cucumber-cinema').full_gem_path}/public/*"].each do |asset|
|
45
|
+
`cp -r #{asset} #{$cucumber_cinema_location}/#{$cucumber_cinema_dir_name}/`
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
38
50
|
end
|
39
51
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-cinema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ilya Katz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
name: cucumber
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
type: :
|
49
|
+
type: :runtime
|
50
50
|
requirement: &id003 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
@@ -57,11 +57,25 @@ dependencies:
|
|
57
57
|
- 0
|
58
58
|
version: "0"
|
59
59
|
prerelease: false
|
60
|
-
name:
|
60
|
+
name: mini_magick
|
61
61
|
version_requirements: *id003
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
type: :development
|
64
64
|
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
prerelease: false
|
74
|
+
name: shoulda
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
type: :development
|
78
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
65
79
|
none: false
|
66
80
|
requirements:
|
67
81
|
- - ~>
|
@@ -74,10 +88,10 @@ dependencies:
|
|
74
88
|
version: 1.0.0
|
75
89
|
prerelease: false
|
76
90
|
name: bundler
|
77
|
-
version_requirements: *
|
91
|
+
version_requirements: *id005
|
78
92
|
- !ruby/object:Gem::Dependency
|
79
93
|
type: :development
|
80
|
-
requirement: &
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
81
95
|
none: false
|
82
96
|
requirements:
|
83
97
|
- - ~>
|
@@ -90,10 +104,10 @@ dependencies:
|
|
90
104
|
version: 1.6.2
|
91
105
|
prerelease: false
|
92
106
|
name: jeweler
|
93
|
-
version_requirements: *
|
107
|
+
version_requirements: *id006
|
94
108
|
- !ruby/object:Gem::Dependency
|
95
109
|
type: :development
|
96
|
-
requirement: &
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
97
111
|
none: false
|
98
112
|
requirements:
|
99
113
|
- - ">="
|
@@ -104,7 +118,7 @@ dependencies:
|
|
104
118
|
version: "0"
|
105
119
|
prerelease: false
|
106
120
|
name: rcov
|
107
|
-
version_requirements: *
|
121
|
+
version_requirements: *id007
|
108
122
|
description: Take a series of screenshots while running your cucumber test suite
|
109
123
|
email: ilyakatz@gmail.com
|
110
124
|
executables: []
|