capybara-mechanize 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,23 @@ Thanks to [Pinkelstar](http://www.pinkelstar.com) for giving me the time and the
19
19
 
20
20
  require 'capybara/mechanize'
21
21
 
22
+ ### Further configuration of Mechanize
23
+
24
+ Upon instantiation of a `Driver`, you can configure [`mechanize` agent
25
+ options](http://www.rubydoc.info/gems/mechanize/Mechanize) in a `#configure` block:
26
+
27
+ ```ruby
28
+ Capybara.register_driver :mechanize do |app|
29
+ driver = Capybara::Mechanize::Driver.new(app)
30
+ driver.configure do |agent|
31
+ # Configure other Mechanize options here.
32
+ agent.log = Logger.new "mech.log"
33
+ agent.user_agent_alias = 'Mac Safari'
34
+ end
35
+ driver
36
+ end
37
+ ```
38
+
22
39
  ### Usage with Cucumber and tags
23
40
 
24
41
  A @mechanize tag is added to your hooks when you add the following line to your env.rb
@@ -11,9 +11,12 @@ class Capybara::Mechanize::Driver < Capybara::RackTest::Driver
11
11
  def remote?(url)
12
12
  browser.remote?(url)
13
13
  end
14
-
14
+
15
+ def configure(&block)
16
+ yield(browser.agent) if block_given?
17
+ end
18
+
15
19
  def browser
16
20
  @browser ||= Capybara::Mechanize::Browser.new(self)
17
21
  end
18
-
19
22
  end
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Mechanize
3
- VERSION = '1.4.0'
3
+ VERSION = '1.4.1'
4
4
  end
5
5
  end
@@ -3,6 +3,15 @@ require 'spec_helper'
3
3
  describe Capybara::Mechanize::Driver, 'local' do
4
4
  let(:driver) { Capybara::Mechanize::Driver.new(ExtendedTestApp) }
5
5
 
6
+ describe "#configure" do
7
+ it "allows extended configuration of the agent" do
8
+ ::Mechanize.any_instance.should_receive(:foo=).with("test")
9
+ driver.configure do |agent|
10
+ agent.foo = "test"
11
+ end
12
+ end
13
+ end
14
+
6
15
  describe ':headers option' do
7
16
  it 'should always set headers' do
8
17
  driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-mechanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
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: 2014-10-14 00:00:00.000000000 Z
12
+ date: 2016-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  segments:
84
84
  - 0
85
- hash: 1895227021431628826
85
+ hash: 304686151432439046
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements: