torquespec 0.2.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -65,11 +65,29 @@ module TorqueSpec
65
65
  DRb.stop_service
66
66
  end
67
67
  end
68
+
69
+ def deploy_paths
70
+ descriptor = <<-END.gsub(/^ {10}/,'')
71
+ application:
72
+ root: #{TorqueSpec.app_root}
73
+ ruby:
74
+ version: #{RUBY_VERSION[0,3]}
75
+ services:
76
+ TorqueSpec::Daemon:
77
+ argv: #{TorqueSpec.argv}
78
+ pwd: #{Dir.pwd}
79
+ environment:
80
+ RUBYLIB: #{TorqueSpec.rubylib}
81
+ END
82
+ [ DeploymentDescriptor.new(descriptor, display_name).path ]
83
+ end
68
84
 
69
85
  end
70
86
  end
71
87
  end
72
88
 
89
+ # Reporters really only care about metadata, which is good since not
90
+ # much else is serializable.
73
91
  module RSpec
74
92
  module Core
75
93
  class Example
@@ -93,3 +111,18 @@ class Proc
93
111
  def marshal_load *args
94
112
  end
95
113
  end
114
+
115
+ # We want any Java exceptions tossed on the server to be passed back
116
+ # to the Reporter on the client, and NativeExceptions have no
117
+ # allocator, hence they're not marshalable.
118
+ class NativeException
119
+ def _dump(*)
120
+ Marshal.dump( [cause, backtrace] )
121
+ end
122
+ def self._load(str)
123
+ exception, trace = Marshal.load(str)
124
+ meta = class << exception; self; end
125
+ meta.send(:define_method, :backtrace) { trace }
126
+ exception
127
+ end
128
+ end
@@ -9,6 +9,7 @@ module TorqueSpec
9
9
  @descriptor = descriptor
10
10
  @path = Pathname.new( name.gsub(/\W/,'_') + "-knob.yml" ).expand_path( TorqueSpec.knob_root )
11
11
  @daemonify = daemonify
12
+ FileUtils.mkdir_p(TorqueSpec.knob_root) unless File.exist?(TorqueSpec.knob_root)
12
13
  end
13
14
  def path
14
15
  daemonify( hash || filename || heredoc )
@@ -7,7 +7,6 @@ module TorqueSpec
7
7
  metaclass = class << self; self; end
8
8
  metaclass.send(:define_method, :deploy_paths) do
9
9
  return @deploy_paths if @deploy_paths
10
- FileUtils.mkdir_p(TorqueSpec.knob_root) unless File.exist?(TorqueSpec.knob_root)
11
10
  descriptors << block.call if block
12
11
  i = descriptors.size > 1 ? 0 : nil
13
12
  @deploy_paths = descriptors.map do |descriptor|
@@ -44,6 +43,27 @@ module TorqueSpec
44
43
  def self.argv
45
44
  ( ARGV.empty? ? [ 'spec' ] : ARGV )
46
45
  end
46
+
47
+ # The location of an empty app used for deploying the daemon
48
+ def self.app_root
49
+ File.expand_path( File.join( File.dirname(__FILE__), "../..", "apps", "empty" ) )
50
+ end
51
+
52
+ # Whether we're running locally or in the daemon
53
+ def self.remote?
54
+ !!ENV['TORQUEBOX_APP_NAME']
55
+ end
56
+
57
+ # Guard those things you only want to do in the container
58
+ def self.remote
59
+ yield if remote?
60
+ end
61
+
62
+ # Guard those things you only want done locally
63
+ def self.local
64
+ yield unless remote?
65
+ end
66
+
47
67
  end
48
68
 
49
69
  # Default TorqueSpec options
@@ -1,3 +1,3 @@
1
1
  module TorqueSpec
2
- VERSION = "0.2.8"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,14 @@
1
+ require 'torquespec'
2
+
3
+ remote_describe "in-container tests without a deploy call" do
4
+
5
+ it "should work" do
6
+ require 'torquebox/messaging/queue'
7
+ queue = TorqueBox::Messaging::Queue.start('/queues/foo', :jndi => "")
8
+ queue.publish('bar')
9
+ queue.receive.should == 'bar'
10
+ queue.stop
11
+ end
12
+
13
+ end
14
+
@@ -0,0 +1,20 @@
1
+ require 'torquespec'
2
+
3
+ remote_describe "remote guard test" do
4
+
5
+ it "should work" do
6
+ TorqueSpec.remote { true }.should be_true
7
+ TorqueSpec.local { true }.should be_false
8
+ end
9
+
10
+ end
11
+
12
+ describe "local guard test" do
13
+
14
+ it "should work" do
15
+ TorqueSpec.remote { true }.should be_false
16
+ TorqueSpec.local { true }.should be_true
17
+ end
18
+
19
+ end
20
+
data/spec/remote_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'torquespec'
2
+ require 'open-uri'
2
3
 
3
4
  remote_describe "in-container tests" do
4
5
 
@@ -7,6 +8,11 @@ remote_describe "in-container tests" do
7
8
  root: #{File.dirname(__FILE__)}/../apps/simple
8
9
  END
9
10
 
11
+ it "should still greet the world" do
12
+ response = open("http://localhost:8080") {|f| f.read}
13
+ response.strip.should == "Hello World!"
14
+ end
15
+
10
16
  it "should work" do
11
17
  require 'torquebox/messaging/queue'
12
18
  queue = TorqueBox::Messaging::Queue.start('/queues/foo', :jndi => "")
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: 7
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 8
10
- version: 0.2.8
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jim Crossley
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-09 00:00:00 -04:00
19
+ date: 2011-06-10 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -60,6 +60,7 @@ files:
60
60
  - Gemfile
61
61
  - README.md
62
62
  - Rakefile
63
+ - apps/empty/torquebox.yml
63
64
  - apps/node-info.war
64
65
  - apps/simple.knob
65
66
  - apps/simple/config.ru
@@ -73,6 +74,8 @@ files:
73
74
  - lib/torquespec/server.rb
74
75
  - lib/torquespec/torquespec.rb
75
76
  - lib/torquespec/version.rb
77
+ - spec/empty_spec.rb
78
+ - spec/guard_spec.rb
76
79
  - spec/hello_world_spec.rb
77
80
  - spec/remote_spec.rb
78
81
  - torquespec.gemspec
@@ -111,5 +114,7 @@ signing_key:
111
114
  specification_version: 3
112
115
  summary: Deploy TorqueBox knobs to a running JBoss instance
113
116
  test_files:
117
+ - spec/empty_spec.rb
118
+ - spec/guard_spec.rb
114
119
  - spec/hello_world_spec.rb
115
120
  - spec/remote_spec.rb