capybara-paparazzi 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e37b4dd76d939ff8af81d07dffd57b8bec00451
4
- data.tar.gz: f0b32e133aae2070f4c533b645eca45b9de6dfe1
3
+ metadata.gz: e89cf9a779d19b87c627cd39e5c1f3af6ffec94d
4
+ data.tar.gz: 868eaf3ec57b1ce4b66362e47bbb2d5314607192
5
5
  SHA512:
6
- metadata.gz: 875d8f5a8f55c4c79435cd577fde4da551fda8a42b1b56f83bc1419ff3bea67b12100eb088fc13b7ccc5a95706a6a4945c7116efdabb575c2cc563b5772e6557
7
- data.tar.gz: e15368acf07fe259bf8f7e7330a385e2cea4f83b1ff6ef5f594a48800f358b78cd9444230986c23f064ed5a6092d21de9e81c90a4e010954edc40473899b5204
6
+ metadata.gz: 5e74bb486bb34ffeed96221f450854bf42e4540f777a3c70aa433468de4c8b7c65e80191c159793943ca80eab3e06e1dc502982feb9117fd7365bcabd2ec418d
7
+ data.tar.gz: 47e943d68d50a492271f101a8dc01a9e97c3c524a96cd8802865b32c525e30767614dd393730ad8c8663c074bad5f4f5af7532a821de135acf6ee23b1a844036
data/README.md CHANGED
@@ -17,6 +17,7 @@ mind.
17
17
 
18
18
  A few driving principles of Capybara::Paparazzi:
19
19
 
20
+ - **Responsive**: It can take screenshots in whatever sizes you want.
20
21
  - **Unobtrusive**: You shouldn't need to edit your feature test scenarios
21
22
  to get screenshots.
22
23
  - **Easy**: Simple to set up, and out-of-the-box settings should get you far.
@@ -105,6 +106,21 @@ end
105
106
 
106
107
  For the default settings, see [shooter.rb](https://github.com/sbull/capybara-paparazzi/blob/master/lib/capybara/paparazzi/shooter.rb).
107
108
 
109
+ ### Manual screenshots
110
+
111
+ Try as it might, Capybara::Paparazzi could miss some photos that you
112
+ want it to take, particularly if you're using javascript to change
113
+ the page without navigating to a different page. You can call
114
+
115
+ take_snapshots
116
+
117
+ in your scenarios to manually capture the page.
118
+ (`take_snapshots` is also known as `paparazzi_take_snapshots`,
119
+ in case you use something else that defines `take_snapshots` differently.)
120
+
121
+ You can leave these calls in your code even when you're not using
122
+ `#follow`, and they will be no-ops.
123
+
108
124
  ### Screenshot Sizes
109
125
 
110
126
  Capybara::Paparazzi uses default screen sizes to represent common
@@ -121,8 +137,14 @@ a shorter view than the actual device height.
121
137
  Use an environment variable to turn screenshots on or off.
122
138
  You probably don't want them running all the time, and only
123
139
  need them on occasion:
124
-
125
- Capybara::Paparazzi.follow(Capybara.default_driver, Capybara.javascript_driver) if ENV['CAPYBARA_PAPARAZZI_ENABLED']
140
+ ```ruby
141
+ if ENV['CAPYBARA_PAPARAZZI_DIR'].present?
142
+ Capybara::Paparazzi.config do |config|
143
+ config.file_dir = ENV['CAPYBARA_PAPARAZZI_DIR']
144
+ config.follow(Capybara.default_driver, Capybara.javascript_driver)
145
+ end
146
+ end
147
+ ```
126
148
 
127
149
  ### Driver Setup
128
150
 
@@ -141,10 +163,50 @@ Here's a simple approach that could work for you:
141
163
  1. `require 'capybara/poltergeist'`
142
164
  2. `Capybara.javascript_driver = :poltergeist`
143
165
 
166
+ ## TODO
167
+
168
+ The photo-capturing triggers may be incomplete, and enhancements may be
169
+ needed to be sure to capture everything. Currently, `visit` and `click`
170
+ are the primary triggers.
171
+
172
+ ## Related Projects
173
+
174
+ - [Capybara](https://github.com/jnicklas/capybara)
175
+ - [Capybara::Animate](https://github.com/cpb/capybara-animate) - makes animated .gifs of scenarios.
176
+ - [capybara-screenshot](https://github.com/mattheworiordan/capybara-screenshot) - takes screenshots of failing scenarios.
177
+ - [Headless](https://github.com/leonid-shevtsov/headless) - has ways to capture screenshots and video.
178
+
144
179
  ## Contributing
145
180
 
181
+ ### Generic Github Instructions
182
+
146
183
  1. Fork it
147
184
  2. Create your feature branch (`git checkout -b my-new-feature`)
148
185
  3. Commit your changes (`git commit -am 'Add some feature'`)
149
186
  4. Push to the branch (`git push origin my-new-feature`)
150
187
  5. Create new Pull Request
188
+
189
+ ### Working on a Gem
190
+
191
+ You can read up on how to develop a local gem on
192
+ [rubygems.org](http://guides.rubygems.org/make-your-own-gem/).
193
+
194
+ Here's the TL;DR:
195
+
196
+ 1. Make your edits.
197
+ 2. Update the version (lib/capybara/paparazzi/version.rb), say to `0.0.1.new`.
198
+ 3. `gem build capybara-paparazzi.gemspec`
199
+ 4. `gem install ./capybara-paparazzi-0.0.1.new.gem`
200
+ 5. In your project that uses Capybara::Paparazzi:
201
+ 1. Update your Gemfile to say `gem 'capybara-paparazzi', '0.0.1.new'
202
+ 2. `bundle install`
203
+
204
+ Some useful one-liners for the above:
205
+
206
+ In `capybara-paparazzi` repository:
207
+
208
+ gem uninstall capybara-paparazzi && gem build capybara-paparazzi.gemspec && gem install ./capybara-paparazzi-0.0.1.new.gem Successfully uninstalled capybara-paparazzi-0.0.1.new
209
+
210
+ In your project:
211
+
212
+ rm vendor/cache/capybara-paparazzi-0.0.1.new.gem && bundle
@@ -1,6 +1,7 @@
1
1
  require 'capybara'
2
2
 
3
3
  require 'capybara/paparazzi/version'
4
+ require 'capybara/paparazzi/dsl'
4
5
  require 'capybara/paparazzi/shooter'
5
6
  require 'capybara/paparazzi/driver'
6
7
  require 'capybara/paparazzi/element'
@@ -24,8 +25,14 @@ module Capybara::Paparazzi
24
25
  @used_drivers ||= {}
25
26
  end
26
27
 
27
- def take_snapshots(driver, event_details=nil)
28
- Capybara::Paparazzi::Shooter.take_snapshots(driver, event_details)
28
+ def take_snapshots(driver, event, args)
29
+ Capybara::Paparazzi::Shooter.take_snapshots(driver, { event: event, args: args })
30
+ end
31
+
32
+ def take_snapshots_if_following(driver, event, args)
33
+ if driver.is_a?(Capybara::Paparazzi::Driver)
34
+ take_snapshots(driver, event, args)
35
+ end
29
36
  end
30
37
 
31
38
  end # ClassMethods
@@ -33,6 +40,10 @@ module Capybara::Paparazzi
33
40
  extend ClassMethods
34
41
  end
35
42
 
43
+ module Capybara::DSL
44
+ include Capybara::Paparazzi::DSL
45
+ end
46
+
36
47
  class Capybara::Node::Element
37
48
  include Capybara::Paparazzi::Element
38
49
  end
@@ -1,14 +1,9 @@
1
1
  module Capybara::Paparazzi::Driver
2
2
 
3
- # TODO: go_back, go_forward
4
-
5
3
  def visit(*args)
6
- super(*args)
7
- take_snapshots(:visit, args)
8
- end
9
-
10
- def take_snapshots(method, args)
11
- Capybara::Paparazzi.take_snapshots(self, { method: method, args: args })
4
+ response = super(*args)
5
+ Capybara::Paparazzi.take_snapshots(self, :visit, args)
6
+ response
12
7
  end
13
8
 
14
9
  end
@@ -0,0 +1,13 @@
1
+ module Capybara::Paparazzi::DSL
2
+
3
+ def paparazzi_take_snapshots(*args)
4
+ Capybara::Paparazzi.take_snapshots_if_following(page.driver, :manual, args)
5
+ end
6
+
7
+ def self.included(mod)
8
+ unless mod.method_defined?(:take_snapshots)
9
+ mod.send(:alias_method, :take_snapshots, :paparazzi_take_snapshots)
10
+ end
11
+ end
12
+
13
+ end
@@ -2,9 +2,7 @@ module Capybara::Paparazzi::Element
2
2
 
3
3
  def click_with_paparazzi(*args)
4
4
  response = click_without_paparazzi(*args)
5
- if session.driver.respond_to?(:take_snapshots)
6
- session.driver.take_snapshots(:click, args)
7
- end
5
+ Capybara::Paparazzi.take_snapshots_if_following(session.driver, :click, args)
8
6
  response
9
7
  end
10
8
 
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Paparazzi
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-paparazzi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Bull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-27 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - capybara-paparazzi.gemspec
71
71
  - lib/capybara-paparazzi.rb
72
72
  - lib/capybara/paparazzi/driver.rb
73
+ - lib/capybara/paparazzi/dsl.rb
73
74
  - lib/capybara/paparazzi/element.rb
74
75
  - lib/capybara/paparazzi/session.rb
75
76
  - lib/capybara/paparazzi/shooter.rb