cucumber-screenshot 0.3.1 → 0.3.2
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 +31 -12
- data/Rakefile +3 -3
- data/cucumber-screenshot.gemspec +4 -4
- data/cucumber-screenshot.tmproj +39 -10
- data/lib/cucumber_screenshot.rb +3 -1
- data/lib/cucumber_screenshot/world.rb +25 -2
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
= Cucumber Screenshot
|
2
2
|
|
3
|
-
Cucumber Screenshot makes it easy to capture screenshots of the pages generated
|
3
|
+
Cucumber Screenshot makes it easy to capture HTML snapshots and PNG screenshots of the pages generated
|
4
4
|
by your Rails application as it runs your Cucumber/Webrat features.
|
5
5
|
|
6
|
-
It uses WebKit to generate the screenshots and so
|
6
|
+
It uses WebKit to generate the PNG screenshots and so they are only available for OS X.
|
7
7
|
|
8
|
-
If you want to take screenshots on any other platform then take a look at
|
8
|
+
If you want to take bitmap screenshots on any other platform then take a look at
|
9
9
|
[this example]http://github.com/aslakhellesoy/cucumber/blob/master/examples/watir/features/support/screenshots.rb
|
10
10
|
from Cucumber.
|
11
11
|
|
@@ -17,9 +17,13 @@ A Rails application with some features written in Cucumber/Webrat.
|
|
17
17
|
|
18
18
|
To install the latest release as a gem
|
19
19
|
|
20
|
-
|
20
|
+
gem install cucumber-screenshot
|
21
21
|
|
22
|
-
|
22
|
+
If you want to take PNG screenshots you will also need to install snapurl
|
23
|
+
|
24
|
+
gem install snapurl --version=0.3.0
|
25
|
+
|
26
|
+
== Set up your rails application
|
23
27
|
|
24
28
|
Create a cucumber_screenshot_env.rb file in the ./features/support/ directory
|
25
29
|
in your Rails project and put the following in it.
|
@@ -44,16 +48,32 @@ in your Rails project and put the following in it.
|
|
44
48
|
cucumber-screenshot with\n\n gem install cucumber-screenshot\n"
|
45
49
|
end
|
46
50
|
|
47
|
-
|
51
|
+
By default cucumber screenshot will do it's best to fix up references to your
|
52
|
+
public assets (images, css, js, etc.) in the HTML for your screenshots to point
|
53
|
+
at the public folder on your file system.
|
54
|
+
|
55
|
+
However you may find that rendering is improved if you configure it to
|
56
|
+
reference these via HTTP. Say you have a webserver running on
|
57
|
+
http://localhost:3000 that will serve the public files then add a
|
58
|
+
cucumber_screenshot.yml file containing the following to your application's
|
59
|
+
./config/ directory
|
60
|
+
|
61
|
+
base_url: http://localhost:3000
|
62
|
+
|
63
|
+
== Use
|
64
|
+
|
65
|
+
Once you have set up your rails application then simply use the 'rake cucumber'
|
66
|
+
and 'rake cucumber:wip' tasks as per usual.
|
48
67
|
|
49
68
|
Screenshots will be captured for every step failure and for every step in
|
50
|
-
scenarios tagged @screenshot. The screenshots
|
51
|
-
./features/screenshots/
|
69
|
+
scenarios tagged @screenshot. The PNG screenshots and HTML snapshots will be
|
70
|
+
saved to a the ./features/screenshots/ and ./features/screenshots/html
|
71
|
+
directories respectively in your project.
|
52
72
|
|
53
73
|
=== Capturing a single screenshot
|
54
74
|
|
55
|
-
If you want to capture a single screenshot rather than every
|
56
|
-
following step to one of your Rails application's step files
|
75
|
+
If you want to capture a single PNG screenshot/HTML snapshot rather than every
|
76
|
+
page then add the following step to one of your Rails application's step files
|
57
77
|
|
58
78
|
Then "screenshot" do
|
59
79
|
screenshot
|
@@ -68,8 +88,7 @@ page that your application generated.
|
|
68
88
|
|
69
89
|
== TODO
|
70
90
|
|
71
|
-
-
|
72
|
-
- Add support for tables
|
91
|
+
- Offer option to clean out existing snapshots before each run
|
73
92
|
- Add a Rails generator to add the env and step code to a project
|
74
93
|
|
75
94
|
== License
|
data/Rakefile
CHANGED
@@ -25,10 +25,10 @@ task :default => ['spec']
|
|
25
25
|
spec = Gem::Specification.new do |s|
|
26
26
|
# Change these as appropriate
|
27
27
|
s.name = 'cucumber-screenshot'
|
28
|
-
s.version = '0.3.
|
29
|
-
s.summary = 'Extension for Cucumber to capture PNG screenshots of your app'
|
28
|
+
s.version = '0.3.2'
|
29
|
+
s.summary = 'Extension for Cucumber to capture HTML snapshots/PNG screenshots of your app'
|
30
30
|
|
31
|
-
s.description = 'Extension for Cucumber (http://cukes.info/) that makes it easy to use Webkit to capture PNG screenshots of your web application during tests'
|
31
|
+
s.description = 'Extension for Cucumber (http://cukes.info/) that makes it easy to take HTML snapshots and also to use Webkit to capture PNG screenshots of your web application during tests'
|
32
32
|
s.author = 'Joel Chippindale'
|
33
33
|
s.email = 'joel.chippindale@gmail.com'
|
34
34
|
s.homepage = 'http://github.com/mocoso/cucumber-screenshot'
|
data/cucumber-screenshot.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cucumber-screenshot}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Joel Chippindale"]
|
9
|
-
s.date = %q{2010-
|
10
|
-
s.description = %q{Extension for Cucumber (http://cukes.info/) that makes it easy to use Webkit to capture PNG screenshots of your web application during tests}
|
9
|
+
s.date = %q{2010-05-19}
|
10
|
+
s.description = %q{Extension for Cucumber (http://cukes.info/) that makes it easy to take HTML snapshots and also to use Webkit to capture PNG screenshots of your web application during tests}
|
11
11
|
s.email = %q{joel.chippindale@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc"]
|
13
13
|
s.files = ["cucumber-screenshot.gemspec", "cucumber-screenshot.tmproj", "MIT-LICENSE", "Rakefile", "README.rdoc", "spec", "lib/cucumber_screenshot", "lib/cucumber_screenshot/world.rb", "lib/cucumber_screenshot.rb"]
|
@@ -23,7 +23,7 @@ You will also need to install the snapurl gem
|
|
23
23
|
s.require_paths = ["lib"]
|
24
24
|
s.requirements = ["Mac OS X 10.5 or later", "RubyCocoa"]
|
25
25
|
s.rubygems_version = %q{1.3.6}
|
26
|
-
s.summary = %q{Extension for Cucumber to capture PNG screenshots of your app}
|
26
|
+
s.summary = %q{Extension for Cucumber to capture HTML snapshots/PNG screenshots of your app}
|
27
27
|
|
28
28
|
if s.respond_to? :specification_version then
|
29
29
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/cucumber-screenshot.tmproj
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<plist version="1.0">
|
4
4
|
<dict>
|
5
5
|
<key>currentDocument</key>
|
6
|
-
<string>
|
6
|
+
<string>spec/cucumber_screenshot/world_spec.rb</string>
|
7
7
|
<key>documents</key>
|
8
8
|
<array>
|
9
9
|
<dict>
|
@@ -40,9 +40,37 @@
|
|
40
40
|
<key>caret</key>
|
41
41
|
<dict>
|
42
42
|
<key>column</key>
|
43
|
-
<integer>
|
43
|
+
<integer>9</integer>
|
44
44
|
<key>line</key>
|
45
|
-
<integer>
|
45
|
+
<integer>58</integer>
|
46
|
+
</dict>
|
47
|
+
<key>firstVisibleColumn</key>
|
48
|
+
<integer>0</integer>
|
49
|
+
<key>firstVisibleLine</key>
|
50
|
+
<integer>22</integer>
|
51
|
+
</dict>
|
52
|
+
<key>Rakefile</key>
|
53
|
+
<dict>
|
54
|
+
<key>caret</key>
|
55
|
+
<dict>
|
56
|
+
<key>column</key>
|
57
|
+
<integer>0</integer>
|
58
|
+
<key>line</key>
|
59
|
+
<integer>58</integer>
|
60
|
+
</dict>
|
61
|
+
<key>firstVisibleColumn</key>
|
62
|
+
<integer>0</integer>
|
63
|
+
<key>firstVisibleLine</key>
|
64
|
+
<integer>13</integer>
|
65
|
+
</dict>
|
66
|
+
<key>lib/cucumber_screenshot.rb</key>
|
67
|
+
<dict>
|
68
|
+
<key>caret</key>
|
69
|
+
<dict>
|
70
|
+
<key>column</key>
|
71
|
+
<integer>0</integer>
|
72
|
+
<key>line</key>
|
73
|
+
<integer>4</integer>
|
46
74
|
</dict>
|
47
75
|
<key>firstVisibleColumn</key>
|
48
76
|
<integer>0</integer>
|
@@ -54,35 +82,36 @@
|
|
54
82
|
<key>caret</key>
|
55
83
|
<dict>
|
56
84
|
<key>column</key>
|
57
|
-
<integer>
|
85
|
+
<integer>10</integer>
|
58
86
|
<key>line</key>
|
59
|
-
<integer>
|
87
|
+
<integer>75</integer>
|
60
88
|
</dict>
|
61
89
|
<key>firstVisibleColumn</key>
|
62
90
|
<integer>0</integer>
|
63
91
|
<key>firstVisibleLine</key>
|
64
|
-
<integer>
|
92
|
+
<integer>32</integer>
|
65
93
|
</dict>
|
66
94
|
<key>spec/cucumber_screenshot/world_spec.rb</key>
|
67
95
|
<dict>
|
68
96
|
<key>caret</key>
|
69
97
|
<dict>
|
70
98
|
<key>column</key>
|
71
|
-
<integer>
|
99
|
+
<integer>32</integer>
|
72
100
|
<key>line</key>
|
73
|
-
<integer>
|
101
|
+
<integer>127</integer>
|
74
102
|
</dict>
|
75
103
|
<key>firstVisibleColumn</key>
|
76
104
|
<integer>0</integer>
|
77
105
|
<key>firstVisibleLine</key>
|
78
|
-
<integer>
|
106
|
+
<integer>77</integer>
|
79
107
|
</dict>
|
80
108
|
</dict>
|
81
109
|
<key>openDocuments</key>
|
82
110
|
<array>
|
83
111
|
<string>lib/cucumber_screenshot/world.rb</string>
|
112
|
+
<string>Rakefile</string>
|
84
113
|
<string>README.rdoc</string>
|
85
|
-
<string>
|
114
|
+
<string>lib/cucumber_screenshot.rb</string>
|
86
115
|
<string>spec/cucumber_screenshot/world_spec.rb</string>
|
87
116
|
</array>
|
88
117
|
<key>showFileHierarchyDrawer</key>
|
data/lib/cucumber_screenshot.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'cucumber'
|
2
2
|
require 'cucumber/formatter/html'
|
3
3
|
require 'webrat'
|
4
|
+
require 'yaml'
|
5
|
+
require 'nokogiri'
|
4
6
|
|
5
7
|
require 'cucumber_screenshot/world'
|
6
8
|
|
7
9
|
module CucumberScreenshot
|
8
|
-
VERSION = '0.3.
|
10
|
+
VERSION = '0.3.2'
|
9
11
|
|
10
12
|
begin
|
11
13
|
require 'snapurl'
|
@@ -47,8 +47,18 @@ module CucumberScreenshot
|
|
47
47
|
|
48
48
|
# So that references to stylesheets, javascript and images will work
|
49
49
|
def rewrite_local_urls(response_html) # :nodoc:
|
50
|
-
|
51
|
-
|
50
|
+
if base_url
|
51
|
+
doc = Nokogiri::HTML::Document.parse response_html
|
52
|
+
base = Nokogiri::HTML::DocumentFragment.parse "<base href=\"#{base_url}\">"
|
53
|
+
head = doc.xpath("//head").first
|
54
|
+
head.child && head.child.add_previous_sibling(base)
|
55
|
+
doc.to_html
|
56
|
+
elsif doc_root
|
57
|
+
# TODO: replace with nokogiri calls
|
58
|
+
response_html.gsub(/"\/([^"]*)"/, %{"#{doc_root}} + '/\1"')
|
59
|
+
else
|
60
|
+
response_html
|
61
|
+
end
|
52
62
|
end
|
53
63
|
|
54
64
|
def report_error_running_screenshot_command(command)
|
@@ -60,6 +70,19 @@ Unable to make screenshot, to find out what went wrong try the following from th
|
|
60
70
|
"
|
61
71
|
end
|
62
72
|
|
73
|
+
def config
|
74
|
+
config_file = File.expand_path(File.join(RAILS_ROOT, 'config', 'cucumber_screenshot.yml'))
|
75
|
+
@config ||= if File.exist?(config_file)
|
76
|
+
YAML::load(File.open(config_file))
|
77
|
+
else
|
78
|
+
{}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def base_url
|
83
|
+
config['base_url']
|
84
|
+
end
|
85
|
+
|
63
86
|
def doc_root
|
64
87
|
File.expand_path(File.join(RAILS_ROOT, 'public'))
|
65
88
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joel Chippindale
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-19 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
version: "0"
|
58
58
|
type: :development
|
59
59
|
version_requirements: *id003
|
60
|
-
description: Extension for Cucumber (http://cukes.info/) that makes it easy to use Webkit to capture PNG screenshots of your web application during tests
|
60
|
+
description: Extension for Cucumber (http://cukes.info/) that makes it easy to take HTML snapshots and also to use Webkit to capture PNG screenshots of your web application during tests
|
61
61
|
email: joel.chippindale@gmail.com
|
62
62
|
executables: []
|
63
63
|
|
@@ -110,6 +110,6 @@ rubyforge_project:
|
|
110
110
|
rubygems_version: 1.3.6
|
111
111
|
signing_key:
|
112
112
|
specification_version: 3
|
113
|
-
summary: Extension for Cucumber to capture PNG screenshots of your app
|
113
|
+
summary: Extension for Cucumber to capture HTML snapshots/PNG screenshots of your app
|
114
114
|
test_files: []
|
115
115
|
|