cucumber-cinema 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -2
- data/VERSION +1 -1
- data/cucumber-cinema.gemspec +1 -1
- data/lib/cucumber-cinema.rb +17 -4
- data/lib/cucumber_cinema/camera.rb +3 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
= cucumber-cinema
|
2
2
|
|
3
|
-
Take a series of screenshots while runing your cucumber test suite
|
3
|
+
Take a series of screenshots while runing your cucumber test suite. Movie is composed of screenshots of pages as
|
4
|
+
they appear in the end of each scenario. Cinematographer attempts to avoid duplicates by taking screenshots of
|
5
|
+
pages that have unique urls (without integer values that may represent model ids). In addition, screen shots of
|
6
|
+
emails with distinct subject are also taken
|
4
7
|
|
5
8
|
== Installation
|
6
9
|
|
@@ -15,7 +18,7 @@ Install wkhtmltoimage (https://github.com/csquared/IMGKit)
|
|
15
18
|
|
16
19
|
Add this to features/support/cucumber_screenhot.rb
|
17
20
|
After do
|
18
|
-
embed_screenshot
|
21
|
+
embed_screenshot(scenario, :prefix=>"my-refix") if defined?(CucumberCinema)
|
19
22
|
end
|
20
23
|
|
21
24
|
Run your cucumber suite and screenshots will be generated in directory tmp/capybara
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/cucumber-cinema.gemspec
CHANGED
data/lib/cucumber-cinema.rb
CHANGED
@@ -5,28 +5,41 @@ module CucumberCinema
|
|
5
5
|
|
6
6
|
BODY_HASHES=[]
|
7
7
|
SCREENSHOT_DIR_NAME=["#{Time.new.strftime("%Y%m%d%H%M%S")}"]
|
8
|
+
EMAILS={}
|
8
9
|
|
9
|
-
def embed_screenshot(scenario=nil,options={})
|
10
|
+
def embed_screenshot(scenario=nil, options={})
|
10
11
|
|
11
|
-
if take_screenshot?(scenario
|
12
|
+
if take_screenshot?(scenario, :url=>current_url)
|
12
13
|
BODY_HASHES<<path
|
13
14
|
CucumberCinema::Camera.new(options).take_screenshot(body)
|
14
15
|
end
|
15
16
|
|
17
|
+
collect_emails(options)
|
18
|
+
|
16
19
|
end
|
17
20
|
|
18
21
|
def self.new_movie
|
19
22
|
BODY_HASHES.clear
|
20
23
|
SCREENSHOT_DIR_NAME.clear
|
21
24
|
SCREENSHOT_DIR_NAME<<"#{Time.new.strftime("%Y%m%d%H%M%S")}"
|
25
|
+
EMAILS.clear
|
22
26
|
end
|
23
27
|
|
24
28
|
protected
|
25
29
|
|
26
30
|
|
27
31
|
#determines whether or not to take a screenshot
|
28
|
-
def take_screenshot?(scenario,options)
|
32
|
+
def take_screenshot?(scenario, options)
|
29
33
|
CucumberCinema::PathStrategy.new.take_screenshot?(scenario, options)
|
30
34
|
end
|
31
35
|
|
32
|
-
|
36
|
+
def collect_emails(options)
|
37
|
+
current_emails = ActionMailer::Base.deliveries.uniq{|x|x.subject}
|
38
|
+
new_emails = current_emails.select { |k, v| !EMAILS.key?(k.subject) }
|
39
|
+
new_emails.each { |k, v| EMAILS[k.subject]=v }
|
40
|
+
new_emails.each_with_index do |e, i|
|
41
|
+
CucumberCinema::Camera.new(options).take_screenshot("<h1>#{e.subject}</h1><pre>#{e}</pre><hr />")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -7,13 +7,15 @@ module CucumberCinema
|
|
7
7
|
else
|
8
8
|
@location="#{Rails.root}/tmp/screenshots/"
|
9
9
|
end
|
10
|
+
|
11
|
+
@prefix = options[:prefix].present? ? options[:prefix] : "take-"
|
10
12
|
@pictures=[]
|
11
13
|
end
|
12
14
|
|
13
15
|
def take_screenshot(body)
|
14
16
|
screenshot_dir_name = SCREENSHOT_DIR_NAME.first
|
15
17
|
create_directory(screenshot_dir_name)
|
16
|
-
filename="#{screenshot_dir_name}
|
18
|
+
filename="#{screenshot_dir_name}/#{@prefix}-#{rand(10**10)}"
|
17
19
|
Capybara.save_page(body, "#{filename}.html")
|
18
20
|
`wkhtmltoimage #{Capybara.save_and_open_page_path}/#{filename}.html #{@location}/#{filename}.png`
|
19
21
|
end
|