cucumber-cinema 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +3 -13
- data/VERSION +1 -1
- data/cucumber-cinema.gemspec +3 -3
- data/lib/cucumber-cinema.rb +20 -32
- data/lib/cucumber_cinema/camera.rb +8 -26
- data/lib/cucumber_cinema/view_strategy.rb +24 -0
- metadata +5 -5
- data/lib/cucumber_cinema/path_strategy.rb +0 -23
data/README.rdoc
CHANGED
@@ -17,24 +17,14 @@ And bundle bundle install
|
|
17
17
|
Install wkhtmltoimage (https://github.com/csquared/IMGKit)
|
18
18
|
|
19
19
|
Add this to features/support/cucumber_screenhot.rb
|
20
|
+
CucumberCinema::ViewSelectStrategy::new_movie
|
20
21
|
After do
|
21
|
-
|
22
|
+
screenshot_emails
|
22
23
|
end
|
23
24
|
|
24
25
|
Run your cucumber suite and screenshots will be generated in directory tmp/capybara
|
25
26
|
|
26
|
-
|
27
|
-
Spork.each_run do
|
28
|
-
CucumberCinema::new_movie
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
Spork.prefork do
|
33
|
-
World(CucumberCinema)
|
34
|
-
end
|
35
|
-
|
36
|
-
If you want to take a screenhot of a scenario regardless of what cinema decides, tag it with @action
|
37
|
-
|
27
|
+
Doesn't workwith spork yet
|
38
28
|
== Contributing to cucumber-cinema
|
39
29
|
|
40
30
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
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.
|
8
|
+
s.version = "0.6.0"
|
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-11}
|
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 = [
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"cucumber-cinema.gemspec",
|
28
28
|
"lib/cucumber-cinema.rb",
|
29
29
|
"lib/cucumber_cinema/camera.rb",
|
30
|
-
"lib/cucumber_cinema/
|
30
|
+
"lib/cucumber_cinema/view_strategy.rb",
|
31
31
|
"public/galleria/LICENSE",
|
32
32
|
"public/galleria/galleria-1.2.5.js",
|
33
33
|
"public/galleria/galleria-1.2.5.min.js",
|
data/lib/cucumber-cinema.rb
CHANGED
@@ -1,45 +1,33 @@
|
|
1
1
|
require 'capybara/util/save_and_open_page'
|
2
2
|
require 'cucumber_cinema/camera'
|
3
|
-
require 'cucumber_cinema/
|
3
|
+
require 'cucumber_cinema/view_strategy'
|
4
4
|
module CucumberCinema
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if take_screenshot?(scenario, :url=>current_url)
|
13
|
-
BODY_HASHES<<path
|
14
|
-
CucumberCinema::Camera.new(options).take_screenshot(body)
|
6
|
+
def screenshot_emails(options)
|
7
|
+
current_emails = ActionMailer::Base.deliveries.uniq { |x| x.subject }
|
8
|
+
new_emails = current_emails.select { |k, v| !$cucumber_cinema_emails.key?(k.subject) }
|
9
|
+
new_emails.each { |k, v| $cucumber_cinema_emails[k.subject]=v }
|
10
|
+
new_emails.each_with_index do |e, i|
|
11
|
+
CucumberCinema::Camera.new(options).take_screenshot("<h1>#{e.subject}</h1><pre>#{e}</pre><hr />")
|
15
12
|
end
|
16
|
-
|
17
|
-
collect_emails(options)
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.new_movie
|
22
|
-
BODY_HASHES.clear
|
23
|
-
SCREENSHOT_DIR_NAME.clear
|
24
|
-
SCREENSHOT_DIR_NAME<<"#{Time.new.strftime("%Y%m%d%H%M%S")}"
|
25
|
-
EMAILS.clear
|
26
13
|
end
|
27
14
|
|
28
|
-
|
15
|
+
end
|
29
16
|
|
17
|
+
#DOESN' WORK WITH Spork Yet
|
18
|
+
module ActionView
|
19
|
+
module Rendering
|
30
20
|
|
31
|
-
|
32
|
-
def take_screenshot?(scenario, options)
|
33
|
-
CucumberCinema::PathStrategy.new.take_screenshot?(scenario, options)
|
34
|
-
end
|
21
|
+
alias_method :render_old, :render
|
35
22
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
23
|
+
def render(options = {}, locals = {}, &block)
|
24
|
+
if CucumberCinema::ViewSelectStrategy.take_screenshot?(request)
|
25
|
+
body = render_old(options, locals, &block)
|
26
|
+
::CucumberCinema::Camera.new.take_screenshot(body)
|
27
|
+
end
|
28
|
+
render_old(options, locals, &block)
|
42
29
|
end
|
43
30
|
end
|
44
|
-
|
45
31
|
end
|
32
|
+
|
33
|
+
World(CucumberCinema)
|
@@ -1,23 +1,11 @@
|
|
1
1
|
module CucumberCinema
|
2
2
|
class Camera
|
3
3
|
|
4
|
-
def initialize(options={})
|
5
|
-
if options[:location]
|
6
|
-
@location=options[:location]
|
7
|
-
else
|
8
|
-
@location="#{Rails.root}/tmp/screenshots/"
|
9
|
-
end
|
10
|
-
|
11
|
-
@prefix = options[:prefix].present? ? options[:prefix] : "take-"
|
12
|
-
@pictures=[]
|
13
|
-
end
|
14
|
-
|
15
4
|
def take_screenshot(body)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Capybara.
|
20
|
-
`wkhtmltoimage #{Capybara.save_and_open_page_path}/#{filename}.html #{@location}/#{filename}.png`
|
5
|
+
create_directory($cucumber_cinema_dir_name)
|
6
|
+
filename="#{$cucumber_cinema_dir_name}/#{$cucumber_cinema_prefix}-#{rand(10**10)}"
|
7
|
+
Capybara.save_page(body.to_str, "#{filename}.html")
|
8
|
+
`wkhtmltoimage #{Capybara.save_and_open_page_path}/#{filename}.html #{$cucumber_cinema_location}/#{filename}.png`
|
21
9
|
end
|
22
10
|
|
23
11
|
protected
|
@@ -27,17 +15,11 @@ module CucumberCinema
|
|
27
15
|
if !Dir.exist?("#{Capybara.save_and_open_page_path}/#{screenshot_dir_name}")
|
28
16
|
Dir.mkdir("#{Capybara.save_and_open_page_path}/#{screenshot_dir_name}")
|
29
17
|
end
|
30
|
-
Dir.mkdir("#{
|
31
|
-
|
18
|
+
Dir.mkdir("#{$cucumber_cinema_location}") if !Dir.exist?($cucumber_cinema_location)
|
19
|
+
if !Dir.exist?("#{$cucumber_cinema_location}/#{screenshot_dir_name}")
|
20
|
+
Dir.mkdir("#{$cucumber_cinema_location}/#{screenshot_dir_name}")
|
21
|
+
end
|
32
22
|
end
|
33
|
-
#
|
34
|
-
# def create_theater
|
35
|
-
# @files=@pictures
|
36
|
-
# html_path="#{File.dirname(__FILE__)}/../../public/index.html.erb"
|
37
|
-
# html=ERB.new(File.read(html_path)).result
|
38
|
-
# File.open("#{@location}/index.html", 'w') { |f| f.write(doc) }
|
39
|
-
#
|
40
|
-
# end
|
41
23
|
|
42
24
|
end
|
43
25
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CucumberCinema
|
2
|
+
module ViewSelectStrategy
|
3
|
+
|
4
|
+
def self.take_screenshot?(request)
|
5
|
+
return false unless request
|
6
|
+
current_shot = "#{request.filtered_parameters["controller"]}-#{request.filtered_parameters["action"]}-#{request.method}"
|
7
|
+
if !$cucumber_cinema_screenshots[current_shot]
|
8
|
+
$cucumber_cinema_screenshots[current_shot] = 1
|
9
|
+
true
|
10
|
+
else
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.new_movie(options={})
|
16
|
+
$cucumber_cinema_screenshots = {}
|
17
|
+
$cucumber_cinema_dir_name = "#{Time.new.strftime("%Y%m%d%H%M%S")}"
|
18
|
+
$cucumber_cinema_emails = {}
|
19
|
+
$cucumber_cinema_location=options[:location] || "#{Rails.root}/tmp/screenshots/"
|
20
|
+
$cucumber_cinema_prefix = options[:prefix].present? ? options[:prefix] : "take"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
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
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
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-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|
@@ -125,7 +125,7 @@ files:
|
|
125
125
|
- cucumber-cinema.gemspec
|
126
126
|
- lib/cucumber-cinema.rb
|
127
127
|
- lib/cucumber_cinema/camera.rb
|
128
|
-
- lib/cucumber_cinema/
|
128
|
+
- lib/cucumber_cinema/view_strategy.rb
|
129
129
|
- public/galleria/LICENSE
|
130
130
|
- public/galleria/galleria-1.2.5.js
|
131
131
|
- public/galleria/galleria-1.2.5.min.js
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module CucumberCinema
|
2
|
-
class PathStrategy
|
3
|
-
|
4
|
-
#determines whether or not to take a screenshot
|
5
|
-
def take_screenshot?(scenario, options={})
|
6
|
-
current_url=options[:url]
|
7
|
-
#always take screenshots of scenario's with tag @action
|
8
|
-
if scenario and scenario.source_tag_names.include?("@action")
|
9
|
-
return true
|
10
|
-
end
|
11
|
-
if current_url
|
12
|
-
#remove parameters and such
|
13
|
-
path = URI.parse(current_url).path
|
14
|
-
#remove model id's
|
15
|
-
path = current_url.gsub(/\d+/, '')
|
16
|
-
!BODY_HASHES.include?(path)
|
17
|
-
else
|
18
|
-
true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|