browsermob-proxy 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10733afcc2b776e0a5bef4369436ccc1db174436
4
- data.tar.gz: f4ca31c55c2a73816344951a31c2cdb47b11b8e3
3
+ metadata.gz: f12486dddc06e36739ca5096673afe2ff6c93814
4
+ data.tar.gz: 28f90db23dfedc1553016ca9197ca63f6db1ca01
5
5
  SHA512:
6
- metadata.gz: 485b20b18bc7771eff5836f2c45d6ad566d1bf2c5131c0fff900ff656a9ef3331cbcc5c4800b7922d55caa771a9389c8582a5fbd7d9bb73d03142887835eb5fc
7
- data.tar.gz: f030b905d45673a987095c9f285028f93d10c6ca54b78b5d75cb21f78b6851a7a78bb2f0b0db2b5c85b404bad085db52aa9de50881f52bb5cdd150fe45eec0ac
6
+ metadata.gz: 1bc123504739bb7f2945e8f79dd6db65f3c9546c19f304ff7ff83c02e86f49e569cf14379bbfb327ede3d3b672279e37c70ce03db7fe141490123271e4c5c8b2
7
+ data.tar.gz: b6aeec505c779005f78572009a5083d14d379eac80e7542b0f7a3da17c04182310f3dc2fbf6aa59cf9366d70dd749fe9455a8d9047d2e228b094bf0e6f3d46ee
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  pkg/*
5
5
  .ruby-version
6
6
  .ruby-gemset
7
+ .yardoc
@@ -1,6 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.0
4
5
  before_script:
5
6
  - sudo apt-get install -y unzip
6
7
  - curl -k -L -O https://s3-us-west-1.amazonaws.com/lightbody-bmp/browsermob-proxy-2.0-beta-9-bin.zip
data/README.md CHANGED
@@ -82,7 +82,7 @@ Note on Patches/Pull Requests
82
82
  Copyright
83
83
  ---------
84
84
 
85
- Copyright 2011-2013 Jari Bakken
85
+ Copyright 2011-2014 Jari Bakken
86
86
 
87
87
  Licensed under the Apache License, Version 2.0 (the "License");
88
88
  you may not use this file except in compliance with the License.
@@ -26,8 +26,7 @@ module BrowserMob
26
26
  end
27
27
 
28
28
  #
29
- # Examples:
30
- #
29
+ # @example
31
30
  # client.new_har("page-name")
32
31
  # client.new_har("page-name", :capture_headers => true)
33
32
  # client.new_har(:capture_headers => true)
@@ -106,6 +105,15 @@ module BrowserMob
106
105
  @resource['blacklist'].delete
107
106
  end
108
107
 
108
+ def rewrite(match_regex, replace)
109
+ regex = Regexp === match_regex ? match_regex.source : match_regex.to_s
110
+ @resource['rewrite'].put :matchRegex => regex, :replace => replace
111
+ end
112
+
113
+ def clear_rewrites
114
+ @resource['rewrite'].delete
115
+ end
116
+
109
117
  def header(hash)
110
118
  @resource['headers'].post hash.to_json, :content_type => "application/json"
111
119
  end
@@ -154,7 +162,8 @@ module BrowserMob
154
162
  # Each invocation of the method will add given hosts to existing BrowserMob's DNS cache
155
163
  # instead of overriding it.
156
164
  #
157
- # @example remap_dns_hosts('example.com' => '1.2.3.4')
165
+ # @example
166
+ # remap_dns_hosts('example.com' => '1.2.3.4')
158
167
  # @param hash [Hash] a hash with domains as keys and IPs as values
159
168
  #
160
169
 
@@ -1,5 +1,5 @@
1
1
  module BrowserMob
2
2
  module Proxy
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
@@ -128,6 +128,29 @@ describe "Proxy + WebDriver" do
128
128
  end
129
129
  end
130
130
 
131
+ describe 'rewrite rules' do
132
+
133
+ let(:uri) { URI.parse url_for('1.html') }
134
+
135
+ before do
136
+ proxy.rewrite(%r{1\.html}, '2.html')
137
+ end
138
+
139
+ it 'fetches the rewritten url' do
140
+ driver.get uri
141
+
142
+ wait.until { driver.title == '2' }
143
+ end
144
+
145
+ it 'can be cleared' do
146
+ proxy.clear_rewrites
147
+ driver.get uri
148
+
149
+ wait.until { driver.title == '1' }
150
+ end
151
+
152
+ end
153
+
131
154
  it 'should set timeouts' do
132
155
  proxy.timeouts(read: 0.001)
133
156
  driver.get url_for('slow')
@@ -19,7 +19,8 @@ module BrowserMob
19
19
  "headers" => double("resource[headers]"),
20
20
  "auth/basic/#{DOMAIN}" => double("resource[auth/basic/#{DOMAIN}]"),
21
21
  "hosts" => double("resource[hosts]"),
22
- "timeout" => double("resource[timeout]")
22
+ "timeout" => double("resource[timeout]"),
23
+ "rewrite" => double("resource[rewrite]")
23
24
  }.each do |path, mock|
24
25
  resource.stub(:[]).with(path).and_return(mock)
25
26
  end
@@ -231,6 +232,34 @@ module BrowserMob
231
232
  client.remap_dns_hosts(DOMAIN => '1.2.3.4')
232
233
  end
233
234
 
235
+ describe 'rewrite rules' do
236
+
237
+ context 'when using a regular expression' do
238
+ it 'sets a rewrite rule' do
239
+ resource['rewrite'].should_receive(:put).
240
+ with(:matchRegex => 'old\.com', :replace => 'new.com')
241
+
242
+ client.rewrite('old\.com', 'new.com')
243
+ end
244
+ end
245
+
246
+ context 'when using a string' do
247
+ it 'sets a rewrite rule' do
248
+ resource['rewrite'].should_receive(:put).
249
+ with(:matchRegex => 'old\.com', :replace => 'new.com')
250
+
251
+ client.rewrite(%r{old\.com}, 'new.com')
252
+ end
253
+ end
254
+
255
+ it 'clears the rewrite rules' do
256
+ resource['rewrite'].should_receive(:delete)
257
+
258
+ client.clear_rewrites
259
+ end
260
+ end
261
+
262
+
234
263
  context "#selenium_proxy" do
235
264
  it "defaults to HTTP proxy only" do
236
265
  proxy = client.selenium_proxy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browsermob-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jari.bakken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-18 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  requirements: []
188
188
  rubyforge_project: browsermob-proxy-rb
189
- rubygems_version: 2.1.9
189
+ rubygems_version: 2.1.10
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Ruby client for the BrowserMob Proxy REST API