capybara 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,14 +1,37 @@
1
- # master
1
+ # Version 2.0.2
2
+
3
+ Release date: 2012-12-31
4
+
5
+ ### Changed
6
+
7
+ * Capybara no longer uses thin as a server if it is available, due to thread
8
+ safety issues. Now Capybara always defaults to WEBrick. [Jonas Nicklas]
9
+
10
+ ### Fixed
11
+
12
+ * Suppress several warnings [Kouhei Sutou]
13
+ * Fix default host becoming nil [Brian Cardarella]
14
+ * Fix regression in 2.0.1 which caused node comparisons with non node objects
15
+ to throw an exception [Kouhei Sotou]
16
+ * A few changes to the specs, only relevant to driver authors [Jonas Nicklas]
17
+ * Encoding error under JRuby [Piotr Krawiec]
18
+ * Ruby 2 encoding fix [Murahashi Sanemat Kenichi]
19
+ * Catch correct exception on server timeout [Jonathan del Strother]
20
+
21
+ # Version 2.0.1
22
+
23
+ Release date: 2012-12-21
2
24
 
3
25
  ### Changed
4
26
 
5
27
  * Move the RackTest driver override with the `:respect_data_method` option
6
28
  enabled from capybara/rspec to capybara/rails, so that it is enabled in
7
29
  Rails projects that don't use RSpec. [Carlos Antonio da Silva]
8
- * Source is now an alias for `body`. RackTest no longer returns modifications
9
- to `body`. This basically codifies the behaviour which we've had for a while
10
- anyway, and should have minimal impact for end users. It is important to
11
- driver authors though. [Jonas Nicklas]
30
+ * `source` is now an alias for `html`. RackTest no longer returns modifications
31
+ to `html`. This basically codifies the behaviour which we've had for a while
32
+ anyway, and should have minimal impact for end users. For driver authors, it
33
+ means that they only have to implement `html`, and not `source`. [Jonas
34
+ Nicklas]
12
35
 
13
36
  ### Fixed
14
37
 
@@ -131,6 +154,14 @@ Release date: 2012-11-05
131
154
  * `:count => 0` now works as expected [Jarl Friis]
132
155
  * Fixed race conditions on negative assertions when removing nodes [Jonas Nicklas]
133
156
 
157
+ # Version 1.1.4
158
+
159
+ Release date: 2012-11-28
160
+
161
+ ### Fixed
162
+
163
+ * Fix more race conditions on negative assertions. [Jonas Nicklas]
164
+
134
165
  # Version 1.1.3
135
166
 
136
167
  Release date: 2012-10-30
data/README.md CHANGED
@@ -827,7 +827,7 @@ additional info about how the underlying driver can be configured.
827
827
  since Capybara's Ajax timing uses the system time, resulting in Capybara
828
828
  never timing out and just hanging when a failure occurs. It's still possible to
829
829
  use gems which allow you to travel in time, rather than freeze time.
830
- One such gem is [Timecop](http://github.com/jtrupiano/timecop).
830
+ One such gem is [Timecop](http://github.com/travisjeffery/timecop).
831
831
 
832
832
  * When using Rack::Test, beware if attempting to visit absolute URLs. For
833
833
  example, a session might not be shared between visits to `posts_path`
@@ -12,9 +12,7 @@ module Capybara
12
12
  class FileNotFound < CapybaraError; end
13
13
  class UnselectNotAllowed < CapybaraError; end
14
14
  class NotSupportedByDriverError < CapybaraError; end
15
- class TimeoutError < CapybaraError; end
16
- class LocateHiddenElementError < CapybaraError; end
17
- class InfiniteRedirectError < TimeoutError; end
15
+ class InfiniteRedirectError < CapybaraError; end
18
16
 
19
17
  class << self
20
18
  attr_accessor :asset_root, :app_host, :run_server, :default_host, :always_include_port
@@ -175,14 +173,8 @@ module Capybara
175
173
  # @param [Fixnum] port The port to run the application on
176
174
  #
177
175
  def run_default_server(app, port)
178
- begin
179
- require 'rack/handler/thin'
180
- Thin::Logging.silent = true
181
- Rack::Handler::Thin.run(app, :Port => port)
182
- rescue LoadError
183
- require 'rack/handler/webrick'
184
- Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
185
- end
176
+ require 'rack/handler/webrick'
177
+ Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
186
178
  end
187
179
 
188
180
  ##
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module Capybara
2
4
  module Helpers
3
5
  class << self
@@ -31,6 +31,7 @@ module Capybara
31
31
  def initialize(session, base)
32
32
  @session = session
33
33
  @base = base
34
+ @unsynchronized = false
34
35
  end
35
36
 
36
37
  # overridden in subclasses, e.g. Capybara::Node::Element
@@ -421,15 +421,9 @@ module Capybara
421
421
  ##
422
422
  #
423
423
  # Checks if the page or current node has a table with the given id
424
- # or caption.
424
+ # or caption:
425
425
  #
426
- # If the options :rows is given, it will check that the table contains
427
- # the rows and columns given:
428
- #
429
- # page.has_table?('People', :rows => [['Jonas', '24'], ['Peter', '32']])
430
- #
431
- # Note that this option is quite strict, the order needs to be correct
432
- # and the text needs to match exactly.
426
+ # page.has_table?('People')
433
427
  #
434
428
  # @param [String] locator The id or caption of a table
435
429
  # @return [Boolean] Whether it exist
@@ -451,7 +445,7 @@ module Capybara
451
445
  end
452
446
 
453
447
  def ==(other)
454
- self.eql?(other) or base == other.base
448
+ self.eql?(other) or (other.respond_to?(:base) and base == other.base)
455
449
  end
456
450
 
457
451
  private
@@ -94,7 +94,7 @@ protected
94
94
 
95
95
  def build_rack_mock_session
96
96
  reset_host! unless current_host
97
- Rack::MockSession.new(app, URI.parse(current_host).host)
97
+ Rack::MockSession.new(app, current_host)
98
98
  end
99
99
 
100
100
  def request_path
@@ -21,6 +21,7 @@ module Capybara
21
21
  @name = name
22
22
  @custom_filters = {}
23
23
  @match = nil
24
+ @label = nil
24
25
  @failure_message = nil
25
26
  instance_eval(&block)
26
27
  end
@@ -76,7 +76,7 @@ module Capybara
76
76
 
77
77
  Timeout.timeout(60) { @server_thread.join(0.1) until responsive? }
78
78
  end
79
- rescue TimeoutError
79
+ rescue Timeout::Error
80
80
  raise "Rack application timed out during boot"
81
81
  else
82
82
  self
@@ -51,7 +51,10 @@ module Capybara
51
51
  @app = app
52
52
  if Capybara.run_server and @app and driver.needs_server?
53
53
  @server = Capybara::Server.new(@app).boot
54
+ else
55
+ @server = nil
54
56
  end
57
+ @touched = false
55
58
  end
56
59
 
57
60
  def driver
@@ -79,15 +79,15 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
79
79
  should_be_on 0, "/landed"
80
80
  end
81
81
 
82
- it "is affected by pushState", :requires => [:js] do
83
- @session.visit("/with_js")
84
- @session.execute_script("window.history.pushState({}, '', '/pushed')")
85
- @session.current_path.should == "/pushed"
86
- end
82
+ it "is affected by pushState", :requires => [:js] do
83
+ @session.visit("/with_js")
84
+ @session.execute_script("window.history.pushState({}, '', '/pushed')")
85
+ @session.current_path.should == "/pushed"
86
+ end
87
87
 
88
- it "is affected by replaceState", :requires => [:js] do
89
- @session.visit("/with_js")
90
- @session.execute_script("window.history.replaceState({}, '', '/replaced')")
91
- @session.current_path.should == "/replaced"
92
- end
88
+ it "is affected by replaceState", :requires => [:js] do
89
+ @session.visit("/with_js")
90
+ @session.execute_script("window.history.replaceState({}, '', '/replaced')")
91
+ @session.current_path.should == "/replaced"
92
+ end
93
93
  end
@@ -114,6 +114,10 @@ Capybara::SpecHelper.spec "node" do
114
114
  (@session.find('//h1') === @session.find('//h1')).should be_true
115
115
  (@session.find('//h1').eql? @session.find('//h1')).should be_false
116
116
  end
117
+
118
+ it "returns false for unrelated object" do
119
+ (@session.find('//h1') == "Not Capybara::Node::Base").should be_false
120
+ end
117
121
  end
118
122
 
119
123
  describe "#trigger", :requires => [:js, :trigger] do
@@ -1,3 +1,4 @@
1
+ #coding: US-ASCII
1
2
  Capybara::SpecHelper.spec "#save_screenshot" do
2
3
  let(:image_path) { File.join(Dir.tmpdir, 'capybara-screenshot.png') }
3
4
 
@@ -9,24 +9,25 @@ module Capybara
9
9
  module SpecHelper
10
10
  class << self
11
11
  def configure(config)
12
- filter = lambda do |requires, metadata|
13
- if requires and metadata[:skip]
14
- requires.any? do |require|
15
- metadata[:skip].include?(require)
16
- end
17
- else
18
- false
19
- end
20
- end
21
- config.filter_run_excluding :requires => filter
22
- config.before do
23
- Capybara.app = TestApp
12
+ config.filter_run_excluding :requires => method(:filter).to_proc
13
+ config.before { Capybara::SpecHelper.reset! }
14
+ config.after { Capybara::SpecHelper.reset! }
15
+ end
24
16
 
25
- Capybara.configure do |config|
26
- config.default_selector = :xpath
27
- end
17
+ def reset!
18
+ Capybara.app = TestApp
19
+ Capybara.app_host = nil
20
+ Capybara.default_selector = :xpath
21
+ Capybara.default_wait_time = 1
22
+ end
28
23
 
29
- Capybara.default_wait_time = 1
24
+ def filter(requires, metadata)
25
+ if requires and metadata[:skip]
26
+ requires.any? do |require|
27
+ metadata[:skip].include?(require)
28
+ end
29
+ else
30
+ false
30
31
  end
31
32
  end
32
33
 
@@ -45,8 +46,8 @@ module Capybara
45
46
  after do
46
47
  @session.reset_session!
47
48
  end
48
- specs.each do |name, options, block|
49
- describe name, options do
49
+ specs.each do |spec_name, spec_options, block|
50
+ describe spec_name, spec_options do
50
51
  class_eval(&block)
51
52
  end
52
53
  end
@@ -77,8 +78,4 @@ module Capybara
77
78
  end
78
79
  end
79
80
 
80
- RSpec.configure do |config|
81
- Capybara::SpecHelper.configure(config)
82
- end
83
-
84
81
  Dir[File.dirname(__FILE__)+'/session/*'].each { |group| require group }
@@ -1,3 +1,3 @@
1
1
  module Capybara
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
@@ -229,41 +229,25 @@ describe Capybara::DSL do
229
229
  end
230
230
 
231
231
  it "should be possible to include it in another class" do
232
- klass = Class.new do
233
- include Capybara::DSL
234
- end
235
- foo = klass.new
236
- foo.visit('/with_html')
237
- foo.click_link('ullamco')
238
- foo.body.should include('Another World')
232
+ @session.visit('/with_html')
233
+ @session.click_link('ullamco')
234
+ @session.body.should include('Another World')
239
235
  end
240
236
 
241
237
  it "should provide a 'page' shortcut for more expressive tests" do
242
- klass = Class.new do
243
- include Capybara::DSL
244
- end
245
- foo = klass.new
246
- foo.page.visit('/with_html')
247
- foo.page.click_link('ullamco')
248
- foo.page.body.should include('Another World')
238
+ @session.page.visit('/with_html')
239
+ @session.page.click_link('ullamco')
240
+ @session.page.body.should include('Another World')
249
241
  end
250
242
 
251
243
  it "should provide an 'using_session' shortcut" do
252
- klass = Class.new do
253
- include Capybara::DSL
254
- end
255
244
  Capybara.should_receive(:using_session).with(:name)
256
- foo = klass.new
257
- foo.using_session(:name)
245
+ @session.using_session(:name)
258
246
  end
259
247
 
260
248
  it "should provide a 'using_wait_time' shortcut" do
261
- klass = Class.new do
262
- include Capybara::DSL
263
- end
264
249
  Capybara.should_receive(:using_wait_time).with(6)
265
- foo = klass.new
266
- foo.using_wait_time(6)
250
+ @session.using_wait_time(6)
267
251
  end
268
252
  end
269
253
  end
@@ -1 +1,5 @@
1
1
  require 'capybara/spec/spec_helper'
2
+
3
+ RSpec.configure do |config|
4
+ Capybara::SpecHelper.configure(config)
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-21 00:00:00.000000000 Z
12
+ date: 2012-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri