glebtv-phantomjs 1.9.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aca6f2d9c6d008898b99baafdaaeaa469e8e2f15
4
+ data.tar.gz: 03207a839b27453f87a1d825f8f8a3b1fe9d819a
5
+ SHA512:
6
+ metadata.gz: 29e48bd7792bc44fef50b41cbe0faa7b740d7acc5d7d1c2dc021308f5ba9ef083e49cbdf7625d188b6797403b07ad2e06b282d0fc42c582425c67b3b0d49f33d
7
+ data.tar.gz: 961d4b0b0f87bebd8f157a8fe23bedddf213b836aeb278cece8d901f512c641f50b94af0e5b36067768a289f19dd5462d04dd97de7ae39ba480b8b336a154505
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1 @@
1
+ SimpleCov.start
@@ -0,0 +1,12 @@
1
+ script:
2
+ - bundle
3
+ - bundle exec rspec
4
+ rvm:
5
+ - 1.9
6
+ - 2.0
7
+ - 2.1
8
+ - jruby-19mode
9
+ notifications:
10
+ email:
11
+ on_success: always
12
+ on_failure: always
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in phantomjs.gemspec
4
+ gemspec
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.
@@ -0,0 +1,78 @@
1
+ # PhantomJS as a RubyGem
2
+
3
+ [![Build Status](https://travis-ci.org/colszowka/phantomjs-gem.png?branch=master)](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/
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require 'phantomjs'
@@ -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
@@ -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://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2'
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://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.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-1.9.8-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-1.9.8-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
@@ -0,0 +1,3 @@
1
+ module Phantomjs
2
+ VERSION = "1.9.8.0"
3
+ end
@@ -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'
13
+ gem.add_development_dependency 'capybara', '~> 2.0.0'
14
+ gem.add_development_dependency 'rspec', ">= 2.11.0"
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 = "glebtv-phantomjs"
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
@@ -0,0 +1,3 @@
1
+ console.log('bar ' + phantom.args[0]);
2
+ console.log('bar ' + phantom.args[1]);
3
+ phantom.exit();
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'simplecov'
3
+ require 'bundler/setup'
4
+
5
+ require 'phantomjs'
6
+ require 'capybara/rspec'
7
+
8
+ Phantomjs.implode!
9
+
10
+ RSpec.configure do |config|
11
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: glebtv-phantomjs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.9.8.0
5
+ platform: ruby
6
+ authors:
7
+ - Christoph Olszowka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-04 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: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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.0.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0
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.11.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.11.0
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/glebtv-phantomjs.rb
100
+ - lib/phantomjs.rb
101
+ - lib/phantomjs/platform.rb
102
+ - lib/phantomjs/poltergeist.rb
103
+ - lib/phantomjs/version.rb
104
+ - phantomjs.gemspec
105
+ - spec/phantomjs_spec.rb
106
+ - spec/platform_spec.rb
107
+ - spec/runner.js
108
+ - spec/spec_helper.rb
109
+ homepage: https://github.com/colszowka/phantomjs-gem
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.4
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Auto-install phantomjs on demand for current platform. Comes with poltergeist
133
+ integration.
134
+ test_files:
135
+ - spec/phantomjs_spec.rb
136
+ - spec/platform_spec.rb
137
+ - spec/runner.js
138
+ - spec/spec_helper.rb