capybara-webkit 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,5 +7,5 @@ describe Capybara::Webkit::JsonError do
7
7
 
8
8
  it { should be_an_instance_of Capybara::Webkit::ClickFailed }
9
9
 
10
- its(:message) { should == 'Error clicking this element' }
10
+ it { expect(subject.message).to eq 'Error clicking this element' }
11
11
  end
@@ -50,7 +50,7 @@ describe Capybara::Session do
50
50
  it "waits for a request to load" do
51
51
  subject.visit("/")
52
52
  subject.find_button("Submit").click
53
- subject.should have_content("Goodbye");
53
+ expect(subject).to have_content("Goodbye");
54
54
  end
55
55
  end
56
56
 
@@ -76,12 +76,12 @@ describe Capybara::Session do
76
76
  end
77
77
 
78
78
  it "inspects nodes" do
79
- subject.all(:xpath, "//strong").first.inspect.should include("strong")
79
+ expect(subject.all(:xpath, "//strong").first.inspect).to include("strong")
80
80
  end
81
81
 
82
82
  it "can read utf8 string" do
83
83
  utf8str = subject.all(:xpath, "//span").first.text
84
- utf8str.should eq('UTF8文字列')
84
+ expect(utf8str).to eq('UTF8文字列')
85
85
  end
86
86
 
87
87
  it "can click utf8 string" do
@@ -91,7 +91,7 @@ describe Capybara::Session do
91
91
  it "raises an ElementNotFound error when the selector scope is no longer valid" do
92
92
  subject.within('//body') do
93
93
  subject.click_link 'Link'
94
- lambda { subject.find('//strong') }.should raise_error(Capybara::ElementNotFound)
94
+ expect { subject.find('//strong') }.to raise_error(Capybara::ElementNotFound)
95
95
  end
96
96
  end
97
97
  end
@@ -119,26 +119,26 @@ describe Capybara::Session do
119
119
 
120
120
  it "should get status code" do
121
121
  subject.visit '/'
122
- subject.status_code.should eq 200
122
+ expect(subject.status_code).to eq 200
123
123
  end
124
124
 
125
125
  it "should reset status code" do
126
126
  subject.visit '/'
127
- subject.status_code.should eq 200
127
+ expect(subject.status_code).to eq 200
128
128
  subject.reset!
129
- subject.status_code.should eq 0
129
+ expect(subject.status_code).to eq 0
130
130
  end
131
131
 
132
132
  it "should get response headers" do
133
133
  subject.visit '/'
134
- subject.response_headers['X-Capybara'].should eq 'WebKit'
134
+ expect(subject.response_headers['X-Capybara']).to eq 'WebKit'
135
135
  end
136
136
 
137
137
  it "should reset response headers" do
138
138
  subject.visit '/'
139
- subject.response_headers['X-Capybara'].should eq 'WebKit'
139
+ expect(subject.response_headers['X-Capybara']).to eq 'WebKit'
140
140
  subject.reset!
141
- subject.response_headers['X-Capybara'].should eq nil
141
+ expect(subject.response_headers['X-Capybara']).to eq nil
142
142
  end
143
143
  end
144
144
 
@@ -188,7 +188,7 @@ describe Capybara::Session do
188
188
  subject.visit("/")
189
189
  subject.click_link('Click Me!')
190
190
  Capybara.using_wait_time(5) do
191
- subject.should have_content("finished")
191
+ expect(subject).to have_content("finished")
192
192
  end
193
193
  end
194
194
  end
@@ -235,7 +235,7 @@ describe Capybara::Session do
235
235
  subject.fill_in('password', with: 'temp4now')
236
236
  subject.click_button('Submit')
237
237
  subject.visit('/other')
238
- subject.should have_content('admin')
238
+ expect(subject).to have_content('admin')
239
239
  end
240
240
  end
241
241
 
@@ -299,7 +299,7 @@ describe Capybara::Session do
299
299
  subject.within_frame 'a_frame' do
300
300
  subject.within_frame 'b_frame' do
301
301
  subject.click_button 'B Button'
302
- subject.should have_content('Page C')
302
+ expect(subject).to have_content('Page C')
303
303
  end
304
304
  end
305
305
  end
@@ -319,9 +319,9 @@ describe Capybara::Session do
319
319
 
320
320
  subject.within_frame('a_frame') do
321
321
  subject.within_frame('b_frame') do
322
- lambda {
322
+ expect {
323
323
  subject.click_button 'B Button'
324
- }.should raise_error(Capybara::Webkit::ClickFailed)
324
+ }.to raise_error(Capybara::Webkit::ClickFailed)
325
325
  end
326
326
  end
327
327
  end
@@ -379,29 +379,29 @@ describe Capybara::Session do
379
379
  it 'clicks in the center of an element' do
380
380
  subject.visit('/')
381
381
  subject.find(:css, '#one').click
382
- subject.find(:css, '#one')['data-click-x'].should eq '199'
383
- subject.find(:css, '#one')['data-click-y'].should eq '199'
382
+ expect(subject.find(:css, '#one')['data-click-x']).to eq '199'
383
+ expect(subject.find(:css, '#one')['data-click-y']).to eq '199'
384
384
  end
385
385
 
386
386
  it 'clicks in the center of the viewable area of an element' do
387
387
  subject.visit('/')
388
388
  subject.driver.resize_window(200, 200)
389
389
  subject.find(:css, '#one').click
390
- subject.find(:css, '#one')['data-click-x'].should eq '149'
391
- subject.find(:css, '#one')['data-click-y'].should eq '99'
390
+ expect(subject.find(:css, '#one')['data-click-x']).to eq '149'
391
+ expect(subject.find(:css, '#one')['data-click-y']).to eq '99'
392
392
  end
393
393
 
394
394
  it 'does not raise an error when an anchor contains empty nodes' do
395
395
  subject.visit('/')
396
- lambda { subject.click_link('Some link') }.should_not raise_error
396
+ expect { subject.click_link('Some link') }.not_to raise_error
397
397
  end
398
398
 
399
399
  it 'scrolls an element into view when clicked' do
400
400
  subject.visit('/')
401
401
  subject.driver.resize_window(200, 200)
402
402
  subject.find(:css, '#two').click
403
- subject.find(:css, '#two')['data-click-x'].should_not be_nil
404
- subject.find(:css, '#two')['data-click-y'].should_not be_nil
403
+ expect(subject.find(:css, '#two')['data-click-x']).not_to be_nil
404
+ expect(subject.find(:css, '#two')['data-click-y']).not_to be_nil
405
405
  end
406
406
 
407
407
  it 'raises an error if an element is obscured when clicked' do
@@ -417,11 +417,11 @@ describe Capybara::Session do
417
417
  expect {
418
418
  subject.find(:css, '#one').click
419
419
  }.to raise_error(Capybara::Webkit::ClickFailed) { |exception|
420
- exception.message.should =~ %r{Failed.*\[@id='one'\].*overlapping.*\[@id='two'\].*at position}
420
+ expect(exception.message).to match %r{Failed.*\[@id='one'\].*overlapping.*\[@id='two'\].*at position}
421
421
  screenshot_pattern = %r{A screenshot of the page at the time of the failure has been written to (.*)}
422
- exception.message.should =~ screenshot_pattern
422
+ expect(exception.message).to match screenshot_pattern
423
423
  file = exception.message.match(screenshot_pattern)[1]
424
- File.exist?(file).should be_true
424
+ expect(File.exist?(file)).to be true
425
425
  }
426
426
  end
427
427
 
@@ -438,9 +438,9 @@ describe Capybara::Session do
438
438
  document.body.appendChild(div);
439
439
  JS
440
440
 
441
- lambda {
441
+ expect {
442
442
  subject.check('bar')
443
- }.should raise_error(Capybara::Webkit::ClickFailed)
443
+ }.to raise_error(Capybara::Webkit::ClickFailed)
444
444
  end
445
445
 
446
446
  it 'raises an error if an element is not visible when clicked' do
@@ -449,7 +449,7 @@ describe Capybara::Session do
449
449
  begin
450
450
  subject.visit('/')
451
451
  subject.execute_script "document.getElementById('foo').style.display = 'none'"
452
- lambda { subject.click_link "Click Me" }.should raise_error(
452
+ expect { subject.click_link "Click Me" }.to raise_error(
453
453
  Capybara::Webkit::ClickFailed,
454
454
  /\[@id='foo'\].*visible/
455
455
  )
@@ -460,7 +460,7 @@ describe Capybara::Session do
460
460
 
461
461
  it 'raises an error if an element is not in the viewport when clicked' do
462
462
  subject.visit('/')
463
- lambda { subject.click_link "Click Me" }.should raise_error(Capybara::Webkit::ClickFailed)
463
+ expect { subject.click_link "Click Me" }.to raise_error(Capybara::Webkit::ClickFailed)
464
464
  end
465
465
 
466
466
  context "with wait time of 1 second" do
@@ -479,7 +479,7 @@ describe Capybara::Session do
479
479
  }, 400);
480
480
  JS
481
481
 
482
- lambda { subject.click_link "Click Me" }.should_not raise_error
482
+ expect { subject.click_link "Click Me" }.not_to raise_error
483
483
  end
484
484
  end
485
485
  end
@@ -538,7 +538,7 @@ describe Capybara::Session do
538
538
  session.attach_file 'File', file.path
539
539
  session.click_on 'Go'
540
540
 
541
- session.should have_text('Hello')
541
+ expect(session).to have_text('Hello')
542
542
  end
543
543
  end
544
544
  end
@@ -107,7 +107,7 @@ describe Capybara::Webkit, 'compatibility with selenium' do
107
107
  end
108
108
 
109
109
  def compare_for_drivers(first, second, &block)
110
- for_driver(first, &block).should == for_driver(second, &block)
110
+ expect(for_driver(first, &block)).to eq for_driver(second, &block)
111
111
  end
112
112
 
113
113
  def for_driver(name, &block)
@@ -16,7 +16,7 @@ describe Capybara::Webkit::Connection do
16
16
  write_io.close
17
17
 
18
18
  webkit_pid = read_io.read.to_i
19
- webkit_pid.should be > 1
19
+ expect(webkit_pid).to be > 1
20
20
  read_io.close
21
21
  Process.kill(9, fork_pid)
22
22
 
@@ -59,14 +59,14 @@ describe Capybara::Webkit::Connection do
59
59
  socket.puts 1
60
60
  socket.puts url.to_s.bytesize
61
61
  socket.print url
62
- socket.gets.should eq "ok\n"
63
- socket.gets.should eq "0\n"
62
+ expect(socket.gets).to eq "ok\n"
63
+ expect(socket.gets).to eq "0\n"
64
64
  socket.puts "Body"
65
65
  socket.puts 0
66
- socket.gets.should eq "ok\n"
66
+ expect(socket.gets).to eq "ok\n"
67
67
  response_length = socket.gets.to_i
68
68
  response = socket.read(response_length)
69
- response.should include("Hey there")
69
+ expect(response).to include("Hey there")
70
70
  end
71
71
 
72
72
  it "forwards stderr to the given IO object" do
@@ -86,27 +86,27 @@ describe Capybara::Webkit::Connection do
86
86
  end
87
87
 
88
88
  it "does not forward stderr to nil" do
89
- IO.should_not_receive(:copy_stream)
89
+ expect(IO).not_to receive(:copy_stream)
90
90
  start_server(stderr: nil)
91
91
  end
92
92
 
93
93
  it "prints a deprecation warning if the stdout option is used" do
94
- Capybara::Webkit::Server.any_instance.should_receive(:warn)
94
+ expect_any_instance_of(Capybara::Webkit::Server).to receive(:warn)
95
95
  start_server(stdout: nil)
96
96
  end
97
97
 
98
98
  it "does not forward stdout to nil if the stdout option is used" do
99
- Capybara::Webkit::Server.any_instance.stub(:warn)
100
- IO.should_not_receive(:copy_stream)
99
+ allow_any_instance_of(Capybara::Webkit::Server).to receive(:warn)
100
+ expect(IO).not_to receive(:copy_stream)
101
101
  start_server(stdout: nil)
102
102
  end
103
103
 
104
104
  it "returns the server port" do
105
- start_server.port.should be_between 0x400, 0xffff
105
+ expect(start_server.port).to be_between 0x400, 0xffff
106
106
  end
107
107
 
108
108
  it "chooses a new port number for a new connection" do
109
- start_server.port.should_not == start_server.port
109
+ expect(start_server.port).not_to eq start_server.port
110
110
  end
111
111
 
112
112
  before(:all) do
@@ -1,5 +1,4 @@
1
1
  require 'rspec'
2
- require 'rspec/autorun'
3
2
  require 'rbconfig'
4
3
  require 'capybara'
5
4
 
@@ -48,12 +47,20 @@ RSpec.configure do |c|
48
47
  require 'capybara_webkit_builder'
49
48
  c.filter_run_excluding :skip_on_qt4 => !(%x(#{CapybaraWebkitBuilder.qmake_bin} -v).match(/Using Qt version 4/)).nil?
50
49
 
51
- # We can't support outerWidth and outerHeight without a visible window.
50
+ # We can't support outerWidth and outerHeight without a visible window. Only affects Capybara < 2.12.0
52
51
  # We focus the next window instead of failing when closing windows.
52
+ # Accessing unattached nodes is allowed when reload is disabled - Legacy behavior
53
+ # Node#send_keys does not support modifiers and only supports a subset of special keys
53
54
  c.filter_run_excluding :full_description => lambda { |description, metadata|
54
55
  (description !~ /Capybara::Session webkit node #send_keys should send a string of keys to an element/) && (
55
- description =~ /Capybara::Session webkit Capybara::Window #(size|resize_to|maximize|close.*no_such_window_error|send_keys)/ ||
56
- description =~ /Capybara::Session webkit node #send_keys/
56
+ description =~ /Capybara::Session webkit node #send_keys/ ||
57
+ description =~ /Capybara::Session webkit node #reload without automatic reload should not automatically reload/ ||
58
+ if Gem::Version.new(Capybara::VERSION) < Gem::Version.new("2.12.0")
59
+ description =~ /Capybara::Session webkit Capybara::Window\s*#(size|resize_to|maximize|close.*no_such_window_error|send_keys)/ ||
60
+ description =~ /Capybara::Session webkit node\s*#set should allow me to change the contents of a contenteditable elements child/
61
+ else
62
+ description =~ /Capybara::Session webkit Capybara::Window\s*#close.*no_such_window_error/
63
+ end
57
64
  )
58
65
  }
59
66
  end
@@ -21,6 +21,7 @@ module AppRunner
21
21
  end
22
22
 
23
23
  self.browser = $webkit_browser
24
+ self.browser.reset!
24
25
 
25
26
  self.configuration = Capybara::Webkit::Configuration.new
26
27
  end
@@ -14,11 +14,11 @@ RSpec::Matchers.define :include_response do |expected_response|
14
14
  found_response
15
15
  end
16
16
 
17
- failure_message_for_should do |actual|
17
+ send(respond_to?(:failure_message) ? :failure_message : :failure_message_for_should) do |actual|
18
18
  "expected #{response} to include #{expected_response}"
19
19
  end
20
20
 
21
- failure_message_for_should_not do |actual|
21
+ send(respond_to?(:failure_message_when_negated) ? :failure_message_when_negated : :failure_message_for_should_not) do |actual|
22
22
  "expected #{response} to not include #{expected_response}"
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-webkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-01-13 00:00:00.000000000 Z
16
+ date: 2017-03-20 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: capybara
@@ -55,14 +55,14 @@ dependencies:
55
55
  requirements:
56
56
  - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: '2.14'
58
+ version: '3.5'
59
59
  type: :development
60
60
  prerelease: false
61
61
  version_requirements: !ruby/object:Gem::Requirement
62
62
  requirements:
63
63
  - - "~>"
64
64
  - !ruby/object:Gem::Version
65
- version: '2.14'
65
+ version: '3.5'
66
66
  - !ruby/object:Gem::Dependency
67
67
  name: sinatra
68
68
  requirement: !ruby/object:Gem::Requirement
@@ -155,7 +155,7 @@ files:
155
155
  - bin/Info.plist
156
156
  - capybara-webkit.gemspec
157
157
  - extconf.rb
158
- - gemfiles/2.11.gemfile
158
+ - gemfiles/2.12.gemfile
159
159
  - gemfiles/2.7.gemfile
160
160
  - gemfiles/master.gemfile
161
161
  - lib/capybara-webkit.rb
@@ -385,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
385
  requirements:
386
386
  - Qt >= 4.8
387
387
  rubyforge_project:
388
- rubygems_version: 2.5.1
388
+ rubygems_version: 2.6.8
389
389
  signing_key:
390
390
  specification_version: 4
391
391
  summary: Headless Webkit driver for Capybara