infrataster 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/Rakefile +17 -9
- data/lib/infrataster/browsermob_proxy.rb +5 -0
- data/lib/infrataster/contexts/capybara_context.rb +24 -24
- data/lib/infrataster/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ce1087098d32e5590380749af3c3d864cb877ff
|
4
|
+
data.tar.gz: 3db9a8a5b018a199ce49a90853b0906c820d22fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d03e0bee9d2b39ffaaf1f628c541532702aafe38771f4dc870125cc1e647d20cb1650fbbe9598fb31c5473b6208e26f5e97bf2d180424dc42a070be6f4480d5
|
7
|
+
data.tar.gz: 50e50689ea235aafbf3aa1729716e7996021310e532bf539be391bdc9a8958cfb73bc813e5e0e5a9994172d3d3ec4c648402d4f6a1a6320d720a2907627612f8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require "open-uri"
|
3
4
|
|
4
|
-
def
|
5
|
-
"\e[
|
5
|
+
def yellow(str)
|
6
|
+
"\e[33m#{str}\e[m"
|
6
7
|
end
|
7
8
|
|
8
9
|
ENV['VAGRANT_CWD'] = File.expand_path('spec/integration/vm')
|
@@ -18,16 +19,23 @@ namespace :spec do
|
|
18
19
|
|
19
20
|
namespace :integration do
|
20
21
|
integration_dir = 'spec/integration'
|
22
|
+
|
21
23
|
task :prepare => ['download_browsermob', 'start_vm'] do
|
22
24
|
end
|
23
25
|
|
24
26
|
task :download_browsermob do
|
25
27
|
dir = File.join(integration_dir, 'vm/vendor/browsermob')
|
26
28
|
unless Dir.exist?(dir)
|
27
|
-
puts
|
29
|
+
puts yellow("Downloading browsermob...")
|
28
30
|
Dir.mktmpdir do |tmp|
|
29
|
-
|
30
|
-
|
31
|
+
open('https://s3-us-west-1.amazonaws.com/lightbody-bmp/browsermob-proxy-2.0-beta-9-bin.zip') do |remote|
|
32
|
+
open(File.join(tmp, 'browsermob-proxy.zip'), 'wb') do |f|
|
33
|
+
f.write(remote.read)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
Dir.chdir(tmp) do
|
37
|
+
system "unzip browsermob-proxy.zip"
|
38
|
+
end
|
31
39
|
FileUtils.mv(File.join(tmp, 'browsermob-proxy-2.0-beta-9'), dir)
|
32
40
|
end
|
33
41
|
end
|
@@ -37,15 +45,15 @@ namespace :spec do
|
|
37
45
|
dir = File.join(integration_dir, 'vm/vendor/cookbooks')
|
38
46
|
# Berkshelf
|
39
47
|
if Dir.exist?(dir)
|
40
|
-
puts
|
48
|
+
puts yellow("'#{dir}' already exists. If you want update cookbooks, delete the directory and re-run rake command")
|
41
49
|
else
|
42
|
-
puts
|
43
|
-
system "cd #{
|
50
|
+
puts yellow('Installing cookbooks by berkshelf...')
|
51
|
+
system "cd #{integration_dir}/vm && berks vendor vendor/cookbooks"
|
44
52
|
end
|
45
53
|
end
|
46
54
|
|
47
55
|
task :start_vm => ['berks_vendor'] do
|
48
|
-
puts
|
56
|
+
puts yellow('Starting VM...')
|
49
57
|
system '/usr/bin/vagrant up'
|
50
58
|
end
|
51
59
|
end
|
@@ -5,18 +5,29 @@ require 'capybara/poltergeist'
|
|
5
5
|
module Infrataster
|
6
6
|
module Contexts
|
7
7
|
class CapybaraContext < BaseContext
|
8
|
+
def self.session
|
9
|
+
@session ||= prepare_session
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.prepare_session
|
13
|
+
capybara_driver_name = :infrataster_driver
|
14
|
+
|
15
|
+
proxy = BrowsermobProxy.proxy
|
16
|
+
Capybara.register_driver capybara_driver_name do |app|
|
17
|
+
Capybara::Poltergeist::Driver.new(
|
18
|
+
app,
|
19
|
+
phantomjs_options: ["--proxy=http://#{proxy.host}:#{proxy.port}"],
|
20
|
+
)
|
21
|
+
end
|
22
|
+
Capybara::Session.new(capybara_driver_name)
|
23
|
+
end
|
24
|
+
|
8
25
|
def initialize(*args)
|
9
26
|
super(*args)
|
10
|
-
|
11
|
-
register_capybara_driver
|
12
27
|
end
|
13
28
|
|
14
29
|
def session
|
15
|
-
|
16
|
-
|
17
|
-
address, port, @gateway_finalize_proc = server.from_gateway_open(resource.uri.port)
|
18
|
-
Capybara.app_host = "http://#{address}:#{port}"
|
19
|
-
@session = Capybara::Session.new(capybara_driver_name)
|
30
|
+
self.class.session
|
20
31
|
end
|
21
32
|
|
22
33
|
def page
|
@@ -25,6 +36,12 @@ module Infrataster
|
|
25
36
|
|
26
37
|
def before_each(example)
|
27
38
|
example.example_group_instance.extend(Capybara::RSpecMatchers)
|
39
|
+
|
40
|
+
proxy = BrowsermobProxy.proxy
|
41
|
+
proxy.header({"Host" => resource.uri.host})
|
42
|
+
|
43
|
+
address, port, @gateway_finalize_proc = server.from_gateway_open(resource.uri.port)
|
44
|
+
Capybara.app_host = "http://#{address}:#{port}"
|
28
45
|
end
|
29
46
|
|
30
47
|
def after_each(example)
|
@@ -34,23 +51,6 @@ module Infrataster
|
|
34
51
|
def method_missing(method, *args)
|
35
52
|
session.public_send(method, *args)
|
36
53
|
end
|
37
|
-
|
38
|
-
private
|
39
|
-
def register_capybara_driver
|
40
|
-
proxy = BrowsermobProxy.server.create_proxy
|
41
|
-
proxy.header({"Host" => resource.uri.host})
|
42
|
-
|
43
|
-
Capybara.register_driver capybara_driver_name do |app|
|
44
|
-
Capybara::Poltergeist::Driver.new(
|
45
|
-
app,
|
46
|
-
phantomjs_options: ["--proxy=http://#{proxy.host}:#{proxy.port}"],
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def capybara_driver_name
|
52
|
-
:"selenium_via_proxy_#{hash}"
|
53
|
-
end
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/infrataster/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infrataster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|