frameworks-capybara 0.3.0.rc5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,11 @@ module Cucumber
7
7
  @project_name = ENV['PROJECT_NAME'] || ''
8
8
  unless @project_name.empty? then @project_name += ' - ' end
9
9
 
10
- @step_count = get_step_count(features)
10
+ if Cucumber::Ast::Feature.method_defined?(:step_count)
11
+ @step_count = features.step_count # cucumber >=1.3.0
12
+ else
13
+ @step_count = get_step_count(features) # cucumber <1.3.0
14
+ end
11
15
 
12
16
  # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
13
17
  @builder.declare!(
@@ -4,9 +4,9 @@ require 'mechanize'
4
4
  #we check after response and it may be the last response we need it to clear here.
5
5
  class Mechanize::CookieJar
6
6
  alias_method :old_add, :add
7
- def add(uri, cookie)
7
+ def add(*args)
8
8
  cleanup
9
- old_add(uri, cookie)
9
+ old_add(*args)
10
10
  end
11
11
  end
12
12
  #This patch may still be required, think it is only not needed now because we don't run
@@ -58,8 +58,17 @@ end
58
58
  =end
59
59
 
60
60
  # This patch prevents Mechanize from raising a Mechanize::ResponseCodeError
61
- # when the HTTP Response Code is 503 or 404. This lets capybara continue the journey.
61
+ # when the HTTP Response Code is in `allowed_error_codes`.
62
+ # https://github.com/tenderlove/mechanize/pull/248
62
63
  class Mechanize::HTTP::Agent
64
+ attr_accessor :allowed_error_codes
65
+
66
+ alias_method :old_initialize, :initialize
67
+ def initialize
68
+ @allowed_error_codes = []
69
+ old_initialize
70
+ end
71
+
63
72
  def fetch uri, method = :get, headers = {}, params = [],
64
73
  referer = current_page, redirects = 0
65
74
  referer_uri = referer ? referer.uri : nil
@@ -156,7 +165,11 @@ class Mechanize::HTTP::Agent
156
165
  referer)
157
166
  else
158
167
  # BEGIN PATCH
159
- if page.code == "503" or page.code == "404"
168
+ if @allowed_error_codes.any? {|code| code.to_s == page.code} then
169
+ if robots && page.is_a?(Mechanize::Page)
170
+ page.parser.noindex? and raise Mechanize::RobotsDisallowedError.new(uri)
171
+ end
172
+
160
173
  page
161
174
  else
162
175
  raise Mechanize::ResponseCodeError.new(page, 'unhandled response')
@@ -24,7 +24,7 @@ class RakeHelpers
24
24
  f = File.open('config/cucumber.yml', 'r')
25
25
  linenum = 0
26
26
  @profiles = {}
27
- f.read.each do |line|
27
+ f.readlines.each do |line|
28
28
  line.scan(/.*?: /) do |match|
29
29
  linenum += 1
30
30
  puts color(linenum.to_s + '. ', :color => :yellow) + color(match.gsub(':',''), :color => :green)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FrameworksCapybara
2
- VERSION = '0.3.0.rc5'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+ require 'rspec/mocks/mock'
3
+ require 'uri'
4
+
5
+ describe Capybara::Mechanize::Browser do
6
+
7
+ RSpec::Mocks::setup(self)
8
+
9
+ it "shouldn't send referer if unknown" do
10
+
11
+ agent = double()
12
+ agent.stub('get' => true)
13
+ agent.should_receive('get').with(
14
+ "http://example.bbc.co.uk/test",
15
+ {},
16
+ nil,
17
+ {}
18
+ )
19
+
20
+ driver = double("Capybara::Mechanize::Driver")
21
+
22
+ browser = Capybara::Mechanize::Browser.new(driver)
23
+ browser.stub('current_url' => "")
24
+ browser.stub('agent' => agent)
25
+
26
+ browser.process_remote_request(:get, 'http://example.bbc.co.uk/test', {}, {})
27
+ end
28
+
29
+ it "should not change behaviour for POST requests" do
30
+
31
+ agent = double()
32
+ agent.stub('post' => true)
33
+ agent.should_receive('post').with("http://example.bbc.co.uk/test")
34
+
35
+ driver = double("Capybara::Mechanize::Driver")
36
+
37
+ browser = Capybara::Mechanize::Browser.new(driver)
38
+ browser.stub('current_url' => "http://example.bbc.co.uk/blah")
39
+ browser.stub('agent' => agent)
40
+
41
+ browser.process_remote_request(:post, 'http://example.bbc.co.uk/test', {}, {})
42
+ end
43
+
44
+ it "should not send referer for requests from HTTPs to HTTP" do
45
+
46
+ agent = double()
47
+ agent.stub('get' => true)
48
+ agent.should_receive('get').with(
49
+ "http://example.bbc.co.uk/test",
50
+ {},
51
+ nil,
52
+ {}
53
+ )
54
+
55
+ driver = double("Capybara::Mechanize::Driver")
56
+
57
+ browser = Capybara::Mechanize::Browser.new(driver)
58
+ browser.stub('current_url' => "https://example.bbc.co.uk/blah")
59
+ browser.stub('agent' => agent)
60
+
61
+ browser.process_remote_request(:get, 'http://example.bbc.co.uk/test', {}, {})
62
+ end
63
+
64
+ it "should send referer for requests from HTTP to HTTPs" do
65
+
66
+ agent = double()
67
+ agent.stub('get' => true)
68
+ agent.should_receive('get').with(
69
+ "https://example.bbc.co.uk/test",
70
+ {},
71
+ "http://example.bbc.co.uk/blah",
72
+ {}
73
+ )
74
+
75
+ driver = double("Capybara::Mechanize::Driver")
76
+
77
+ browser = Capybara::Mechanize::Browser.new(driver)
78
+ browser.stub('current_url' => "http://example.bbc.co.uk/blah")
79
+ browser.stub('agent' => agent)
80
+
81
+ browser.process_remote_request(:get, 'https://example.bbc.co.uk/test', {}, {})
82
+ end
83
+
84
+ it "should send referer for requests from HTTP to HTTP" do
85
+
86
+ agent = double()
87
+ agent.stub('get' => true)
88
+ agent.should_receive('get').with(
89
+ "http://example.bbc.co.uk/test",
90
+ {},
91
+ "http://example.bbc.co.uk/blah",
92
+ {}
93
+ )
94
+
95
+ driver = double("Capybara::Mechanize::Driver")
96
+
97
+ browser = Capybara::Mechanize::Browser.new(driver)
98
+ browser.stub('current_url' => "http://example.bbc.co.uk/blah")
99
+ browser.stub('agent' => agent)
100
+
101
+ browser.process_remote_request(:get, 'http://example.bbc.co.uk/test', {}, {})
102
+ end
103
+
104
+ it "should send referer for requests from HTTPs to HTTPs" do
105
+
106
+ agent = double()
107
+ agent.stub('get' => true)
108
+ agent.should_receive('get').with(
109
+ "https://example.bbc.co.uk/test",
110
+ {},
111
+ "https://example.bbc.co.uk/blah",
112
+ {}
113
+ )
114
+
115
+ driver = double("Capybara::Mechanize::Driver")
116
+
117
+ browser = Capybara::Mechanize::Browser.new(driver)
118
+ browser.stub('current_url' => "https://example.bbc.co.uk/blah")
119
+ browser.stub('agent' => agent)
120
+
121
+ browser.process_remote_request(:get, 'https://example.bbc.co.uk/test', {}, {})
122
+ end
123
+
124
+ end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'securerandom'
2
3
  ##
3
4
  #Monkey Patch
4
5
  #This is required because Capybara has module methods (singletons) which create
@@ -116,7 +117,7 @@ describe CapybaraSetup do
116
117
  before do
117
118
  ENV['BROWSER'] = 'firefox'
118
119
  ENV['FIREFOX_PROFILE'] = 'BBC_INTERNAL'
119
- ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
120
+ ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80/'
120
121
  ENV['PROXY_ON'] = 'false'
121
122
  end
122
123
 
@@ -127,7 +128,7 @@ describe CapybaraSetup do
127
128
  Capybara.current_session.driver.options[:browser].should == :firefox
128
129
  Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
129
130
  Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.type'].should == 1
130
- Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk'
131
+ Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk,*.sandbox.bbc.co.uk'
131
132
  Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.http'].should == 'example.cache.co.uk'
132
133
  Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.http_port'].should == 80
133
134
  Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.ssl'].should == 'example.cache.co.uk'
@@ -216,7 +217,7 @@ describe CapybaraSetup do
216
217
  Capybara.current_session.driver.options[:browser].should == :remote
217
218
  Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
218
219
  Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.type'].should == 1
219
- Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk'
220
+ Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk,*.sandbox.bbc.co.uk'
220
221
  Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.http'].should == 'example.cache.co.uk'
221
222
  Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.http_port'].should == 80
222
223
  Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.ssl'].should == 'example.cache.co.uk'
@@ -448,23 +449,137 @@ describe CapybaraSetup do
448
449
  end
449
450
  end
450
451
 
451
- end
452
+ context "integration tests for update_firefox_profile_with_certificates() method" do
453
+ before do
454
+ def write_random_data(file_path)
455
+ file_data = SecureRandom.hex
456
+ File.open(file_path, "w") { |a_file|
457
+ a_file.write(file_data)
458
+ }
459
+ file_data
460
+ end
461
+
462
+ def compare_file_data(profile_path, file_name, expected_data)
463
+ profile_file = profile_path + File::SEPARATOR + file_name
464
+ actual_data = nil
465
+ File.open(profile_file, "r") { |a_file|
466
+ actual_data = a_file.read
467
+ }
468
+ expected_data.should == actual_data
469
+ end
470
+
471
+ ENV['BROWSER'] = 'firefox'
472
+ ENV['ENVIRONMENT'] = 'test'
473
+ ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
474
+ @cert_dir = Dir.mktmpdir
475
+ @cert8_db = @cert_dir + File::SEPARATOR + 'cert8.db'
476
+ @key3_db = @cert_dir + File::SEPARATOR + 'key3.db'
477
+ @secmod_db = @cert_dir + File::SEPARATOR + 'secmod.db'
478
+ end
452
479
 
480
+ after do
481
+ FileUtils.remove_entry @cert_dir
482
+ end
453
483
 
454
- describe "should allow Webkit driver to be created" do
455
- context "with minimal Webkit driver" do
456
- before do
457
- ENV['BROWSER'] = 'webkit'
484
+ it "should raise an exception if the cert8.db file is missing in the source directory" do
485
+ profile = Selenium::WebDriver::Firefox::Profile.new
486
+
487
+ key3_data = write_random_data(@key3_db)
488
+ secmod_data = write_random_data(@secmod_db)
489
+
490
+ an_exception = nil
491
+ begin
492
+ CapybaraSetup.new.instance_exec(profile, @cert_dir) { |profile, certificate_path|
493
+ update_firefox_profile_with_certificates(profile, certificate_path)
494
+ }
495
+ rescue RuntimeError => e
496
+ an_exception = e
497
+ end
498
+
499
+ an_exception.should_not be_nil
458
500
  end
459
501
 
460
- it "should be initialized correctly" do
461
- Capybara.delete_session
462
- CapybaraSetup.new.driver.should == :webkit
463
- Capybara.current_session.driver.should be_a_kind_of Capybara::Driver::Webkit
502
+ it "should raise an exception if the key3.db file is missing in the source directory" do
503
+ profile = Selenium::WebDriver::Firefox::Profile.new
504
+
505
+ cert8_data = write_random_data(@cert8_db)
506
+ secmod_data = write_random_data(@secmod_db)
507
+
508
+ an_exception = nil
509
+ begin
510
+ CapybaraSetup.new.instance_exec(profile, @cert_dir) { |profile, certificate_path|
511
+ update_firefox_profile_with_certificates(profile, certificate_path)
512
+ }
513
+ rescue RuntimeError => e
514
+ an_exception = e
515
+ end
516
+
517
+ an_exception.should_not be_nil
518
+ end
519
+
520
+ it "should raise an exception if the secmod.db file is missing in the source directory" do
521
+ profile = Selenium::WebDriver::Firefox::Profile.new
522
+
523
+ cert8_data = write_random_data(@cert8_db)
524
+ key3_data = write_random_data(@key3_db)
525
+
526
+ an_exception = nil
527
+ begin
528
+ CapybaraSetup.new.instance_exec(profile, @cert_dir) { |profile, certificate_path|
529
+ update_firefox_profile_with_certificates(profile, certificate_path)
530
+ }
531
+ rescue RuntimeError => e
532
+ an_exception = e
533
+ end
534
+
535
+ an_exception.should_not be_nil
536
+ end
537
+
538
+ it "should update a firefox profile with valid references to certificate db files" do
539
+
540
+ profile = Selenium::WebDriver::Firefox::Profile.new
541
+
542
+ cert8_data = write_random_data(@cert8_db)
543
+ key3_data = write_random_data(@key3_db)
544
+ secmod_data = write_random_data(@secmod_db)
545
+
546
+ setup = CapybaraSetup.new
547
+ result = setup.instance_exec(profile, @cert_dir) { |profile, certificate_path|
548
+ update_firefox_profile_with_certificates(profile, certificate_path)
549
+ }
550
+ profile_path = result.layout_on_disk
551
+ compare_file_data(profile_path, 'cert8.db', cert8_data)
552
+ compare_file_data(profile_path, 'key3.db', key3_data)
553
+ compare_file_data(profile_path, 'secmod.db', secmod_data)
464
554
  end
555
+
556
+ it "should update a firefox profile with references to certificate db files with prefixes" do
557
+
558
+ profile = Selenium::WebDriver::Firefox::Profile.new
559
+ cert_prefix = 'a'
560
+ @cert8_db = @cert_dir + File::SEPARATOR + cert_prefix + 'cert8.db'
561
+ @key3_db = @cert_dir + File::SEPARATOR + cert_prefix + 'key3.db'
562
+ @secmod_db = @cert_dir + File::SEPARATOR + cert_prefix + 'secmod.db'
563
+
564
+ cert8_data = write_random_data(@cert8_db)
565
+ key3_data = write_random_data(@key3_db)
566
+ secmod_data = write_random_data(@secmod_db)
567
+
568
+ setup = CapybaraSetup.new
569
+ result = setup.instance_exec(profile, @cert_dir, cert_prefix) { |profile, certificate_path, certificate_prefix, result|
570
+ update_firefox_profile_with_certificates(profile, certificate_path, certificate_prefix)
571
+ }
572
+ profile_path = result.layout_on_disk
573
+ compare_file_data(profile_path, 'cert8.db', cert8_data)
574
+ compare_file_data(profile_path, 'key3.db', key3_data)
575
+ compare_file_data(profile_path, 'secmod.db', secmod_data)
576
+ end
577
+
465
578
  end
579
+
466
580
  end
467
581
 
582
+
468
583
  end
469
584
  end
470
585
  end
@@ -20,6 +20,16 @@ describe Frameworks::EnvHelper do
20
20
  @mobile_base_url.should == 'http://mobile.sandbox.dev.bbc.co.uk'
21
21
  end
22
22
 
23
+ it "should be able to set a local system6 url" do
24
+ ENV['ENVIRONMENT'] = 'sandbox6'
25
+ generate_base_urls
26
+ @base_url.should == 'http://sandbox.bbc.co.uk'
27
+ @ssl_base_url.should == 'https://ssl.sandbox.bbc.co.uk'
28
+ @static_base_url.should == 'http://static.sandbox.bbc.co.uk'
29
+ @m_base_url.should == 'http://m.sandbox.bbc.co.uk'
30
+ @mobile_base_url.should == 'http://mobile.sandbox.bbc.co.uk'
31
+ end
32
+
23
33
  it "should be able to set a base url" do
24
34
  ENV['ENVIRONMENT'] = 'foo'
25
35
  generate_base_urls
@@ -114,27 +124,128 @@ describe Frameworks::EnvHelper do
114
124
  @open_base_url.should == 'https://open.foo.bbc.co.uk'
115
125
  end
116
126
 
117
- it "should be able to set proxy host correctly to use in tests using HTTP_PROXY env variable" do
127
+ it "should be able to set proxy host and port correctly to use in tests using HTTP_PROXY env variable" do
118
128
  ENV['ENVIRONMENT'] = 'foo'
119
- ENV['HTTP_PROXY'] = 'http://mycache.co.uk:80'
129
+ ENV['HTTP_PROXY'] = 'http://mycache.co.uk:8080'
120
130
  generate_base_urls
121
131
  @proxy_host.should == "mycache.co.uk"
132
+ @proxy_port.should == "8080"
122
133
  end
123
134
 
124
135
  it "should be able to set proxy host correctly to use in tests using http_proxy env variable" do
125
136
  ENV['ENVIRONMENT'] = 'foo'
126
- ENV['http_proxy'] = 'http://mycache.co.uk:80'
137
+ ENV['http_proxy'] = 'http://mycache.co.uk:8080'
138
+ generate_base_urls
139
+ @proxy_host.should == "mycache.co.uk"
140
+ @proxy_port.should == "8080"
141
+ end
142
+
143
+ it "should be able to use 80 as default proxy port when none specified" do
144
+ ENV['ENVIRONMENT'] = 'foo'
145
+ ENV['http_proxy'] = 'http://mycache.co.uk'
146
+ generate_base_urls
147
+ @proxy_host.should == "mycache.co.uk"
148
+ @proxy_port.should == "80"
149
+ end
150
+
151
+ it "should be able to handle an environment variable which doesn't have the protocol" do
152
+ ENV['ENVIRONMENT'] = 'foo'
153
+ ENV['http_proxy'] = 'mycache.co.uk'
127
154
  generate_base_urls
128
155
  @proxy_host.should == "mycache.co.uk"
156
+ @proxy_port.should == "80"
157
+ end
158
+
159
+ it "should be able to have an empty http_proxy environment variable" do
160
+ ENV['ENVIRONMENT'] = 'foo'
161
+ ENV['http_proxy'] = ''
162
+ generate_base_urls
163
+ @proxy_host.should be_nil
164
+ @proxy_port.should be_nil
165
+ end
166
+
167
+ it "should be able to set a local url with expected domain" do
168
+ ENV['ENVIRONMENT'] = 'sandbox'
169
+ ENV['FW_BBC_DOMAIN'] = 'bbc.com'
170
+ generate_base_urls
171
+ @base_url.should == 'http://pal.sandbox.dev.bbc.com'
172
+ @ssl_base_url.should == 'https://ssl.sandbox.dev.bbc.com'
173
+ @static_base_url.should == 'http://static.sandbox.dev.bbc.com'
174
+ @m_base_url.should == 'http://m.sandbox.dev.bbc.com'
175
+ @mobile_base_url.should == 'http://mobile.sandbox.dev.bbc.com'
176
+ end
177
+
178
+ it "should be able to set a local system6 url with expected domain" do
179
+ ENV['ENVIRONMENT'] = 'sandbox6'
180
+ ENV['FW_BBC_DOMAIN'] = 'bbc.com'
181
+ generate_base_urls
182
+ @base_url.should == 'http://sandbox.bbc.com'
183
+ @ssl_base_url.should == 'https://ssl.sandbox.bbc.com'
184
+ @static_base_url.should == 'http://static.sandbox.bbc.com'
185
+ @m_base_url.should == 'http://m.sandbox.bbc.com'
186
+ @mobile_base_url.should == 'http://mobile.sandbox.bbc.com'
187
+ end
188
+
189
+ it "should be able to set a base url with expected domain" do
190
+ ENV['ENVIRONMENT'] = 'foo'
191
+ ENV['FW_BBC_DOMAIN'] = 'bbc.com'
192
+ generate_base_urls
193
+ @base_url.should == 'http://www.foo.bbc.com'
194
+ @ssl_base_url.should == 'https://ssl.foo.bbc.com'
195
+ @static_base_url.should == 'http://static.foo.bbci.co.uk'
196
+ @open_base_url.should == 'http://open.foo.bbc.com'
197
+ @m_base_url.should == 'http://m.foo.bbc.com'
198
+ @mobile_base_url.should == 'http://mobile.foo.bbc.com'
199
+ end
200
+
201
+ it "should set public facing live domain" do
202
+ ENV['ENVIRONMENT'] = 'live'
203
+ ENV['WWW_LIVE'] = 'false'
204
+ ENV['FW_BBC_DOMAIN'] = 'bbc.com'
205
+ generate_base_urls
206
+ @base_url.should == 'http://www.bbc.com'
207
+ @ssl_base_url.should == 'https://ssl.bbc.com'
208
+ @static_base_url.should == 'http://static.bbci.co.uk'
209
+ @open_base_url.should == 'http://open.bbc.com'
210
+ @m_base_url.should == 'http://m.bbc.com'
211
+ @mobile_base_url.should == 'http://mobile.bbc.com'
129
212
  end
130
213
 
131
214
  =begin
132
215
  #don't want to push proxy addr online
133
216
  it "should be able to validate xhtml online" do
134
217
  @proxy_host = ''
218
+ @proxy_port = ''
135
219
  xhtml = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>a</title></head><body><p>a</p></body></html>'
136
220
  validate_online(xhtml)
137
221
  end
222
+
223
+ it "should be able to report errors for invalid markup" do
224
+ @proxy_host = ''
225
+ @proxy_port = ''
226
+ xhtml = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><nosuchelement><title>a</title></head><body><p>a</p></body></html>'
227
+ expect {
228
+ validate_online(xhtml)
229
+ }.to raise_error(RuntimeError)
230
+ end
138
231
  =end
232
+ end
233
+
234
+ describe "independent mechanize agent" do
235
+ include Frameworks::EnvHelper
236
+
237
+ it "should allow you to create an independent, configured mechanize object" do
238
+ ENV['HTTP_PROXY'] = 'http://mycache.co.uk:80'
239
+ agent = new_mechanize
240
+ agent.should be_a_kind_of Mechanize
241
+ agent.proxy_addr.should == 'mycache.co.uk'
242
+ end
243
+
244
+ it "the proxy should be separately configurable" do
245
+ agent = new_mechanize(http_proxy='http://mycache.co.uk:80')
246
+ agent.should be_a_kind_of Mechanize
247
+ agent.proxy_addr.should == 'mycache.co.uk'
248
+ end
249
+
139
250
  end
140
251
  end
data/spec/spec_helper.rb CHANGED
@@ -13,4 +13,5 @@ Cucumber::RbSupport::RbLanguage.new(Cucumber::Runtime.new) #Need to load Cucumbe
13
13
 
14
14
  require 'frameworks/capybara'
15
15
  require 'frameworks/cucumber'
16
+ require 'monkey-patches/capybara-mechanize-patches'
16
17
  require 'unit_test_monkeypatches.rb'