remove jank, support sinatra better

now that we depend on active_support, we can remove some jank. While we're at it, remove rails-specific code
This commit is contained in:
Neil Matatall 2013-01-24 23:56:39 -08:00
Родитель 4d40200354
Коммит 3f04883d51
3 изменённых файлов: 4 добавлений и 38 удалений

Просмотреть файл

@ -31,7 +31,7 @@ class ContentSecurityPolicyController < ActionController::Base
head :ok head :ok
rescue StandardError => e rescue StandardError => e
Rails.logger.warn "Unable to POST CSP report to #{report_uri} because #{e}" Rails.logger.warn("Unable to POST CSP report to #{report_uri} because #{e}") if defined?(Rails.logger)
head :bad_request head :bad_request
end end

Просмотреть файл

@ -39,6 +39,7 @@ describe ContentSecurityPolicyController do
it "makes a POST request" do it "makes a POST request" do
Net::HTTP.stub(:new).and_return(request) Net::HTTP.stub(:new).and_return(request)
request.should_receive(:request).with(instance_of(::Net::HTTP::Post)) request.should_receive(:request).with(instance_of(::Net::HTTP::Post))
params.stub(:to_json)
subject.scribe subject.scribe
end end
@ -60,7 +61,7 @@ describe ContentSecurityPolicyController do
end end
it "logs errors when it cannot forward the CSP report" do it "logs errors when it cannot forward the CSP report" do
class Rails; end class Rails; def logger; end; end
logger = double(:repond_to? => true) logger = double(:repond_to? => true)
Rails.stub(:logger).and_return(logger) Rails.stub(:logger).and_return(logger)

Просмотреть файл

@ -1,5 +1,6 @@
require 'rubygems' require 'rubygems'
require 'spork' require 'spork'
require 'active_support'
unless Spork.using_spork? unless Spork.using_spork?
require 'simplecov' require 'simplecov'
@ -11,42 +12,6 @@ end
Spork.prefork do Spork.prefork do
require 'pry' require 'pry'
require 'rspec' require 'rspec'
# Need these features from Rails, stubbing various features from various versions
class ApplicationController; end
module ActionController
module Routing
class Routes
def self.draw; end
end
module RouteSet; class Mapper; end; end
end
end
module ActiveSupport
class JSON
def self.encode obj, options = nil; end
end
module Dependencies
class << self
attr_accessor :autoload_paths
autoload_paths = []
end
end
end
class Object
def try(*a, &b); end
def to_json(options = nil); end
end
class NilClass
def try(*args); end
end
end end
Spork.each_run do Spork.each_run do