Update to modern RSpec

This commit is contained in:
Thomas Walpole 2017-02-03 11:20:27 -08:00
parent a76ccd7606
commit ed295f25bd
21 changed files with 484 additions and 475 deletions

View File

@ -28,15 +28,15 @@ matrix:
gemfile: gemfiles/2.7.gemfile
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt4/bin/qmake
- rvm: 1.9.3
gemfile: gemfiles/2.11.gemfile
gemfile: gemfiles/2.12.gemfile
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt4/bin/qmake
- rvm: 2.3.1
- rvm: 2.3.3
gemfile: gemfiles/master.gemfile
allow_failures:
- gemfile: gemfiles/master.gemfile
gemfile:
- gemfiles/2.7.gemfile
- gemfiles/2.11.gemfile
- gemfiles/2.12.gemfile
before_install:
- gem install bundler
install: bundle

View File

@ -1,11 +1,12 @@
appraise "2.7" do
gem "capybara", "~> 2.7.0"
gem "rspec", "~> 2.14.0"
gem 'addressable', '< 2.5.0', :platforms=>[:ruby_19, :jruby_19] # 2.5 requires public_suffix which requires ruby 2.0
gem 'nokogiri', '< 1.7.0', :platforms=>[:ruby_19, :jruby_19] # 1.7.0 requires ruby 2.1+
end
appraise "2.11" do
gem "capybara", "~> 2.11.0"
appraise "2.12" do
gem "capybara", "~> 2.12.0"
gem 'addressable', '< 2.5.0', :platforms=>[:ruby_19, :jruby_19] # 2.5 requires public_suffix which requires ruby 2.0
gem 'nokogiri', '< 1.7.0', :platforms=>[:ruby_19, :jruby_19] # 1.7.0 requires ruby 2.1+
end

View File

@ -13,17 +13,17 @@ GEM
appraisal (0.4.1)
bundler
rake
capybara (2.11.0)
capybara (2.12.0)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
diff-lcs (1.2.5)
ffi (1.9.14-java)
json (1.8.3)
json (1.8.3-java)
diff-lcs (1.3)
ffi (1.9.17-java)
json (1.8.6)
json (1.8.6-java)
launchy (2.4.3)
addressable (~> 2.3)
launchy (2.4.3-java)
@ -34,6 +34,9 @@ GEM
mini_portile2 (2.1.0)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
nokogiri (1.7.0.1-java)
nokogiri (1.7.0.1-x86-mingw32)
mini_portile2 (~> 2.1.0)
public_suffix (2.0.5)
rack (1.6.5)
rack-protection (1.5.3)
@ -41,21 +44,26 @@ GEM
rack-test (0.6.3)
rack (>= 1.0)
rake (11.3.0)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.99.4)
sinatra (1.4.7)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
spoon (0.0.6)
ffi
tilt (2.0.5)
tilt (2.0.6)
xpath (2.0.0)
nokogiri (~> 1.3)
@ -72,8 +80,8 @@ DEPENDENCIES
mime-types (< 3.0)
mini_magick
rake (< 12.0.0)
rspec (~> 2.14)
rspec (~> 3.5)
sinatra
BUNDLED WITH
1.13.6
1.14.3

View File

@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("capybara", ">= 2.3.0", "< 2.13.0")
s.add_runtime_dependency("json")
s.add_development_dependency("rspec", "~> 2.14")
s.add_development_dependency("rspec", "~> 3.5")
# Sinatra is used by Capybara's TestApp
s.add_development_dependency("sinatra")
s.add_development_dependency("mini_magick")

View File

@ -4,7 +4,7 @@ source "https://rubygems.org"
gem "mime-types", "< 3.0", :platforms=>[:ruby_19, :jruby_19]
gem "json", "< 2.0", :platforms=>[:ruby_19, :jruby_19]
gem "capybara", "~> 2.11.0"
gem "capybara", "~> 2.12.0"
gem "addressable", "< 2.5.0", :platforms=>[:ruby_19, :jruby_19]
gem "nokogiri", "< 1.7.0", :platforms=>[:ruby_19, :jruby_19]

View File

@ -5,6 +5,7 @@ source "https://rubygems.org"
gem "mime-types", "< 3.0", :platforms=>[:ruby_19, :jruby_19]
gem "json", "< 2.0", :platforms=>[:ruby_19, :jruby_19]
gem "capybara", "~> 2.7.0"
gem "rspec", "~> 2.14.0"
gem "addressable", "< 2.5.0", :platforms=>[:ruby_19, :jruby_19]
gem "nokogiri", "< 1.7.0", :platforms=>[:ruby_19, :jruby_19]

View File

@ -7,11 +7,13 @@ module Capybara
actual.error_messages.any?
end
failure_message_for_should do |actual|
#RSpec 2 compatability
send(respond_to?(:failure_message) ? :failure_message : :failure_message_for_should) do |_actual|
"Expected Javascript errors, but there were none."
end
failure_message_for_should_not do |actual|
#RSpec 2 compatability
send(respond_to?(:failure_message_when_negated) ? :failure_message_when_negated : :failure_message_for_should_not) do |actual|
actual = resolve(actual)
"Expected no Javascript errors, got:\n#{error_messages_for(actual)}"
end

View File

@ -59,7 +59,7 @@ module Capybara::Webkit
when String
key.to_s
else
raise Capybara::NotSupportedByDriverError.new
raise Capybara::NotSupportedByDriverError.new, "Unrecognized key(s) in #{key}"
end
}.join)
end

View File

@ -21,11 +21,9 @@ describe Capybara::Webkit::Browser do
end
it "doesn't try to read an empty response" do
connection = double("connection")
connection.stub(:puts)
connection.stub(:print)
connection.stub(:gets).and_return("ok\n", "0\n")
connection.stub(:read).and_raise(StandardError.new("tried to read empty response"))
connection = double("connection", puts: nil, print: nil)
allow(connection).to receive(:gets).and_return("ok\n", "0\n")
allow(connection).to receive(:read).and_raise(StandardError.new("tried to read empty response"))
browser = Capybara::Webkit::Browser.new(connection)
@ -37,9 +35,9 @@ describe Capybara::Webkit::Browser do
it 'raises an error of given class' do
error_json = '{"class": "ClickFailed"}'
connection.should_receive(:gets).ordered.and_return 'error'
connection.should_receive(:gets).ordered.and_return error_json.bytesize
connection.stub read: error_json
expect(connection).to receive(:gets).ordered.and_return 'error'
expect(connection).to receive(:gets).ordered.and_return error_json.bytesize
allow(connection).to receive(:read).and_return(error_json)
expect { browser.command 'blah', 'meh' }.to raise_error(Capybara::Webkit::ClickFailed)
end

View File

@ -6,25 +6,25 @@ describe CapybaraWebkitBuilder do
it "will use the env variable for #make_bin" do
with_env_vars("MAKE" => "fake_make") do
builder.make_bin.should == "fake_make"
expect(builder.make_bin).to eq "fake_make"
end
end
it "will use the env variable for #qmake_bin" do
with_env_vars("QMAKE" => "fake_qmake") do
builder.qmake_bin.should == "fake_qmake"
expect(builder.qmake_bin).to eq "fake_qmake"
end
end
it "defaults the #make_bin" do
with_env_vars("MAKE_BIN" => nil) do
builder.make_bin.should == 'make'
expect(builder.make_bin).to eq 'make'
end
end
it "defaults the #qmake_bin" do
with_env_vars("QMAKE" => nil) do
builder.qmake_bin.should == 'qmake'
expect(builder.qmake_bin).to eq 'qmake'
end
end
end

View File

@ -5,13 +5,12 @@ describe Capybara::Webkit::Connection do
it "sets appropriate options on its socket" do
socket = double("socket")
server = double(:Server, start: nil, port: 123)
TCPSocket.stub(:open).and_return(socket)
allow(TCPSocket).to receive(:open).and_return(socket)
if defined?(Socket::TCP_NODELAY)
socket.
should_receive(:setsockopt).
expect(socket).to receive(:setsockopt).
with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
else
socket.should_not_receive(:setsockopt)
expect(socket).not_to receive(:setsockopt)
end
Capybara::Webkit::Connection.new(server: server)

View File

@ -4,7 +4,7 @@ require 'capybara/webkit/cookie_jar'
describe Capybara::Webkit::CookieJar do
let(:browser) {
browser = double("Browser")
browser.stub(:get_cookies) { [
allow(browser).to receive(:get_cookies) { [
"cookie1=1; domain=.example.org; path=/",
"cookie1=2; domain=.example.org; path=/dir1/",
"cookie1=3; domain=.facebook.com; path=/",
@ -17,32 +17,32 @@ describe Capybara::Webkit::CookieJar do
describe "#find" do
it "returns a cookie object" do
subject.find("cookie1", "www.facebook.com").domain.should eq ".facebook.com"
expect(subject.find("cookie1", "www.facebook.com").domain).to eq ".facebook.com"
end
it "returns the right cookie for every given domain/path" do
subject.find("cookie1", "example.org").value.should eq "1"
subject.find("cookie1", "www.facebook.com").value.should eq "3"
subject.find("cookie2", "sub1.example.org").value.should eq "4"
expect(subject.find("cookie1", "example.org").value).to eq "1"
expect(subject.find("cookie1", "www.facebook.com").value).to eq "3"
expect(subject.find("cookie2", "sub1.example.org").value).to eq "4"
end
it "does not return a cookie from other domain" do
subject.find("cookie2", "www.example.org").should eq nil
expect(subject.find("cookie2", "www.example.org")).to eq nil
end
it "respects path precedence rules" do
subject.find("cookie1", "www.example.org").value.should eq "1"
subject.find("cookie1", "www.example.org", "/dir1/123").value.should eq "2"
expect(subject.find("cookie1", "www.example.org").value).to eq "1"
expect(subject.find("cookie1", "www.example.org", "/dir1/123").value).to eq "2"
end
end
describe "#[]" do
it "returns the first matching cookie's value" do
subject["cookie1", "example.org"].should eq "1"
expect(subject["cookie1", "example.org"]).to eq "1"
end
it "returns nil if no cookie is found" do
subject["notexisting"].should eq nil
expect(subject["notexisting"]).to eq nil
end
end
end

View File

@ -34,16 +34,16 @@ describe Capybara::Webkit::Driver, "rendering an image" do
before { render({}) }
it "should be a PNG" do
@image[:format].should eq "PNG"
expect(@image[:format]).to eq "PNG"
end
it "width default to 1000px (with 15px less for the scrollbar)" do
@image[:width].should be < 1001
@image[:width].should be > 1000-17
expect(@image[:width]).to be < 1001
expect(@image[:width]).to be > 1000-17
end
it "height should be at least 10px" do
@image[:height].should be >= 10
expect(@image[:height]).to be >= 10
end
end
@ -51,16 +51,16 @@ describe Capybara::Webkit::Driver, "rendering an image" do
before { render(:width => 500, :height => 400) }
it "width should match the width given" do
@image[:width].should eq 500
expect(@image[:width]).to eq 500
end
it "height should match the height given" do
@image[:height].should eq 400
expect(@image[:height]).to eq 400
end
it "should reset window dimensions to their default value" do
driver.evaluate_script('window.innerWidth').should eq 1680
driver.evaluate_script('window.innerHeight').should eq 1050
expect(driver.evaluate_script('window.innerWidth')).to eq 1680
expect(driver.evaluate_script('window.innerHeight')).to eq 1050
end
end
@ -68,16 +68,16 @@ describe Capybara::Webkit::Driver, "rendering an image" do
before { render(:width => 50, :height => 10) }
it "width should be greater than the width given" do
@image[:width].should be > 50
expect(@image[:width]).to be > 50
end
it "height should be greater than the height given" do
@image[:height].should be > 10
expect(@image[:height]).to be > 10
end
it "should restore viewport dimensions after rendering" do
driver.evaluate_script('window.innerWidth').should eq 1680
driver.evaluate_script('window.innerHeight').should eq 1050
expect(driver.evaluate_script('window.innerWidth')).to eq 1680
expect(driver.evaluate_script('window.innerHeight')).to eq 1050
end
end
@ -86,8 +86,8 @@ describe Capybara::Webkit::Driver, "rendering an image" do
it "should restore viewport dimensions after rendering" do
render({})
driver.evaluate_script('window.innerWidth').should eq 800
driver.evaluate_script('window.innerHeight').should eq 600
expect(driver.evaluate_script('window.innerWidth')).to eq 800
expect(driver.evaluate_script('window.innerHeight')).to eq 600
end
end

View File

@ -27,23 +27,23 @@ describe Capybara::Webkit::Driver, "#resize_window(width, height)" do
driver.visit("#{AppRunner.app_host}/")
driver.resize_window(800, 600)
driver.html.should include("[800x600]")
expect(driver.html).to include("[800x600]")
driver.resize_window(300, 100)
driver.html.should include("[300x100]")
expect(driver.html).to include("[300x100]")
end
it "resizes the window to the specified size even before the document has loaded" do
driver.resize_window(800, 600)
driver.visit("#{AppRunner.app_host}/")
driver.html.should include("[800x600]")
expect(driver.html).to include("[800x600]")
end
it "resets the window to the default size when the driver is reset" do
driver.resize_window(800, 600)
driver.reset!
driver.visit("#{AppRunner.app_host}/")
driver.html.should include(DEFAULT_DIMENTIONS)
expect(driver.html).to include(DEFAULT_DIMENTIONS)
end
it "resizes windows by handle" do
@ -54,8 +54,8 @@ describe Capybara::Webkit::Driver, "#resize_window(width, height)" do
driver.resize_window_to(driver.window_handles.first, 800, 600)
driver.resize_window_to(driver.window_handles.last, 400, 300)
driver.window_size(driver.window_handles.first).should eq [800, 600]
driver.window_size(driver.window_handles.last).should eq [400, 300]
expect(driver.window_size(driver.window_handles.first)).to eq [800, 600]
expect(driver.window_size(driver.window_handles.last)).to eq [400, 300]
end
it "maximizes a window" do
@ -64,7 +64,7 @@ describe Capybara::Webkit::Driver, "#resize_window(width, height)" do
driver.maximize_window(driver.current_window_handle)
width, height = *driver.window_size(driver.current_window_handle)
width.should be > 400
height.should be > 300
expect(width).to be > 400
expect(height).to be > 300
end
end

File diff suppressed because it is too large Load Diff

View File

@ -7,5 +7,5 @@ describe Capybara::Webkit::JsonError do
it { should be_an_instance_of Capybara::Webkit::ClickFailed }
its(:message) { should == 'Error clicking this element' }
it { expect(subject.message).to eq 'Error clicking this element' }
end

View File

@ -50,7 +50,7 @@ describe Capybara::Session do
it "waits for a request to load" do
subject.visit("/")
subject.find_button("Submit").click
subject.should have_content("Goodbye");
expect(subject).to have_content("Goodbye");
end
end
@ -76,12 +76,12 @@ describe Capybara::Session do
end
it "inspects nodes" do
subject.all(:xpath, "//strong").first.inspect.should include("strong")
expect(subject.all(:xpath, "//strong").first.inspect).to include("strong")
end
it "can read utf8 string" do
utf8str = subject.all(:xpath, "//span").first.text
utf8str.should eq('UTF8文字列')
expect(utf8str).to eq('UTF8文字列')
end
it "can click utf8 string" do
@ -91,7 +91,7 @@ describe Capybara::Session do
it "raises an ElementNotFound error when the selector scope is no longer valid" do
subject.within('//body') do
subject.click_link 'Link'
lambda { subject.find('//strong') }.should raise_error(Capybara::ElementNotFound)
expect { subject.find('//strong') }.to raise_error(Capybara::ElementNotFound)
end
end
end
@ -119,26 +119,26 @@ describe Capybara::Session do
it "should get status code" do
subject.visit '/'
subject.status_code.should eq 200
expect(subject.status_code).to eq 200
end
it "should reset status code" do
subject.visit '/'
subject.status_code.should eq 200
expect(subject.status_code).to eq 200
subject.reset!
subject.status_code.should eq 0
expect(subject.status_code).to eq 0
end
it "should get response headers" do
subject.visit '/'
subject.response_headers['X-Capybara'].should eq 'WebKit'
expect(subject.response_headers['X-Capybara']).to eq 'WebKit'
end
it "should reset response headers" do
subject.visit '/'
subject.response_headers['X-Capybara'].should eq 'WebKit'
expect(subject.response_headers['X-Capybara']).to eq 'WebKit'
subject.reset!
subject.response_headers['X-Capybara'].should eq nil
expect(subject.response_headers['X-Capybara']).to eq nil
end
end
@ -188,7 +188,7 @@ describe Capybara::Session do
subject.visit("/")
subject.click_link('Click Me!')
Capybara.using_wait_time(5) do
subject.should have_content("finished")
expect(subject).to have_content("finished")
end
end
end
@ -235,7 +235,7 @@ describe Capybara::Session do
subject.fill_in('password', with: 'temp4now')
subject.click_button('Submit')
subject.visit('/other')
subject.should have_content('admin')
expect(subject).to have_content('admin')
end
end
@ -299,7 +299,7 @@ describe Capybara::Session do
subject.within_frame 'a_frame' do
subject.within_frame 'b_frame' do
subject.click_button 'B Button'
subject.should have_content('Page C')
expect(subject).to have_content('Page C')
end
end
end
@ -319,9 +319,9 @@ describe Capybara::Session do
subject.within_frame('a_frame') do
subject.within_frame('b_frame') do
lambda {
expect {
subject.click_button 'B Button'
}.should raise_error(Capybara::Webkit::ClickFailed)
}.to raise_error(Capybara::Webkit::ClickFailed)
end
end
end
@ -379,29 +379,29 @@ describe Capybara::Session do
it 'clicks in the center of an element' do
subject.visit('/')
subject.find(:css, '#one').click
subject.find(:css, '#one')['data-click-x'].should eq '199'
subject.find(:css, '#one')['data-click-y'].should eq '199'
expect(subject.find(:css, '#one')['data-click-x']).to eq '199'
expect(subject.find(:css, '#one')['data-click-y']).to eq '199'
end
it 'clicks in the center of the viewable area of an element' do
subject.visit('/')
subject.driver.resize_window(200, 200)
subject.find(:css, '#one').click
subject.find(:css, '#one')['data-click-x'].should eq '149'
subject.find(:css, '#one')['data-click-y'].should eq '99'
expect(subject.find(:css, '#one')['data-click-x']).to eq '149'
expect(subject.find(:css, '#one')['data-click-y']).to eq '99'
end
it 'does not raise an error when an anchor contains empty nodes' do
subject.visit('/')
lambda { subject.click_link('Some link') }.should_not raise_error
expect { subject.click_link('Some link') }.not_to raise_error
end
it 'scrolls an element into view when clicked' do
subject.visit('/')
subject.driver.resize_window(200, 200)
subject.find(:css, '#two').click
subject.find(:css, '#two')['data-click-x'].should_not be_nil
subject.find(:css, '#two')['data-click-y'].should_not be_nil
expect(subject.find(:css, '#two')['data-click-x']).not_to be_nil
expect(subject.find(:css, '#two')['data-click-y']).not_to be_nil
end
it 'raises an error if an element is obscured when clicked' do
@ -417,11 +417,11 @@ describe Capybara::Session do
expect {
subject.find(:css, '#one').click
}.to raise_error(Capybara::Webkit::ClickFailed) { |exception|
exception.message.should =~ %r{Failed.*\[@id='one'\].*overlapping.*\[@id='two'\].*at position}
expect(exception.message).to match %r{Failed.*\[@id='one'\].*overlapping.*\[@id='two'\].*at position}
screenshot_pattern = %r{A screenshot of the page at the time of the failure has been written to (.*)}
exception.message.should =~ screenshot_pattern
expect(exception.message).to match screenshot_pattern
file = exception.message.match(screenshot_pattern)[1]
File.exist?(file).should be_true
expect(File.exist?(file)).to be true
}
end
@ -438,9 +438,9 @@ describe Capybara::Session do
document.body.appendChild(div);
JS
lambda {
expect {
subject.check('bar')
}.should raise_error(Capybara::Webkit::ClickFailed)
}.to raise_error(Capybara::Webkit::ClickFailed)
end
it 'raises an error if an element is not visible when clicked' do
@ -449,7 +449,7 @@ describe Capybara::Session do
begin
subject.visit('/')
subject.execute_script "document.getElementById('foo').style.display = 'none'"
lambda { subject.click_link "Click Me" }.should raise_error(
expect { subject.click_link "Click Me" }.to raise_error(
Capybara::Webkit::ClickFailed,
/\[@id='foo'\].*visible/
)
@ -460,7 +460,7 @@ describe Capybara::Session do
it 'raises an error if an element is not in the viewport when clicked' do
subject.visit('/')
lambda { subject.click_link "Click Me" }.should raise_error(Capybara::Webkit::ClickFailed)
expect { subject.click_link "Click Me" }.to raise_error(Capybara::Webkit::ClickFailed)
end
context "with wait time of 1 second" do
@ -479,7 +479,7 @@ describe Capybara::Session do
}, 400);
JS
lambda { subject.click_link "Click Me" }.should_not raise_error
expect { subject.click_link "Click Me" }.not_to raise_error
end
end
end
@ -538,7 +538,7 @@ describe Capybara::Session do
session.attach_file 'File', file.path
session.click_on 'Go'
session.should have_text('Hello')
expect(session).to have_text('Hello')
end
end
end

View File

@ -107,7 +107,7 @@ describe Capybara::Webkit, 'compatibility with selenium' do
end
def compare_for_drivers(first, second, &block)
for_driver(first, &block).should == for_driver(second, &block)
expect(for_driver(first, &block)).to eq for_driver(second, &block)
end
def for_driver(name, &block)

View File

@ -16,7 +16,7 @@ describe Capybara::Webkit::Connection do
write_io.close
webkit_pid = read_io.read.to_i
webkit_pid.should be > 1
expect(webkit_pid).to be > 1
read_io.close
Process.kill(9, fork_pid)
@ -59,14 +59,14 @@ describe Capybara::Webkit::Connection do
socket.puts 1
socket.puts url.to_s.bytesize
socket.print url
socket.gets.should eq "ok\n"
socket.gets.should eq "0\n"
expect(socket.gets).to eq "ok\n"
expect(socket.gets).to eq "0\n"
socket.puts "Body"
socket.puts 0
socket.gets.should eq "ok\n"
expect(socket.gets).to eq "ok\n"
response_length = socket.gets.to_i
response = socket.read(response_length)
response.should include("Hey there")
expect(response).to include("Hey there")
end
it "forwards stderr to the given IO object" do
@ -86,27 +86,27 @@ describe Capybara::Webkit::Connection do
end
it "does not forward stderr to nil" do
IO.should_not_receive(:copy_stream)
expect(IO).not_to receive(:copy_stream)
start_server(stderr: nil)
end
it "prints a deprecation warning if the stdout option is used" do
Capybara::Webkit::Server.any_instance.should_receive(:warn)
expect_any_instance_of(Capybara::Webkit::Server).to receive(:warn)
start_server(stdout: nil)
end
it "does not forward stdout to nil if the stdout option is used" do
Capybara::Webkit::Server.any_instance.stub(:warn)
IO.should_not_receive(:copy_stream)
allow_any_instance_of(Capybara::Webkit::Server).to receive(:warn)
expect(IO).not_to receive(:copy_stream)
start_server(stdout: nil)
end
it "returns the server port" do
start_server.port.should be_between 0x400, 0xffff
expect(start_server.port).to be_between 0x400, 0xffff
end
it "chooses a new port number for a new connection" do
start_server.port.should_not == start_server.port
expect(start_server.port).not_to eq start_server.port
end
before(:all) do

View File

@ -1,5 +1,4 @@
require 'rspec'
require 'rspec/autorun'
require 'rbconfig'
require 'capybara'
@ -48,12 +47,20 @@ RSpec.configure do |c|
require 'capybara_webkit_builder'
c.filter_run_excluding :skip_on_qt4 => !(%x(#{CapybaraWebkitBuilder.qmake_bin} -v).match(/Using Qt version 4/)).nil?
# We can't support outerWidth and outerHeight without a visible window.
# We can't support outerWidth and outerHeight without a visible window. Only affects Capybara < 2.12.0
# We focus the next window instead of failing when closing windows.
# Accessing unattached nodes is allowed when reload is disabled - Legacy behavior
# Node#send_keys does not support modifiers and only supports a subset of special keys
c.filter_run_excluding :full_description => lambda { |description, metadata|
(description !~ /Capybara::Session webkit node #send_keys should send a string of keys to an element/) && (
description =~ /Capybara::Session webkit Capybara::Window #(size|resize_to|maximize|close.*no_such_window_error|send_keys)/ ||
description =~ /Capybara::Session webkit node #send_keys/
description =~ /Capybara::Session webkit node #send_keys/ ||
description =~ /Capybara::Session webkit node #reload without automatic reload should not automatically reload/ ||
if Gem::Version.new(Capybara::VERSION) < Gem::Version.new("2.12.0")
description =~ /Capybara::Session webkit Capybara::Window\s*#(size|resize_to|maximize|close.*no_such_window_error|send_keys)/ ||
description =~ /Capybara::Session webkit node\s*#set should allow me to change the contents of a contenteditable elements child/
else
description =~ /Capybara::Session webkit Capybara::Window\s*#close.*no_such_window_error/
end
)
}
end

View File

@ -14,11 +14,11 @@ RSpec::Matchers.define :include_response do |expected_response|
found_response
end
failure_message_for_should do |actual|
send(respond_to?(:failure_message) ? :failure_message : :failure_message_for_should) do |actual|
"expected #{response} to include #{expected_response}"
end
failure_message_for_should_not do |actual|
send(respond_to?(:failure_message_when_negated) ? :failure_message_when_negated : :failure_message_for_should_not) do |actual|
"expected #{response} to not include #{expected_response}"
end
end