Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Exorcise poltergeist

  • Loading branch information...
commit 067ecd31532e4b1df42c57f96adad04ae44a2af7 1 parent 21418f1
@haines haines authored
View
4 .travis.yml
@@ -8,7 +8,3 @@ matrix:
allow_failures:
- rvm: rbx-19mode
- rvm: ruby-head
-before_script:
- - sudo ci/install_phantomjs
- - "export PATH=phantomjs/bin:$PATH"
- - phantomjs --version
View
6 ci/install_phantomjs
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-version=phantomjs-1.7.0-linux-i686
-wget http://phantomjs.googlecode.com/files/$version.tar.bz2
-tar xjf $version.tar.bz2
-mv $version phantomjs
View
1  draper.gemspec
@@ -26,5 +26,4 @@ Gem::Specification.new do |s|
s.add_development_dependency 'minitest-rails', '~> 0.2'
s.add_development_dependency 'minitest', '~> 3.0' if RUBY_PLATFORM == "java"
s.add_development_dependency 'capybara'
- s.add_development_dependency 'poltergeist'
end
View
16 spec/integration/integration_spec.rb
@@ -22,26 +22,20 @@
end
describe "integration" do
- include Capybara::DSL
-
- rails_env = ENV["RAILS_ENV"].to_s
- raise ArgumentError, "RAILS_ENV must be development or production" unless ["development", "production"].include?(rails_env)
-
- app = DummyApp.new(rails_env)
+ app = DummyApp.new(ENV["RAILS_ENV"])
app.start_server do
- describe "in #{rails_env}" do
- let(:environment) { rails_env }
- before { Capybara.app_host = app.url }
+ describe "in #{app.environment}" do
+ let(:environment) { app.environment }
context "in a view" do
- before { visit("/posts/1") }
+ let(:page) { app.get("/posts/1") }
it_behaves_like "a decorator in a view"
end
context "in a mailer" do
- before { visit("/posts/1/mail") }
+ let(:page) { app.get("/posts/1/mail") }
it_behaves_like "a decorator in a view"
end
View
17 spec/support/dummy_app.rb
@@ -1,25 +1,26 @@
-require 'capybara'
-require 'capybara/dsl'
-require 'capybara/poltergeist'
-require 'singleton'
require 'socket'
+require 'net/http'
# Adapted from code by Jon Leighton
# https://github.com/jonleighton/focused_controller/blob/ec7ccf1/test/acceptance/app_test.rb
-Capybara.run_server = false
-Capybara.default_driver = :poltergeist
-
class DummyApp
def initialize(environment)
+ raise ArgumentError, "Environment must be development or production" unless ["development", "production"].include?(environment.to_s)
@environment = environment
end
+ attr_reader :environment
+
def url
"http://#{localhost}:#{port}"
end
+ def get(path)
+ Net::HTTP.get(URI(url + path))
+ end
+
def within_app(&block)
Dir.chdir(root, &block)
end
@@ -66,7 +67,7 @@ def localhost
def port
@port ||= begin
server = TCPServer.new(localhost, 0)
- port = server.addr[1]
+ server.addr[1]
ensure
server.close if server
end
View
10 spec/support/matchers/have_text.rb
@@ -1,3 +1,5 @@
+require 'capybara'
+
module HaveTextMatcher
def have_text(text)
HaveText.new(text)
@@ -14,7 +16,7 @@ def in(css)
end
def matches?(subject)
- @subject = subject
+ @subject = Capybara.string(subject)
@subject.has_css?(@css || "*", text: @text)
end
@@ -30,7 +32,11 @@ def failure_message_for_should_not
private
def within
- "#{inside} within\n#{@subject.html}"
+ if @css && @subject.has_css?(@css)
+ "within\n#{@subject.find(@css).native}"
+ else
+ "#{inside} within\n#{@subject.native}"
+ end
end
def inside

0 comments on commit 067ecd3

Please sign in to comment.
Something went wrong with that request. Please try again.