wraith 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9eb43d65349986285e6d089a4ed007f7d58247b6
4
- data.tar.gz: 8a807791ed5348d4538495c6637ab1e2a6a11efd
3
+ metadata.gz: 3b81224f867711e225c6f7a2060e37deb7c089d5
4
+ data.tar.gz: 3613a71af35b90bf3c7b6f200db0c9b16870cd43
5
5
  SHA512:
6
- metadata.gz: 2460efd5b9be376c0fefeb69926d5c8d7cc05728718f8c2703f2cfb3c827825f701c0dea044424a99ba62ec8e9355fb956b71293e71d8ea9a06a500ea383bedd
7
- data.tar.gz: 5a0fcdb92530cb4a46f34e57f90374c1ba229a634e5087d64d85386f1fd146b58bf00ce79d38b4fb15cced586f66faa3be1dcfe1f645fc51fbfb399d068a79ab
6
+ metadata.gz: 6bed22eccfb886b54541c7f15468be1bb82da36a95266e384f6e3571c7d90c650a8a7a8c87cba57780d0dd5bafb505fbc407ddea7c41e11fd118bb1abe617f9d
7
+ data.tar.gz: 38b14beb294e7f7d3bce79c43ffa19c44474bdd39de521e2c2346ce71f4395ca34171035ac1b182b8d42dff302783c89280d95f47ee510be3b568e310267c6cb
@@ -89,7 +89,7 @@ module.exports = function (config) {
89
89
  // see https://github.com/n1k0/casperjs/issues/1068
90
90
  setTimeout(function(){
91
91
  phantom.exit();
92
- }, 10);
92
+ }, 30);
93
93
  }
94
94
  }
95
95
 
@@ -58,12 +58,12 @@ casper.open(url);
58
58
  casper.viewport(currentDimensions.viewportWidth, currentDimensions.viewportHeight);
59
59
  casper.then(function() {
60
60
  if (globalBeforeCaptureJS) {
61
- require('./' + globalBeforeCaptureJS)(this);
61
+ require(globalBeforeCaptureJS)(this);
62
62
  }
63
63
  });
64
64
  casper.then(function() {
65
65
  if (pathBeforeCaptureJS) {
66
- require('./' + pathBeforeCaptureJS)(this);
66
+ require(pathBeforeCaptureJS)(this);
67
67
  }
68
68
  });
69
69
  // waits for all images to download before taking screenshots
@@ -1,6 +1,7 @@
1
1
  require "wraith"
2
2
  require "parallel"
3
3
  require "shellwords"
4
+ require "wraith/utilities"
4
5
 
5
6
  class Wraith::SaveImages
6
7
  attr_reader :wraith, :history, :meta
@@ -135,7 +136,7 @@ class CaptureOptions
135
136
  end
136
137
 
137
138
  def before_capture
138
- options["before_capture"] || "false"
139
+ @options["before_capture"] ? convert_to_absolute(@options["before_capture"]) : "false"
139
140
  end
140
141
 
141
142
  def base_url
@@ -0,0 +1,12 @@
1
+ # @TODO - extract more shared functions to this file
2
+
3
+ def convert_to_absolute(filepath)
4
+ if filepath[0] == '/'
5
+ # filepath is already absolute. return unchanged
6
+ filepath
7
+ else
8
+ # filepath is relative. it must be converted to absolute
9
+ working_dir = `pwd`.chomp
10
+ "#{working_dir}/#{filepath}"
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Wraith
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
data/lib/wraith/wraith.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "yaml"
2
+ require "wraith/utilities"
2
3
 
3
4
  class Wraith::Wraith
4
5
  attr_accessor :config
@@ -38,7 +39,7 @@ class Wraith::Wraith
38
39
  end
39
40
 
40
41
  def snap_file
41
- @config["snap_file"] || snap_file_from_engine(engine)
42
+ @config["snap_file"] ? convert_to_absolute(@config["snap_file"]) : snap_file_from_engine(engine)
42
43
  end
43
44
 
44
45
  def snap_file_from_engine(engine)
@@ -55,7 +56,7 @@ class Wraith::Wraith
55
56
  end
56
57
 
57
58
  def before_capture
58
- @config["before_capture"] || "false"
59
+ @config["before_capture"] ? convert_to_absolute(@config["before_capture"]) : "false"
59
60
  end
60
61
 
61
62
  def widths
@@ -11,6 +11,29 @@ describe Wraith do
11
11
  let(:before_suite_js) { "spec/js/global.js" }
12
12
  let(:before_capture_js) { "spec/js/path.js" }
13
13
 
14
+ describe "different ways of determining the before_capture file" do
15
+ it "should allow users to specify the relative path to the before_capture file" do
16
+ config = YAML.load '
17
+ browser: casperjs
18
+ before_capture: javascript/do_something.js
19
+ '
20
+ wraith = Wraith::Wraith.new(config, true)
21
+ # not sure about having code IN the test, but we want to get this right.
22
+ expect(wraith.before_capture).to eq (`pwd`.chomp! + '/javascript/do_something.js')
23
+ end
24
+
25
+ it "should allow users to specify the absolute path to the before_capture file" do
26
+ config = YAML.load '
27
+ browser: casperjs
28
+ before_capture: /Users/some_user/wraith/javascript/do_something.js
29
+ '
30
+ wraith = Wraith::Wraith.new(config, true)
31
+ expect(wraith.before_capture).to eq ('/Users/some_user/wraith/javascript/do_something.js')
32
+ end
33
+ end
34
+
35
+ # @TODO - we need tests determining the path to "path-level before_capture hooks"
36
+
14
37
  describe "When hooking into beforeCapture (CasperJS)" do
15
38
 
16
39
  it "Executes the global JS before capturing" do
data/spec/config_spec.rb CHANGED
@@ -110,13 +110,23 @@ describe "wraith config" do
110
110
  expect(wraith.snap_file).to include 'lib/wraith/javascript/casper.js'
111
111
  end
112
112
 
113
- it "should allow users to specify their own snap file" do
113
+ it "should allow users to specify the relative path to their own snap file" do
114
114
  config = YAML.load '
115
115
  browser: casperjs
116
116
  snap_file: path/to/snap.js
117
117
  '
118
118
  wraith = Wraith::Wraith.new(config, true)
119
- expect(wraith.snap_file).to eq 'path/to/snap.js'
119
+ # not sure about having code IN the test, but we want to get this right.
120
+ expect(wraith.snap_file).to eq (`pwd`.chomp! + '/path/to/snap.js')
121
+ end
122
+
123
+ it "should allow users to specify the absolute path to their own snap file" do
124
+ config = YAML.load '
125
+ browser: casperjs
126
+ snap_file: /Users/my_username/Sites/bbc/wraith/path/to/snap.js
127
+ '
128
+ wraith = Wraith::Wraith.new(config, true)
129
+ expect(wraith.snap_file).to eq ('/Users/my_username/Sites/bbc/wraith/path/to/snap.js')
120
130
  end
121
131
  end
122
132
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wraith
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Blooman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-01 00:00:00.000000000 Z
13
+ date: 2015-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
@@ -206,6 +206,7 @@ files:
206
206
  - lib/wraith/save_images.rb
207
207
  - lib/wraith/spider.rb
208
208
  - lib/wraith/thumbnails.rb
209
+ - lib/wraith/utilities.rb
209
210
  - lib/wraith/version.rb
210
211
  - lib/wraith/wraith.rb
211
212
  - spec/_helpers.rb