Skip to content

Commit 90f2cc3

Browse files
committed
Added spec support for packages
1 parent b9d4997 commit 90f2cc3

File tree

6 files changed

+78
-5
lines changed

6 files changed

+78
-5
lines changed

Diff for: .rspec

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
-I ./lib/
2+
-I ./packages/
3+
-I ./packages/*/spec/
14
--color
25
--require spec_helper
6+
spec
7+
packages/*/spec/

Diff for: Rakefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'rspec/core/rake_task'
2+
3+
desc "test ALL the things"
4+
RSpec::Core::RakeTask.new(:spec) do |t, task_args|
5+
ENV["LC_ALL"] = "en_US.UTF-8"
6+
t.rspec_opts = "-I ./packages/"
7+
t.pattern = "{spec,packages}/**/*_spec.rb"
8+
end

Diff for: packages/ar/ar.rb

+27-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
33
require 'activerecord-jdbcpostgresql-adapter' if defined? JRUBY_VERSION
44
require 'safe_attributes/base'
5+
require 'core/service'
56

67
class ActiveRecordService < Service
78

@@ -21,14 +22,35 @@ def register_namespace(namespace_id, namespace)
2122
end
2223

2324
def unregister_namespace(namespace_id)
25+
ns = @namespaces[namespace_id]
26+
27+
unless ns.nil?
28+
# TODO disconnect from the DB
29+
end
30+
2431
@namespaces[namespace_id] = nil
2532
end
33+
34+
def namespace(namespace_id)
35+
ActiveRecordNameSpaceProxy.new
36+
end
37+
2638
end
2739

28-
=begin
29-
class SandboxDB < ActiveRecord::Base
40+
class ActiveRecordNameSpaceProxy
41+
def lookup(model_id)
42+
nil
43+
end
44+
end
45+
46+
module ActiveRecordNameSpace
3047

31-
self.abstract_class = true
32-
establish_connection "sandbox"
48+
def registered_models
49+
# Example: [ { class_name: ExampleModel } ]
50+
[]
51+
end
52+
53+
def lookup(model_id)
54+
nil
55+
end
3356
end
34-
=end

Diff for: packages/ar/spec/ar_spec.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'ar/ar'
2+
3+
RSpec.describe ActiveRecordService do
4+
5+
class TestNamespace
6+
7+
include ActiveRecordNameSpace
8+
9+
def lookup(model_id)
10+
end
11+
end
12+
13+
context "#lookup" do
14+
15+
it "should allow accessing registered models" do
16+
17+
ar = ActiveRecordService.new
18+
19+
20+
end
21+
end
22+
end
23+
24+
RSpec.describe ActiveRecordNameSpaceProxy do
25+
end

Diff for: packages/health/health.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'core/service'
2+
require 'console/mode'
13

24
class HealthChecker < Service
35

Diff for: packages/health/spec/health_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'health/health'
2+
3+
RSpec.describe HealthChecker do
4+
5+
context "#lofasz" do
6+
it "should lofasz" do
7+
expect(1).to eq(1)
8+
end
9+
end
10+
11+
end

0 commit comments

Comments
 (0)