lbspec 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,13 +41,16 @@ RSpec::Matchers.define :transfer do |nodes|
41
41
  @http_request_command = lambda do |addr, port, path, prove|
42
42
  env, opt = '', ''
43
43
  opt << (@options[:timeout] ? " -m #{@options[:timeout]}" : '')
44
- opt << (@options[:proxy] ? %Q(-x "#{@options[:proxy]}") : '')
44
+ opt << (@options[:proxy] ? %Q( -x "#{@options[:proxy]}") : '')
45
45
  if @options[:noproxy]
46
- opt << %Q( --noproxy "#{@options[:noproxy]}")
47
46
  env << %Q( no_proxy="#{@options[:noproxy]}")
48
47
  env << %Q( NO_PROXY="#{@options[:noproxy]}")
49
48
  end
50
- opt << (@options[:header] ? %Q(-H '#{@options[:header]}') : '')
49
+ if @options[:header]
50
+ header = @options[:header]
51
+ header = [header] unless header.respond_to? :each
52
+ header.each { |h| opt << %Q( -H '#{h}') }
53
+ end
51
54
  uri = 'http://' + "#{addr}:#{port}#{path}?#{prove}"
52
55
  Lbspec::Util
53
56
  .exec_command(%Q(#{env} curl -o /dev/null -s #{opt} '#{uri}'),
@@ -59,11 +62,14 @@ RSpec::Matchers.define :transfer do |nodes|
59
62
  opt << (@options[:ignore_valid_ssl] ? ' -k' : '')
60
63
  opt << (@options[:proxy] ? %Q( -x "#{@options[:proxy]}") : '')
61
64
  if @options[:noproxy]
62
- opt << %Q( --noproxy "#{@options[:noproxy]}")
63
65
  env << %Q( no_proxy="#{@options[:noproxy]}")
64
66
  env << %Q( NO_PROXY="#{@options[:noproxy]}")
65
67
  end
66
- opt << (@options[:header] ? %Q( -H '#{@options[:header]}') : '')
68
+ if @options[:header]
69
+ header = @options[:header]
70
+ header = [header] unless header.respond_to? :each
71
+ header.each { |h| opt << %Q( -H '#{h}') }
72
+ end
67
73
  uri = 'https://' + "#{addr}:#{port}#{path}?#{prove}"
68
74
  Lbspec::Util
69
75
  .exec_command(%Q(#{env} curl -o /dev/null -s #{opt} '#{uri}'),
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  # Lbspec is an RSpec plugin for easy Loadbalancer testing.
3
3
  module Lbspec
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -60,5 +60,37 @@ describe Lbspec do
60
60
  'vhost_a:443'.should transfer('node_a')
61
61
  .https.path('/test').from('node_a')
62
62
  end
63
+
64
+ describe 'request_command' do
65
+ it 'should create single header options for http' do
66
+ Lbspec::Util.should_receive(:exec_command)
67
+ .with(/ -H.*/, nil)
68
+ Lbspec::Util.should_not_receive(:exec_command)
69
+ .with(/ -H.* -H/, nil)
70
+ 'vhost_a:443'.should transfer('node_a').http
71
+ .options({ header: 'X-Test1:1' })
72
+ end
73
+ it 'should create single header options for https' do
74
+ Lbspec::Util.should_receive(:exec_command)
75
+ .with(/ -H.*/, nil)
76
+ Lbspec::Util.should_not_receive(:exec_command)
77
+ .with(/ -H.* -H/, nil)
78
+ 'vhost_a:443'.should transfer('node_a').https
79
+ .options({ header: 'X-Test1:1' })
80
+ end
81
+ it 'should create multi header options for http' do
82
+ Lbspec::Util.should_receive(:exec_command)
83
+ .with(/ -H.* -H/, nil)
84
+ 'vhost_a:443'.should transfer('node_a').http
85
+ .options({ header: %w(X-Test1:1 X-Test2:2) })
86
+ end
87
+ it 'should create multi header options for https' do
88
+ Lbspec::Util.should_receive(:exec_command)
89
+ .with(/ -H.* -H/, nil)
90
+ 'vhost_a:443'.should transfer('node_a').https
91
+ .options({ header: %w(X-Test1:1 X-Test2:2) })
92
+ end
93
+ end
94
+
63
95
  end
64
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-24 00:00:00.000000000 Z
12
+ date: 2014-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -184,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  segments:
186
186
  - 0
187
- hash: -194371314246007915
187
+ hash: -3855103968202962501
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  none: false
190
190
  requirements:
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  segments:
195
195
  - 0
196
- hash: -194371314246007915
196
+ hash: -3855103968202962501
197
197
  requirements: []
198
198
  rubyforge_project:
199
199
  rubygems_version: 1.8.21