torquespec 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,19 +28,15 @@ else
28
28
  end
29
29
 
30
30
  config.before(:all) do
31
- if self.class.respond_to?( :deploy_paths )
32
- self.class.deploy_paths.each do |path|
33
- Thread.current[:app_server].deploy(path)
34
- end
35
- end
31
+ self.class.deploy_paths.each do |path|
32
+ Thread.current[:app_server].deploy(path)
33
+ end if self.class.respond_to?( :deploy_paths )
36
34
  end
37
35
 
38
36
  config.after(:all) do
39
- if self.class.respond_to?( :deploy_paths )
40
- self.class.deploy_paths.each do |path|
41
- Thread.current[:app_server].undeploy(path)
42
- end
43
- end
37
+ self.class.deploy_paths.each do |path|
38
+ Thread.current[:app_server].undeploy(path)
39
+ end if self.class.respond_to?( :deploy_paths )
44
40
  end
45
41
 
46
42
  config.after(:suite) do
@@ -8,7 +8,7 @@ module TorqueSpec
8
8
  def initialize(opts={})
9
9
  puts "JC: create daemon opts=#{opts.inspect}"
10
10
  dir = opts['pwd'].to_s
11
- raise "The 'pwd' option must contain a valid directory name" unless dir.any? && File.exist?(dir)
11
+ raise "The 'pwd' option must contain a valid directory name" if dir.empty? || !File.exist?(dir)
12
12
  Dir.chdir( dir ) do
13
13
  RSpec::Core::Runner.disable_autorun! # avoid a bunch of at_exit finalizer errors
14
14
  @options = RSpec::Core::ConfigurationOptions.new( opts['argv'].to_a )
@@ -5,12 +5,13 @@ require 'yaml'
5
5
  module TorqueSpec
6
6
 
7
7
  class DeploymentDescriptor
8
- def initialize(descriptor, name)
8
+ def initialize(descriptor, name, daemonify = false)
9
9
  @descriptor = descriptor
10
10
  @path = Pathname.new( name.gsub(/\W/,'_') + "-knob.yml" ).expand_path( TorqueSpec.knob_root )
11
+ @daemonify = daemonify
11
12
  end
12
13
  def path
13
- hash || filename || heredoc
14
+ daemonify( hash || filename || heredoc )
14
15
  end
15
16
  def hash
16
17
  if @descriptor.is_a? Hash
@@ -35,6 +36,25 @@ module TorqueSpec
35
36
  def stringify_keys(x)
36
37
  x.is_a?(Hash) ? x.inject({}) {|h,(k,v)| h[k.to_s] = stringify_keys(v); h} : x
37
38
  end
39
+
40
+ def daemonify( path )
41
+ if @daemonify
42
+ yaml = YAML.load_file( path )
43
+ if yaml.is_a? Hash
44
+ yaml['services'] ||= {}
45
+ yaml['services'].update( 'TorqueSpec::Daemon' => { 'argv' => TorqueSpec.argv, 'pwd' => Dir.pwd } )
46
+ yaml['environment'] ||= {}
47
+ env = { 'RUBYLIB' => TorqueSpec.rubylib }
48
+ yaml['environment'].update(env) {|k,oldval,newval| "#{oldval}:#{newval}"}
49
+ File.open( path, 'w' ) do |file|
50
+ YAML.dump( yaml, file )
51
+ end
52
+ else
53
+ $stderr.puts "WARN: Unable to decorate your deployment descriptor with TorqueSpec::Daemon"
54
+ end
55
+ end
56
+ path
57
+ end
38
58
  end
39
59
 
40
60
  end
@@ -11,7 +11,10 @@ module TorqueSpec
11
11
  descriptors << block.call if block
12
12
  i = descriptors.size > 1 ? 0 : nil
13
13
  @deploy_paths = descriptors.map do |descriptor|
14
- DeploymentDescriptor.new(descriptor, "#{self.display_name}#{i&&i-=1}").path
14
+ DeploymentDescriptor.new(descriptor,
15
+ "#{self.display_name}#{i&&i-=1}",
16
+ self.is_a?(TorqueSpec::Daemon::Client)
17
+ ).path
15
18
  end
16
19
  end
17
20
  end
@@ -39,7 +42,7 @@ module TorqueSpec
39
42
 
40
43
  # We must initialize the daemon with the same params as passed to the client
41
44
  def self.argv
42
- ( ARGV.empty? ? [ 'spec' ] : ARGV ).inspect
45
+ ( ARGV.empty? ? [ 'spec' ] : ARGV )
43
46
  end
44
47
  end
45
48
 
@@ -1,3 +1,3 @@
1
1
  module TorqueSpec
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -5,12 +5,6 @@ remote_describe "in-container tests" do
5
5
  deploy <<-END.gsub(/^ {4}/,'')
6
6
  application:
7
7
  root: #{File.dirname(__FILE__)}/../apps/simple
8
- services:
9
- TorqueSpec::Daemon:
10
- argv: #{TorqueSpec.argv}
11
- pwd: #{Dir.pwd}
12
- environment:
13
- RUBYLIB: #{TorqueSpec.rubylib}
14
8
  END
15
9
 
16
10
  it "should work" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquespec
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 7
10
- version: 0.2.7
9
+ - 8
10
+ version: 0.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jim Crossley