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 CHANGED
@@ -5,6 +5,7 @@ source "http://rubygems.org"
5
5
 
6
6
  gem "imgkit"
7
7
  gem 'cucumber'
8
+ gem 'mini_magick'
8
9
 
9
10
  # Add dependencies to develop your gem here.
10
11
  # Include everything needed to run rake, tests, features, etc.
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
@@ -22,6 +22,10 @@ Add this to features/support/cucumber_screenhot.rb
22
22
  screenshot_emails
23
23
  end
24
24
 
25
+ at_exit do
26
+ puts $cucumber_cinema_all_screenshots
27
+ end
28
+
25
29
  Enable cucumber cinema
26
30
  export CUCUMBER_CINEMA=true
27
31
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -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.1"
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-27}
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
- create_directory($cucumber_cinema_dir_name)
9
+ prepare($cucumber_cinema_dir_name)
10
+
6
11
  name = options[:name] || rand(10**10)
7
- filename="#{$cucumber_cinema_dir_name}/#{$cucumber_cinema_prefix}-#{name}"
8
- Capybara.save_page(body.to_str, "#{filename}.html")
9
- screenshot_name="#{$cucumber_cinema_location}/#{filename}.png"
10
- $cucumber_cinema_all_screenshots<<
11
- {"thumbnail_url"=>screenshot_name, "url"=>screenshot_name, "name"=>name}
12
- `wkhtmltoimage #{Capybara.save_and_open_page_path}/#{filename}.html #{screenshot_name}`
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 create_directory(screenshot_dir_name)
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: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
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-27 00:00:00 Z
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: :development
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: shoulda
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: *id004
91
+ version_requirements: *id005
78
92
  - !ruby/object:Gem::Dependency
79
93
  type: :development
80
- requirement: &id005 !ruby/object:Gem::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: *id005
107
+ version_requirements: *id006
94
108
  - !ruby/object:Gem::Dependency
95
109
  type: :development
96
- requirement: &id006 !ruby/object:Gem::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: *id006
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: []