Some Browser::Options work

This commit is contained in:
erwanlr
2013-04-10 18:34:50 +02:00
parent b9524499bf
commit 1615c0f84e
8 changed files with 82 additions and 41 deletions

View File

@@ -4,11 +4,17 @@ require 'spec_helper'
describe Browser do
it_behaves_like 'Browser::Actions'
it_behaves_like 'Browser::Options'
CONFIG_FILE_WITHOUT_PROXY = SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf.json'
CONFIG_FILE_WITH_PROXY = SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf_proxy.json'
CONFIG_FILE_WITH_PROXY_AND_AUTH = SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf_proxy_auth.json'
INSTANCE_VARS_TO_CHECK = ['user_agent', 'user_agent_mode', 'available_user_agents', 'proxy', 'max_threads', 'request_timeout', 'cache_ttl']
INSTANCE_VARS_TO_CHECK = ['user_agent', 'user_agent_mode', 'available_user_agents', 'proxy', 'max_threads', 'cache_ttl']
subject(:browser) {
Browser::reset
Browser.instance
}
before :all do
@json_config_without_proxy = JSON.parse(File.read(CONFIG_FILE_WITHOUT_PROXY))
@@ -47,17 +53,17 @@ describe Browser do
end
end
describe '#max_threads=' do
it 'should set max_threads to 1 if nil is given' do
@browser.max_threads = nil
@browser.max_threads.should === 1
end
it 'should set max_threads to 1 if 0 is given' do
@browser.max_threads = 0
@browser.max_threads.should === 1
end
end
#describe '#max_threads=' do
# it 'should set max_threads to 1 if nil is given' do
# @browser.max_threads = nil
# @browser.max_threads.should === 1
# end
#
# it 'should set max_threads to 1 if 0 is given' do
# @browser.max_threads = 0
# @browser.max_threads.should === 1
# end
#end
describe '#proxy_auth=' do
after :each do
@@ -305,9 +311,9 @@ describe Browser do
context 'when @basic_auth' do
it 'appends the basic_auth' do
@browser.basic_auth = 'basic-auth'
@browser.basic_auth = 'user:pass'
@expected = default_expectation.merge(
headers: default_expectation[:headers].merge('Authorization' => 'basic-auth')
headers: default_expectation[:headers].merge('Authorization' => 'Basic '+Base64.encode64('user:pass'))
)
end

View File

@@ -2,4 +2,32 @@
shared_examples 'Browser::Options' do
describe 'basic_auth=' do
end
describe 'max_threads' do
end
describe 'user_agent=' do
end
describe 'user_agent' do
end
describe 'proxy=' do
end
describe 'proxy_auth=' do
end
describe 'override_config_with_options' do
end
end

View File

@@ -34,12 +34,12 @@ shared_examples 'WpTarget::WpRegistrable' do
context 'when multisite' do
let(:multisite) { true }
it 'returns false (multisite)' do
it 'returns false' do
@stub = { status: 302, headers: { 'Location' => 'wp-login.php?registration=disabled' } }
@expected = false
end
it 'returns true (multisite)' do
it 'returns true' do
@stub = { status: 200, body: %{<form id="setupform" method="post" action="wp-signup.php">} }
@expected = true
end
@@ -48,12 +48,12 @@ shared_examples 'WpTarget::WpRegistrable' do
context 'when not multisite' do
let(:multisite) { false }
it 'returns false (not multisite)' do
it 'returns false' do
@stub = { status: 302, headers: { 'Location' => 'wp-login.php?registration=disabled' } }
@expected = false
end
it 'returns true (not multisite)' do
it 'returns true' do
@stub = { status: 200, body: %{<form name="registerform" id="registerform" action="wp-login.php"} }
@expected = true
end

View File

@@ -1,8 +1,5 @@
# encoding: UTF-8
# https://github.com/bblimke/webmock
# https://github.com/colszowka/simplecov
require 'webmock/rspec'
# Code Coverage (only works with ruby >= 1.9)
require 'simplecov' if RUBY_VERSION >= '1.9'
@@ -11,12 +8,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/common/common_helper'
SPEC_DIR = ROOT_DIR + '/spec'
SPEC_LIB_DIR = SPEC_DIR + '/lib'
SPEC_CACHE_DIR = SPEC_DIR + '/cache'
SPEC_CACHE_DIR = SPEC_DIR + '/cache' # FIXME remove it
SPEC_FIXTURES_DIR = SPEC_DIR + '/samples'
SHARED_EXAMPLES_DIR = SPEC_DIR + '/shared_examples'
SPEC_FIXTURES_CONF_DIR = SPEC_FIXTURES_DIR + '/conf'
SPEC_FIXTURES_CONF_DIR = SPEC_FIXTURES_DIR + '/conf' # FIXME Remove it
SPEC_FIXTURES_WP_VERSIONS_DIR = SPEC_FIXTURES_DIR + '/wp_versions'
redefine_constant(:CACHE_DIR, SPEC_DIR + '/cache')
redefine_constant(:CONF_DIR, SPEC_FIXTURES_DIR + '/conf/browser') # FIXME Remove the /browser
MODELS_FIXTURES = SPEC_FIXTURES_DIR + '/common/models'
COLLECTIONS_FIXTURES = SPEC_FIXTURES_DIR + '/common/collections'