Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleanup specs and get them running again.

  • Loading branch information...
commit a679dfc47ce9055176532a917b9b25ea0f4c4a78 1 parent fc36965
@tobias tobias authored
View
6 backstage.rb
@@ -46,7 +46,11 @@ module Backstage
TORQUEBOX_VERSION = File.readlines( File.join( File.dirname( __FILE__ ), 'TORQUEBOX_VERSION' ) ).first.strip
class Application < Sinatra::Base
- use TorqueBox::Session::ServletStore
+ if ENV['TORQUEBOX_APP_NAME']
+ use TorqueBox::Session::ServletStore
+ else
+ enable :sessions
+ end
use Rack::Accept
use Rack::CommonLogger, Backstage.logger
use Rack::Webconsole
View
5 lib/groups/models/group.rb
@@ -40,6 +40,11 @@ def self.to_hash_attributes
:view]
end
+ # this shadows Object#open
+ def open
+ mbean[:open]
+ end
+
def protocols
mbean = JMX::MBeanServer.new
cluster = self.cluster_name
View
16 spec/api_spec.rb
@@ -16,12 +16,18 @@
require 'spec_helper'
+def parse_json_response
+ JSON.parse(last_response.body, :symbolize_names => true)
+rescue Exception => e
+ puts "WARN: json parsing failed"
+end
+
module Backstage
describe '/api' do
before(:each) do
get '/api'
- @response = JSON.parse(last_response.body, :symbolize_names => true)
+ @response = parse_json_response
end
it "should work" do
@@ -47,7 +53,7 @@ module Backstage
before(:each) do
ENV['REQUIRE_AUTHENTICATION'] = 'true'
@authenticator = mock(:authenticator)
- TorqueBox::Authentication.stub(:default).and_return(@authenticator)
+ TorqueBox::Authentication.stub(:[]).and_return(@authenticator)
end
it "api should work with authentication" do
@@ -85,7 +91,7 @@ module Backstage
before(:each) do
klass.stub(:all).and_return([resource_with_mock_mbean(klass)])
get "/#{resource.pluralize}", :format => 'json'
- @response = JSON.parse(last_response.body, :symbolize_names => true)
+ @response = parse_json_response
end
it "should work" do
@@ -113,7 +119,7 @@ module Backstage
before(:each) do
klass.stub(:find).and_return(resource_with_mock_mbean(klass))
get "/#{resource}/somename", :format => 'json'
- @response = JSON.parse(last_response.body, :symbolize_names => true)
+ @response = parse_json_response
end
it "should work" do
@@ -137,7 +143,7 @@ module Backstage
before(:each) do
Queue.stub(:find).and_return(resource_with_mock_mbean(Queue))
get "/queue/somename", :format => 'json'
- @response = JSON.parse(last_response.body, :symbolize_names => true)
+ @response = parse_json_response
end
it "should include a link to its messages" do
View
2  spec/auth_spec.rb
@@ -25,7 +25,7 @@ module Backstage
TorqueBox::Authentication.stub('[]').with('backstage').and_return(@authenticator)
end
- it "allow access with proper credentials" do
+ it "should allow access with proper credentials" do
@authenticator.should_receive(:authenticate).with('blah', 'pw').and_return(true)
authorize 'blah', 'pw'
get '/apps'
View
3  spec/spec_helper.rb
@@ -26,10 +26,11 @@ def app
def resource_with_mock_mbean(klass)
mock_mbean = mock('mbean')
+
def mock_mbean.method_missing(method, *args, &block)
method.to_s
end
-
+
if klass == Backstage::Log
resource = Backstage::Log.new(File.join( TEST_ROOT, 'data', 'railsapp', 'log', 'production.log' ))
else
Please sign in to comment.
Something went wrong with that request. Please try again.