Skip to content

Commit

Permalink
Added spec support for packages
Browse files Browse the repository at this point in the history
  • Loading branch information
xea committed Feb 23, 2016
1 parent b9d4997 commit 90f2cc3
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
-I ./lib/
-I ./packages/
-I ./packages/*/spec/
--color
--require spec_helper
spec
packages/*/spec/
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'rspec/core/rake_task'

desc "test ALL the things"
RSpec::Core::RakeTask.new(:spec) do |t, task_args|
ENV["LC_ALL"] = "en_US.UTF-8"
t.rspec_opts = "-I ./packages/"
t.pattern = "{spec,packages}/**/*_spec.rb"
end
32 changes: 27 additions & 5 deletions packages/ar/ar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
require 'activerecord-jdbcpostgresql-adapter' if defined? JRUBY_VERSION
require 'safe_attributes/base'
require 'core/service'

class ActiveRecordService < Service

Expand All @@ -21,14 +22,35 @@ def register_namespace(namespace_id, namespace)
end

def unregister_namespace(namespace_id)
ns = @namespaces[namespace_id]

unless ns.nil?
# TODO disconnect from the DB
end

@namespaces[namespace_id] = nil
end

def namespace(namespace_id)
ActiveRecordNameSpaceProxy.new
end

end

=begin
class SandboxDB < ActiveRecord::Base
class ActiveRecordNameSpaceProxy
def lookup(model_id)
nil
end
end

module ActiveRecordNameSpace

self.abstract_class = true
establish_connection "sandbox"
def registered_models
# Example: [ { class_name: ExampleModel } ]
[]
end

def lookup(model_id)
nil
end
end
=end
25 changes: 25 additions & 0 deletions packages/ar/spec/ar_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'ar/ar'

RSpec.describe ActiveRecordService do

class TestNamespace

include ActiveRecordNameSpace

def lookup(model_id)
end
end

context "#lookup" do

it "should allow accessing registered models" do

ar = ActiveRecordService.new


end
end
end

RSpec.describe ActiveRecordNameSpaceProxy do
end
2 changes: 2 additions & 0 deletions packages/health/health.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'core/service'
require 'console/mode'

class HealthChecker < Service

Expand Down
11 changes: 11 additions & 0 deletions packages/health/spec/health_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'health/health'

RSpec.describe HealthChecker do

context "#lofasz" do
it "should lofasz" do
expect(1).to eq(1)
end
end

end

0 comments on commit 90f2cc3

Please sign in to comment.