proxy_rb 0.8.3 → 0.9.0

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: 9cd600ab4e47bdff1d8f9aa5a4c74c3c033f7cc8
4
- data.tar.gz: f923255083ddd9fcf372c8f37815c44387df3c3d
3
+ metadata.gz: 700fef6b3c45edf77d464691d35ce622a011345a
4
+ data.tar.gz: aed87998d986f086e57db2ad93cb1a1ec198ec8b
5
5
  SHA512:
6
- metadata.gz: 9cf9fa3ffed13a211032a6c079703c3fa44f57c16f849c18029c51977e3de6884795b6fe5eb6be68f83b368b13f36e56c04606ca96276662729c6717d2c8c6d7
7
- data.tar.gz: 62c2411556c6ce5a9949ff0ebd5df5294394e91f834f23a24a857cb0f53c7da9a3440d0eba3a7af26eca7e3603d2ca03e551fb9576784e6a098482e5ff943e9c
6
+ metadata.gz: e41ec2bb566cc4ec3afcb9ee3abce78ac7b7679ac5809c819ac07122b5c3b0a196b27e38ac0e7ff67466204e9aaabbe28b4ef1dc52a014e01c645b82c263bb55
7
+ data.tar.gz: 6857309b09f3aa44cc20d70c2a0265ccdad5f76bbdb3d03684cebeb85506e373eb1019c798624b99f3525868dd1d5e3b23e6c95dee770d18352537f247c68ea4
data/History.md CHANGED
@@ -4,6 +4,10 @@ Empty
4
4
 
5
5
  # RELEASED
6
6
 
7
+ ## [v0.9.0](https://github.com/cucumber/aruba/compare/v0.8.3...v0.9.0)
8
+
9
+ * Added some step definitions for cucumber
10
+
7
11
  ## [v0.8.3](https://github.com/cucumber/aruba/compare/v0.8.2...v0.8.3)
8
12
 
9
13
  * Make warning appear once
File without changes
@@ -0,0 +1,2 @@
1
+ # frozen_string_literal: true
2
+ require 'proxy_rb/cucumber'
@@ -42,14 +42,14 @@ module ProxyRb
42
42
 
43
43
  # The proxy based on subject
44
44
  def proxy
45
- ProxyRb::HttpProxy.new(ProxyUrlParser.new(subject))
45
+ @proxy ||= ProxyRb::HttpProxy.new(ProxyRb::ProxyUrlParser.new(subject))
46
46
  end
47
47
 
48
48
  # Visit an URL
49
49
  #
50
50
  # @param [String] url
51
51
  # rubocop:disable Metrics/AbcSize
52
- def visit(url)
52
+ def visit(url, p = proxy)
53
53
  resource = Resource.new(url)
54
54
 
55
55
  proxy_rb.event_bus.notify Events::ResourceSet.new(resource.url.to_s)
@@ -58,10 +58,10 @@ module ProxyRb
58
58
  NonIncludes.clear_environment
59
59
  NonIncludes.configure_driver
60
60
 
61
- proxy_rb.event_bus.notify Events::ProxySet.new(proxy.url.to_s)
62
- proxy_rb.event_bus.notify Events::ProxyUserSet.new(proxy.credentials.to_s) unless proxy.credentials.empty?
61
+ proxy_rb.event_bus.notify Events::ProxySet.new(p.url.to_s)
62
+ proxy_rb.event_bus.notify Events::ProxyUserSet.new(p.credentials.to_s) unless p.credentials.empty?
63
63
 
64
- NonIncludes.register_capybara_driver_for_proxy(proxy)
64
+ NonIncludes.register_capybara_driver_for_proxy(p)
65
65
 
66
66
  proxy_rb.event_bus.notify Events::BeforeResourceFetched.new(page)
67
67
 
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ Before do
3
+ setup_proxy_rb
4
+ end
5
+
6
+ %i(
7
+ proxy
8
+ proxy_user
9
+ resource
10
+ resource_user
11
+ http_response_headers
12
+ ).each do |announcer|
13
+ Before "@announce_#{announcer}" do
14
+ proxy_rb.announcer.activate(announcer)
15
+ end
16
+ end
17
+
18
+ Before '@announce' do
19
+ %i(
20
+ proxy
21
+ proxy_user
22
+ resource
23
+ resource_user
24
+ http_response_headers
25
+ ).each do |announcer|
26
+ proxy_rb.announcer.activate(announcer)
27
+ end
28
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+ require 'proxy_rb/http_proxy'
3
+ require 'proxy_rb/proxy_url_parser'
4
+
5
+ Given(/^I use the following proxies:$/) do |table|
6
+ @proxies = table.hashes.map { |r| ProxyRb::HttpProxy.new(ProxyRb::ProxyUrlParser.new(r[:proxy])) }
7
+ end
8
+
9
+ Then(/the following requests are( not)? allowed to pass the proxy:/) do |forbidden, table|
10
+ requests = []
11
+
12
+ proxies.each do |proxy|
13
+ table.hashes.map { |r| r[:url] }.each do |r|
14
+ visit r, proxy
15
+ requests << page.dup
16
+ end
17
+ end
18
+
19
+ if forbidden
20
+ expect(requests).to ProxyRb::Matchers.all be_forbidden
21
+ else
22
+ expect(requests).to ProxyRb::Matchers.all be_successful
23
+ end
24
+ end
25
+
26
+ When(/^I visit "([^"]*)"$/) do |url|
27
+ Array(proxies.first).each { |proxy| visit url, proxy }
28
+ end
29
+
30
+ When(/^I visit the following websites:$/) do |table|
31
+ @websites = table.hashes.map { |r| r[:url] }
32
+ end
33
+
34
+ Then(/the (?:last response|last requested page) should( not)? contain:/) do |not_expected, content|
35
+ if not_expected
36
+ expect(page).not_to have_content content
37
+ else
38
+ expect(page).to have_content content
39
+ end
40
+ end
41
+
42
+ Then(/all (?:requested pages|responses) should( not)? contain:/) do |not_expected, content|
43
+ results = []
44
+
45
+ proxies.each do |proxy|
46
+ websites.each do |w|
47
+ visit w, proxy
48
+ results << page.dup
49
+ end
50
+ end
51
+
52
+ if not_expected
53
+ expect(results).not_to ProxyRb::Matchers.include have_content content
54
+ else
55
+ expect(results).to ProxyRb::Matchers.all have_content content
56
+ end
57
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'proxy_rb'
3
+ require 'proxy_rb/api'
4
+
5
+ # Main Module
6
+ module ProxyRb
7
+ # Main Module
8
+ module Cucumber
9
+ include ProxyRb::Api
10
+
11
+ attr_reader :proxy
12
+
13
+ def proxies
14
+ @proxies ||= []
15
+ end
16
+
17
+ def websites
18
+ @websites ||= []
19
+ end
20
+ end
21
+ end
22
+
23
+ World(ProxyRb::Cucumber)
24
+
25
+ require 'proxy_rb/cucumber/hooks'
26
+ ProxyRb.require_files_matching_pattern('cucumber/*.rb')
27
+
28
+ ProxyRb.logger.warn 'You disabled the "strict"-mode in your ProxyRb-configuration. You might not notice all errors.' if ProxyRb.config.strict == false
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'rspec/expectations'
3
+
4
+ # Aruba
5
+ module ProxyRb
6
+ # Matchers
7
+ module Matchers
8
+ include ::RSpec::Matchers
9
+
10
+ module_function :all
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'rspec/expectations'
3
+
4
+ # Aruba
5
+ module ProxyRb
6
+ # Matchers
7
+ module Matchers
8
+ include ::RSpec::Matchers
9
+
10
+ module_function :include
11
+ end
12
+ end
@@ -33,18 +33,26 @@ RSpec.configure do |config|
33
33
  config.before :each do |example|
34
34
  next unless self.class.include? ProxyRb::Api
35
35
 
36
- proxy_rb.announcer.activate(:proxy) if example.metadata[:announce_proxy]
37
- proxy_rb.announcer.activate(:proxy_user) if example.metadata[:announce_proxy_user]
38
- proxy_rb.announcer.activate(:resource) if example.metadata[:announce_resource]
39
- proxy_rb.announcer.activate(:resource_user) if example.metadata[:announce_resource_user]
40
- proxy_rb.announcer.activate(:http_response_headers) if example.metadata[:announce_http_response_headers]
36
+ %i(
37
+ proxy
38
+ proxy_user
39
+ resource
40
+ resource_user
41
+ http_response_headers
42
+ ).each do |announcer|
43
+ proxy_rb.announcer.activate(announcer) if example.metadata["announce_#{announcer}".to_sym]
44
+ end
41
45
 
42
46
  if example.metadata[:announce]
43
- proxy_rb.announcer.activate(:proxy)
44
- proxy_rb.announcer.activate(:proxy_user)
45
- proxy_rb.announcer.activate(:resource)
46
- proxy_rb.announcer.activate(:resource_user)
47
- proxy_rb.announcer.activate(:http_response_headers)
47
+ %i(
48
+ proxy
49
+ proxy_user
50
+ resource
51
+ resource_user
52
+ http_response_headers
53
+ ).each do |announcer|
54
+ proxy_rb.announcer.activate(announcer)
55
+ end
48
56
  end
49
57
  end
50
58
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # Main Module
3
3
  module ProxyRb
4
- VERSION = '0.8.3'
4
+ VERSION = '0.9.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,6 +139,8 @@ files:
139
139
  - fixtures/proxy-config/.rspec
140
140
  - fixtures/proxy-config/README.md
141
141
  - fixtures/proxy-config/Rakefile
142
+ - fixtures/proxy-config/features/support/env.rb
143
+ - fixtures/proxy-config/features/support/proxy_rb.rb
142
144
  - fixtures/proxy-config/spec/spec_helper.rb
143
145
  - fixtures/proxy-config/spec/support/aruba.rb
144
146
  - fixtures/proxy-config/spec/support/proxy_rb.rb
@@ -160,6 +162,9 @@ files:
160
162
  - lib/proxy_rb/console.rb
161
163
  - lib/proxy_rb/console/help.rb
162
164
  - lib/proxy_rb/credentials.rb
165
+ - lib/proxy_rb/cucumber.rb
166
+ - lib/proxy_rb/cucumber/hooks.rb
167
+ - lib/proxy_rb/cucumber/steps.rb
163
168
  - lib/proxy_rb/drivers/basic_driver.rb
164
169
  - lib/proxy_rb/drivers/poltergeist_driver.rb
165
170
  - lib/proxy_rb/drivers/selenium_driver.rb
@@ -173,9 +178,11 @@ files:
173
178
  - lib/proxy_rb/initializer.rb
174
179
  - lib/proxy_rb/main.rb
175
180
  - lib/proxy_rb/matchers/.keep
181
+ - lib/proxy_rb/matchers/all.rb
176
182
  - lib/proxy_rb/matchers/be_forbidden.rb
177
183
  - lib/proxy_rb/matchers/be_successful.rb
178
184
  - lib/proxy_rb/matchers/have_mime_type.rb
185
+ - lib/proxy_rb/matchers/include.rb
179
186
  - lib/proxy_rb/no_proxy.rb
180
187
  - lib/proxy_rb/password_fetchers.rb
181
188
  - lib/proxy_rb/password_fetchers/basic_password_fetcher.rb