Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

REQUEST_DEBUG=true bundle exec rspec ...

Any tests that use ey_services_api can now do that to see debug output of requests.
Also, if a test helper defines "extra_middlewares", they will be inserted into all rack apps involved in the integration test.
  • Loading branch information...
commit 71d5a0e761f8e13f845c697985554bca55c38a24 1 parent 52f7743
@jacobo jacobo authored
View
1  fake/ey_services_fake.gemspec
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
s.add_dependency "sinatra"
s.add_dependency "cubbyhole", ">= 0.2.0"
+ s.add_dependency "request_visualizer"
end
View
47 fake/lib/ey_services_fake/mock_backend.rb
@@ -21,6 +21,43 @@ def self.setup!(actors = {})
new(actors)
end
+ def app_for(actor_name)
+ this = self
+ @apps ||= {}
+ @apps[actor_name] ||= Rack::Builder.new do
+ this.actors.each do |k, actor|
+ if actor.respond_to?(:extra_middlewares)
+ self.instance_eval(&actor.extra_middlewares)
+ end
+ end
+ if ENV["REQUEST_DEBUG"]
+ require 'request_visualizer'
+ use RequestVisualizer do |str|
+ found = str
+ this.actors.each do |k, actor|
+ if str.match(actor.base_url)
+ found = k.to_s
+ end
+ end
+ found
+ end
+ end
+ run this.actors[actor_name].app
+ end
+ end
+
+ def app
+ this = self
+ @app ||= Rack::Builder.new do
+ this.actors.each do |k, actor|
+ map "#{actor.base_url}/" do
+ run this.app_for(k)
+ end
+ end
+ end
+ end
+
+ attr_reader :actors
def initialize(actors)
@actors = actors
end
@@ -38,8 +75,8 @@ def reset!
def awsm
awsm_hash = actor(:tresfiestas).find_awsm
unless awsm_hash
- awsm_hash = actor(:tresfiestas).create_awsm(actor(:awsm).base_url, actor(:awsm).app)
- actor(:awsm).setup(awsm_hash[:auth_id], awsm_hash[:auth_key], actor(:tresfiestas).base_url, actor(:tresfiestas).app)
+ awsm_hash = actor(:tresfiestas).create_awsm(actor(:awsm).base_url, app_for(:awsm))
+ actor(:awsm).setup(awsm_hash[:auth_id], awsm_hash[:auth_key], actor(:tresfiestas).base_url, app_for(:tresfiestas))
end
awsm_hash
end
@@ -47,13 +84,13 @@ def awsm
def partner
partner_hash = actor(:tresfiestas).find_partner(sso_user)
unless partner_hash
- partner_hash = actor(:tresfiestas).create_partner(sso_user, actor(:service_provider).base_url, actor(:service_provider).app)
+ partner_hash = actor(:tresfiestas).create_partner(sso_user, actor(:service_provider).base_url, app_for(:service_provider))
@actors.values.each do |actor|
if actor.respond_to?(:service_provider_setup)
- actor.service_provider_setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:service_provider).base_url, actor(:service_provider).app)
+ actor.service_provider_setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:service_provider).base_url, app_for(:service_provider))
end
end
- actor(:service_provider).setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:tresfiestas).base_url, actor(:tresfiestas).app)
+ actor(:service_provider).setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:tresfiestas).base_url, app_for(:tresfiestas))
end
partner_hash
end
View
4 fake/lib/ey_services_fake/reacharound_awsm.rb
@@ -12,6 +12,10 @@ class Application < Sinatra::Base
{}.to_json
end
+ get '/dashboard' do
+ "Hello this is fake AWSM dashboard"
+ end
+
end
def app
View
1  lib/ey_services_api.rb
@@ -26,6 +26,7 @@ def self.connection
def self.enable_mock!(service_provider, tresfiestas = nil, awsm = nil)
unless @mock_backend
+ #TODO: rescue load error and log the need to include ey_services_fake gem
require "ey_services_fake/mock_backend"
@mock_backend = EyServicesFake::MockBackend.setup!(
:awsm => awsm,
View
1  lib/ey_services_api/service.rb
@@ -1,3 +1,4 @@
+#TODO: list services should populate the URL of this object
module EY
module ServicesAPI
class Service < APIStruct.new(:name, :label, :description, :home_url, :service_accounts_url, :terms_and_conditions_url, :vars)
Please sign in to comment.
Something went wrong with that request. Please try again.