phantomjs_2.0 2.0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.simplecov +1 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -0
- data/LICENSE +27 -0
- data/README.md +78 -0
- data/Rakefile +2 -0
- data/lib/phantomjs/platform.rb +162 -0
- data/lib/phantomjs/poltergeist.rb +13 -0
- data/lib/phantomjs/version.rb +3 -0
- data/lib/phantomjs.rb +61 -0
- data/phantomjs.gemspec +24 -0
- data/spec/phantomjs_spec.rb +50 -0
- data/spec/platform_spec.rb +203 -0
- data/spec/runner.js +3 -0
- data/spec/spec_helper.rb +11 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5014adfa92fbbce1d79003a442678b6b97664bed
|
4
|
+
data.tar.gz: 58f35d2aab2ccec2d7d51efa4fd33f6440e6c382
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5dabf3b8fc3fb65dd054759bbb7ce770d237ce3b0048a853fd0ce9acef0ba88f454380a04704bb0b40ef200f29ed62ff456c90c079b0a10876482119e3270da
|
7
|
+
data.tar.gz: a86334f2be8f1cb2f2024af6eb62de461065788104402a96029c9f4f2e4a4dbb614859972f9b217499cce06aaad4babc135a140936138164e2fed82b35c33d08
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.simplecov
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SimpleCov.start
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Note that this project merely bundles the separate PhantomJS project
|
2
|
+
into a Ruby gem. You can find the license information for PhantomJS
|
3
|
+
inside phantomjs/LICENSE.BSD and further information at
|
4
|
+
http://http://phantomjs.org/
|
5
|
+
|
6
|
+
Copyright (c) 2013 Christoph Olszowka
|
7
|
+
|
8
|
+
MIT License
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
a copy of this software and associated documentation files (the
|
12
|
+
"Software"), to deal in the Software without restriction, including
|
13
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
the following conditions:
|
17
|
+
|
18
|
+
The above copyright notice and this permission notice shall be
|
19
|
+
included in all copies or substantial portions of the Software.
|
20
|
+
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# PhantomJS as a RubyGem
|
2
|
+
|
3
|
+
[](https://travis-ci.org/colszowka/phantomjs-gem)
|
4
|
+
|
5
|
+
**DISCLAIMER: Alpha status, YMMV!**
|
6
|
+
|
7
|
+
I am lazy as hell, and wanted to be able to install [PhantomJS](http://phantomjs.org) via Rubygems/Bundler when using [poltergeist](https://github.com/jonleighton/poltergeist).
|
8
|
+
|
9
|
+
It keeps installations of phantomjs in `$HOME/.phantomjs/VERSION/PLATFORM`. When you call `Phantomjs.path`, it will return the path to the phantomjs executable in there. If that is not present, it will first fetch and
|
10
|
+
install the prebuilt packages suitable for the current plattform (currently Linux 32/64 or OS X supported).
|
11
|
+
|
12
|
+
If there is a phantomjs executable in your `$PATH` that matches the version number packaged in this gem, this one will be used instead of installing one in your `$HOME/.phantomjs`.
|
13
|
+
|
14
|
+
You will need `cURL` or `wget` on your system. For extraction, `bunzip2` and `tar` are required on Linux, and `unzip` on OS X. They should be installed already.
|
15
|
+
|
16
|
+
**TL;DR:** Instead of manually installing phantomjs on your machines, use this gem. It will take care of it.
|
17
|
+
|
18
|
+
## Example
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'phantomjs'
|
22
|
+
Phantomjs.path # => path to a phantom js executable suitable to your current platform. Will install before return when not installed yet.
|
23
|
+
|
24
|
+
# Or run phantomjs with the passed arguments:
|
25
|
+
Phantomjs.run('./path/to/script.js') # => returns stdout
|
26
|
+
|
27
|
+
# Also takes a block to receive each line of output:
|
28
|
+
Phantomjs.run('./path/to/script.js') { |line| puts line }
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage with Poltergeist/Capybara
|
32
|
+
|
33
|
+
Add this to your `Gemfile`:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
group :test do
|
37
|
+
gem 'poltergeist'
|
38
|
+
gem 'phantomjs', :require => 'phantomjs/poltergeist'
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
This will automatically require (and install) phantomjs and configure Capybara in the same way as noted below for manual setup.
|
43
|
+
|
44
|
+
Note that you need to add poltergeist as a dependency explicitly since it is not a dependency of this gem in order to avoid forcing users to install poltergeist if the just want to use phantomjs itself.
|
45
|
+
|
46
|
+
### Manual setup
|
47
|
+
|
48
|
+
Add `gem 'phantomjs', :group => :test` to your `Gemfile` and run `bundle`. In your test/spec helper, re-configure the Poltergeist capybara driver to use the phantomjs package from this gem:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require 'phantomjs' # <-- Not required if your app does Bundler.require automatically (e.g. when using Rails)
|
52
|
+
Capybara.register_driver :poltergeist do |app|
|
53
|
+
Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
Check out [the poltergeist docs](https://www.ruby-toolbox.com/gems/phantomjs) for all the options you can pass in there.
|
58
|
+
|
59
|
+
## A note about versions.
|
60
|
+
|
61
|
+
The gem version consists of 4 digits: The first 3 indicate the phantomjs release installed via this gem, the last one is the internal version of this gem, in case I screw things up and need to push another release in the interim.
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
**Warning**: The `spec_helper` calls `Phantomjs.implode` when it is loaded, which purges the `~/.phantomjs` directory. This is no bad thing, it just means every time you run the specs you'll download and install all three packages over, so tread with caution please. :)
|
66
|
+
|
67
|
+
1. Fork it
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
+
5. Create new Pull Request
|
72
|
+
|
73
|
+
## Copyright
|
74
|
+
|
75
|
+
(c) 2013-2014 Christoph Olszowka
|
76
|
+
|
77
|
+
Note that this project merely simplifies the installation of the entirely separate PhantomJS project
|
78
|
+
via a Ruby gem. You can find the license information for PhantomJS at http://phantomjs.org/
|
data/Rakefile
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
module Phantomjs
|
2
|
+
class Platform
|
3
|
+
class << self
|
4
|
+
def host_os
|
5
|
+
RbConfig::CONFIG['host_os']
|
6
|
+
end
|
7
|
+
|
8
|
+
def architecture
|
9
|
+
RbConfig::CONFIG['host_cpu']
|
10
|
+
end
|
11
|
+
|
12
|
+
def temp_path
|
13
|
+
ENV['TMPDIR'] || ENV['TEMP'] || '/tmp'
|
14
|
+
end
|
15
|
+
|
16
|
+
def phantomjs_path
|
17
|
+
if system_phantomjs_installed?
|
18
|
+
system_phantomjs_path
|
19
|
+
else
|
20
|
+
File.expand_path File.join(Phantomjs.base_dir, platform, 'bin/phantomjs')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def system_phantomjs_path
|
25
|
+
`which phantomjs`.delete("\n")
|
26
|
+
rescue
|
27
|
+
end
|
28
|
+
|
29
|
+
def system_phantomjs_version
|
30
|
+
`phantomjs --version`.delete("\n") if system_phantomjs_path.length > 4.2
|
31
|
+
rescue
|
32
|
+
end
|
33
|
+
|
34
|
+
def system_phantomjs_installed?
|
35
|
+
system_phantomjs_version == Phantomjs.version
|
36
|
+
end
|
37
|
+
|
38
|
+
def installed?
|
39
|
+
File.exist?(phantomjs_path) || system_phantomjs_installed?
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: Clean this up, it looks like a pile of...
|
43
|
+
def install!
|
44
|
+
STDERR.puts "Phantomjs does not appear to be installed in #{phantomjs_path}, installing!"
|
45
|
+
FileUtils.mkdir_p Phantomjs.base_dir
|
46
|
+
|
47
|
+
# Purge temporary directory if it is still hanging around from previous installs,
|
48
|
+
# then re-create it.
|
49
|
+
temp_dir = File.join(temp_path, 'phantomjs_install')
|
50
|
+
FileUtils.rm_rf temp_dir
|
51
|
+
FileUtils.mkdir_p temp_dir
|
52
|
+
|
53
|
+
Dir.chdir temp_dir do
|
54
|
+
unless system "curl -L -O #{package_url}" or system "wget #{package_url}"
|
55
|
+
raise "\n\nFailed to load phantomjs! :(\nYou need to have cURL or wget installed on your system.\nIf you have, the source of phantomjs might be unavailable: #{package_url}\n\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
case package_url.split('.').last
|
59
|
+
when 'bz2'
|
60
|
+
system "bunzip2 #{File.basename(package_url)}"
|
61
|
+
system "tar xf #{File.basename(package_url).sub(/\.bz2$/, '')}"
|
62
|
+
when 'zip'
|
63
|
+
system "unzip #{File.basename(package_url)}"
|
64
|
+
else
|
65
|
+
raise "Unknown compression format for #{File.basename(package_url)}"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Find the phantomjs build we just extracted
|
69
|
+
extracted_dir = Dir['phantomjs*'].find { |path| File.directory?(path) }
|
70
|
+
|
71
|
+
# Move the extracted phantomjs build to $HOME/.phantomjs/version/platform
|
72
|
+
if FileUtils.mv extracted_dir, File.join(Phantomjs.base_dir, platform)
|
73
|
+
STDOUT.puts "\nSuccessfully installed phantomjs. Yay!"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Clean up remaining files in tmp
|
77
|
+
if FileUtils.rm_rf temp_dir
|
78
|
+
STDOUT.puts "Removed temporarily downloaded files."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
raise "Failed to install phantomjs. Sorry :(" unless File.exist?(phantomjs_path)
|
83
|
+
end
|
84
|
+
|
85
|
+
def ensure_installed!
|
86
|
+
install! unless installed?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Linux64 < Platform
|
91
|
+
class << self
|
92
|
+
def useable?
|
93
|
+
host_os.include?('linux') and architecture.include?('x86_64')
|
94
|
+
end
|
95
|
+
|
96
|
+
def platform
|
97
|
+
'x86_64-linux'
|
98
|
+
end
|
99
|
+
|
100
|
+
def package_url
|
101
|
+
'https://github.com/bprodoehl/phantomjs/releases/download/v2.0.0-20150528/phantomjs-2.0.0-20150528-u1404-x86_64.zip'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Linux32 < Platform
|
107
|
+
class << self
|
108
|
+
def useable?
|
109
|
+
host_os.include?('linux') and (architecture.include?('x86_32') or architecture.include?('i686'))
|
110
|
+
end
|
111
|
+
|
112
|
+
def platform
|
113
|
+
'x86_32-linux'
|
114
|
+
end
|
115
|
+
|
116
|
+
def package_url
|
117
|
+
'https://s3-us-west-2.amazonaws.com/phantomjs-bin/phantomjs-2.0.0-debian7.8_linux-i686.tar.bz2'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class OsX < Platform
|
123
|
+
class << self
|
124
|
+
def useable?
|
125
|
+
host_os.include?('darwin')
|
126
|
+
end
|
127
|
+
|
128
|
+
def platform
|
129
|
+
'darwin'
|
130
|
+
end
|
131
|
+
|
132
|
+
def package_url
|
133
|
+
'https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.0.0-macosx.zip'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
class Win32 < Platform
|
139
|
+
class << self
|
140
|
+
def useable?
|
141
|
+
host_os.include?('mingw32') and architecture.include?('i686')
|
142
|
+
end
|
143
|
+
|
144
|
+
def platform
|
145
|
+
'win32'
|
146
|
+
end
|
147
|
+
|
148
|
+
def phantomjs_path
|
149
|
+
if system_phantomjs_installed?
|
150
|
+
system_phantomjs_path
|
151
|
+
else
|
152
|
+
File.expand_path File.join(Phantomjs.base_dir, platform, 'phantomjs.exe')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def package_url
|
157
|
+
'https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.0.0-windows.zip'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'phantomjs'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'capybara/poltergeist'
|
6
|
+
rescue => LoadError
|
7
|
+
raise "Poltergeist support requires the poltergeist gem to be available."
|
8
|
+
end
|
9
|
+
|
10
|
+
Phantomjs.path # Force install on require
|
11
|
+
Capybara.register_driver :poltergeist do |app|
|
12
|
+
Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)
|
13
|
+
end
|
data/lib/phantomjs.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "phantomjs/version"
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Phantomjs
|
5
|
+
class UnknownPlatform < StandardError; end;
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def available_platforms
|
9
|
+
@available_platforms ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def base_dir
|
13
|
+
@base_dir ||= File.join(File.expand_path('~'), '.phantomjs', version)
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_dir=(dir)
|
17
|
+
@base_dir = dir
|
18
|
+
end
|
19
|
+
|
20
|
+
def version
|
21
|
+
Phantomjs::VERSION.split('.')[0..-2].join('.')
|
22
|
+
end
|
23
|
+
|
24
|
+
def path
|
25
|
+
@path ||= platform.phantomjs_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def platform
|
29
|
+
if platform = available_platforms.find {|p| p.useable? }
|
30
|
+
platform.ensure_installed!
|
31
|
+
platform
|
32
|
+
else
|
33
|
+
raise UnknownPlatform, "Could not find an appropriate PhantomJS library for your platform (#{RUBY_PLATFORM} :( Please install manually."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Removes the local phantomjs copy
|
38
|
+
def implode!
|
39
|
+
FileUtils.rm_rf File.join(File.expand_path('~'), '.phantomjs')
|
40
|
+
end
|
41
|
+
|
42
|
+
# Clears cached state. Primarily useful for testing.
|
43
|
+
def reset!
|
44
|
+
@base_dir = @path = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
# Run phantomjs with the given arguments, and either
|
48
|
+
# return the stdout or yield each line to the passed block.
|
49
|
+
def run(*args, &block)
|
50
|
+
IO.popen([path, *args]) do |io|
|
51
|
+
block ? io.each(&block) : io.read
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
require 'phantomjs/platform'
|
58
|
+
Phantomjs.available_platforms << Phantomjs::Platform::Linux32
|
59
|
+
Phantomjs.available_platforms << Phantomjs::Platform::Linux64
|
60
|
+
Phantomjs.available_platforms << Phantomjs::Platform::OsX
|
61
|
+
Phantomjs.available_platforms << Phantomjs::Platform::Win32
|
data/phantomjs.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/phantomjs/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Christoph Olszowka"]
|
6
|
+
gem.email = ["christoph at olszowka.de"]
|
7
|
+
gem.description = %q{Auto-install phantomjs on demand for current platform. Comes with poltergeist integration.}
|
8
|
+
gem.summary = %q{Auto-install phantomjs on demand for current platform. Comes with poltergeist integration.}
|
9
|
+
gem.homepage = "https://github.com/colszowka/phantomjs-gem"
|
10
|
+
gem.license = 'MIT'
|
11
|
+
|
12
|
+
gem.add_development_dependency 'poltergeist', '~> 1.5'
|
13
|
+
gem.add_development_dependency 'capybara', '~> 2.4'
|
14
|
+
gem.add_development_dependency 'rspec', "~> 2.99"
|
15
|
+
gem.add_development_dependency 'simplecov'
|
16
|
+
gem.add_development_dependency 'rake'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($\)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.name = "phantomjs_2.0"
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
gem.version = Phantomjs::VERSION
|
24
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'phantomjs/poltergeist'
|
3
|
+
|
4
|
+
HTML_RESPONSE = <<HTML
|
5
|
+
<html>
|
6
|
+
<head></head>
|
7
|
+
<body>
|
8
|
+
<h1>Hello</h1>
|
9
|
+
<div id="js">NO JS :(</div>
|
10
|
+
<script type="text/javascript">
|
11
|
+
document.getElementById('js').innerHTML = 'OMG JS!';
|
12
|
+
</script>
|
13
|
+
</body>
|
14
|
+
</html>
|
15
|
+
HTML
|
16
|
+
Capybara.app = lambda {|env| [200, {"Content-Type" => "text/html"}, [HTML_RESPONSE]] }
|
17
|
+
Capybara.default_driver = :poltergeist
|
18
|
+
|
19
|
+
describe Phantomjs do
|
20
|
+
describe 'A HTTP request using capybara/poltergeist' do
|
21
|
+
include Capybara::DSL
|
22
|
+
|
23
|
+
before { visit '/' }
|
24
|
+
it "has displayed static html content" do
|
25
|
+
within('h1') { page.should have_content('Hello') }
|
26
|
+
end
|
27
|
+
|
28
|
+
it "has processed javascript" do
|
29
|
+
within "#js" do
|
30
|
+
page.should_not have_content('NO JS :(')
|
31
|
+
page.should have_content('OMG JS!')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".run" do
|
37
|
+
it "runs phantomjs binary with the correct arguments" do
|
38
|
+
script = File.expand_path('./spec/runner.js')
|
39
|
+
result = Phantomjs.run(script, 'foo1', 'foo2')
|
40
|
+
result.should eq("bar foo1\nbar foo2\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "accepts a block that will get called for each line of output" do
|
44
|
+
lines = []
|
45
|
+
script = File.expand_path('./spec/runner.js')
|
46
|
+
Phantomjs.run(script, 'foo1', 'foo2') { |line| lines << line }
|
47
|
+
lines.should eq(["bar foo1\n", "bar foo2\n"])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Phantomjs::Platform do
|
4
|
+
before(:each) { Phantomjs.reset! }
|
5
|
+
describe "with a system install present" do
|
6
|
+
describe "#system_phantomjs_installed?" do
|
7
|
+
it "is true when the system version matches Phantomjs.version" do
|
8
|
+
Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return(Phantomjs.version)
|
9
|
+
expect(Phantomjs::Platform.system_phantomjs_installed?).to be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is false when the system version does not match Phantomjs.version" do
|
13
|
+
Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return('1.2.3')
|
14
|
+
expect(Phantomjs::Platform.system_phantomjs_installed?).to be_false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "is false when there's no system version" do
|
18
|
+
Phantomjs::Platform.should_receive(:system_phantomjs_version).and_return(nil)
|
19
|
+
expect(Phantomjs::Platform.system_phantomjs_installed?).to be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "on a 64 bit linux" do
|
25
|
+
before do
|
26
|
+
Phantomjs::Platform.stub(:host_os).and_return('linux-gnu')
|
27
|
+
Phantomjs::Platform.stub(:architecture).and_return('x86_64')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "reports the Linux64 Platform as useable" do
|
31
|
+
Phantomjs::Platform::Linux64.should be_useable
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "without system install" do
|
35
|
+
before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) }
|
36
|
+
|
37
|
+
it "returns the correct phantom js executable path for the platform" do
|
38
|
+
Phantomjs.path.should =~ /x86_64-linux\/bin\/phantomjs$/
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "with system install" do
|
43
|
+
before(:each) do
|
44
|
+
Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version)
|
45
|
+
Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns the correct phantom js executable path for the platform" do
|
49
|
+
expect(Phantomjs.path).to be == '/tmp/path'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "reports the Linux32 platform as unuseable" do
|
54
|
+
Phantomjs::Platform::Linux32.should_not be_useable
|
55
|
+
end
|
56
|
+
|
57
|
+
it "reports the Darwin platform as unuseable" do
|
58
|
+
Phantomjs::Platform::OsX.should_not be_useable
|
59
|
+
end
|
60
|
+
|
61
|
+
it "reports the Win32 Platform as unuseable" do
|
62
|
+
Phantomjs::Platform::Win32.should_not be_useable
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "on a 32 bit linux" do
|
67
|
+
before do
|
68
|
+
Phantomjs::Platform.stub(:host_os).and_return('linux-gnu')
|
69
|
+
Phantomjs::Platform.stub(:architecture).and_return('x86_32')
|
70
|
+
end
|
71
|
+
|
72
|
+
it "reports the Linux32 Platform as useable" do
|
73
|
+
Phantomjs::Platform::Linux32.should be_useable
|
74
|
+
end
|
75
|
+
|
76
|
+
it "reports another Linux32 Platform as useable" do
|
77
|
+
Phantomjs::Platform.stub(:host_os).and_return('linux-gnu')
|
78
|
+
Phantomjs::Platform.stub(:architecture).and_return('i686')
|
79
|
+
Phantomjs::Platform::Linux32.should be_useable
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "without system install" do
|
83
|
+
before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) }
|
84
|
+
|
85
|
+
it "returns the correct phantom js executable path for the platform" do
|
86
|
+
Phantomjs.path.should =~ /x86_32-linux\/bin\/phantomjs$/
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "with system install" do
|
91
|
+
before(:each) do
|
92
|
+
Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version)
|
93
|
+
Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns the correct phantom js executable path for the platform" do
|
97
|
+
expect(Phantomjs.path).to be == '/tmp/path'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "reports the Linux64 platform as unuseable" do
|
102
|
+
Phantomjs::Platform::Linux64.should_not be_useable
|
103
|
+
end
|
104
|
+
|
105
|
+
it "reports the Darwin platform as unuseable" do
|
106
|
+
Phantomjs::Platform::OsX.should_not be_useable
|
107
|
+
end
|
108
|
+
|
109
|
+
it "reports the Win32 Platform as unuseable" do
|
110
|
+
Phantomjs::Platform::Win32.should_not be_useable
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "on OS X" do
|
115
|
+
before do
|
116
|
+
Phantomjs::Platform.stub(:host_os).and_return('darwin')
|
117
|
+
Phantomjs::Platform.stub(:architecture).and_return('x86_64')
|
118
|
+
end
|
119
|
+
|
120
|
+
it "reports the Darwin platform as useable" do
|
121
|
+
Phantomjs::Platform::OsX.should be_useable
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "without system install" do
|
125
|
+
before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) }
|
126
|
+
|
127
|
+
it "returns the correct phantom js executable path for the platform" do
|
128
|
+
Phantomjs.path.should =~ /darwin\/bin\/phantomjs$/
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "with system install" do
|
133
|
+
before(:each) do
|
134
|
+
Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version)
|
135
|
+
Phantomjs::Platform.stub(:system_phantomjs_path).and_return('/tmp/path')
|
136
|
+
end
|
137
|
+
|
138
|
+
it "returns the correct phantom js executable path for the platform" do
|
139
|
+
expect(Phantomjs.path).to be == '/tmp/path'
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it "reports the Linux32 Platform as unuseable" do
|
144
|
+
Phantomjs::Platform::Linux32.should_not be_useable
|
145
|
+
end
|
146
|
+
|
147
|
+
it "reports the Linux64 platform as unuseable" do
|
148
|
+
Phantomjs::Platform::Linux64.should_not be_useable
|
149
|
+
end
|
150
|
+
|
151
|
+
it "reports the Win32 Platform as unuseable" do
|
152
|
+
Phantomjs::Platform::Win32.should_not be_useable
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "on Windows" do
|
157
|
+
before do
|
158
|
+
Phantomjs::Platform.stub(:host_os).and_return('mingw32')
|
159
|
+
Phantomjs::Platform.stub(:architecture).and_return('i686')
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "without system install" do
|
163
|
+
before(:each) { Phantomjs::Platform.stub(:system_phantomjs_version).and_return(nil) }
|
164
|
+
|
165
|
+
it "returns the correct phantom js executable path for the platform" do
|
166
|
+
Phantomjs.path.should =~ /win32\/phantomjs.exe$/
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "with system install" do
|
171
|
+
before(:each) do
|
172
|
+
Phantomjs::Platform.stub(:system_phantomjs_version).and_return(Phantomjs.version)
|
173
|
+
Phantomjs::Platform.stub(:system_phantomjs_path).and_return("#{ENV['TEMP']}/path")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "returns the correct phantom js executable path for the platform" do
|
177
|
+
expect(Phantomjs.path).to be == "#{ENV['TEMP']}/path"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "reports the Darwin platform as unuseable" do
|
182
|
+
Phantomjs::Platform::OsX.should_not be_useable
|
183
|
+
end
|
184
|
+
|
185
|
+
it "reports the Linux32 Platform as unuseable" do
|
186
|
+
Phantomjs::Platform::Linux32.should_not be_useable
|
187
|
+
end
|
188
|
+
|
189
|
+
it "reports the Linux64 platform as unuseable" do
|
190
|
+
Phantomjs::Platform::Linux64.should_not be_useable
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe 'on an unknown platform' do
|
195
|
+
before do
|
196
|
+
Phantomjs::Platform.stub(:host_os).and_return('foobar')
|
197
|
+
end
|
198
|
+
|
199
|
+
it "raises an UnknownPlatform error" do
|
200
|
+
-> { Phantomjs.platform }.should raise_error(Phantomjs::UnknownPlatform)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
data/spec/runner.js
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phantomjs_2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christoph Olszowka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: poltergeist
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: capybara
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.99'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.99'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Auto-install phantomjs on demand for current platform. Comes with poltergeist
|
84
|
+
integration.
|
85
|
+
email:
|
86
|
+
- christoph at olszowka.de
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".simplecov"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- lib/phantomjs.rb
|
100
|
+
- lib/phantomjs/platform.rb
|
101
|
+
- lib/phantomjs/poltergeist.rb
|
102
|
+
- lib/phantomjs/version.rb
|
103
|
+
- phantomjs.gemspec
|
104
|
+
- spec/phantomjs_spec.rb
|
105
|
+
- spec/platform_spec.rb
|
106
|
+
- spec/runner.js
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
homepage: https://github.com/colszowka/phantomjs-gem
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.4.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Auto-install phantomjs on demand for current platform. Comes with poltergeist
|
132
|
+
integration.
|
133
|
+
test_files:
|
134
|
+
- spec/phantomjs_spec.rb
|
135
|
+
- spec/platform_spec.rb
|
136
|
+
- spec/runner.js
|
137
|
+
- spec/spec_helper.rb
|