cucumber-cinema 0.4.2 → 0.5.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 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.4.2
1
+ 0.5.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cucumber-cinema}
8
- s.version = "0.4.2"
8
+ s.version = "0.5.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}]
@@ -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,:url=>current_url)
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
- end
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}/rentini-#{rand(10**10)}"
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
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 2
10
- version: 0.4.2
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilya Katz