methodmissing-scrooge 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. data/README.textile +262 -0
  2. data/lib/scrooge/core/string.rb +29 -0
  3. data/lib/scrooge/core/symbol.rb +21 -0
  4. data/lib/scrooge/core/thread.rb +26 -0
  5. data/lib/scrooge/framework/base.rb +304 -0
  6. data/lib/scrooge/framework/rails.rb +107 -0
  7. data/lib/scrooge/middleware/tracker.rb +47 -0
  8. data/lib/scrooge/orm/active_record.rb +143 -0
  9. data/lib/scrooge/orm/base.rb +102 -0
  10. data/lib/scrooge/profile.rb +204 -0
  11. data/lib/scrooge/storage/base.rb +47 -0
  12. data/lib/scrooge/storage/memory.rb +25 -0
  13. data/lib/scrooge/tracker/app.rb +101 -0
  14. data/lib/scrooge/tracker/base.rb +56 -0
  15. data/lib/scrooge/tracker/model.rb +90 -0
  16. data/lib/scrooge/tracker/resource.rb +201 -0
  17. data/lib/scrooge.rb +62 -0
  18. data/spec/fixtures/config/scrooge/scopes/1234567891/scope.yml +2 -0
  19. data/spec/fixtures/config/scrooge.yml +12 -0
  20. data/spec/helpers/framework/rails/cache.rb +25 -0
  21. data/spec/spec_helper.rb +51 -0
  22. data/spec/units/scrooge/core/string_spec.rb +21 -0
  23. data/spec/units/scrooge/core/symbol_spec.rb +13 -0
  24. data/spec/units/scrooge/core/thread_spec.rb +15 -0
  25. data/spec/units/scrooge/framework/base_spec.rb +154 -0
  26. data/spec/units/scrooge/framework/rails_spec.rb +40 -0
  27. data/spec/units/scrooge/orm/base_spec.rb +61 -0
  28. data/spec/units/scrooge/profile_spec.rb +73 -0
  29. data/spec/units/scrooge/storage/base_spec.rb +35 -0
  30. data/spec/units/scrooge/storage/memory_spec.rb +20 -0
  31. data/spec/units/scrooge/tracker/app_spec.rb +62 -0
  32. data/spec/units/scrooge/tracker/base_spec.rb +21 -0
  33. data/spec/units/scrooge/tracker/model_spec.rb +50 -0
  34. data/spec/units/scrooge/tracker/resource_spec.rb +83 -0
  35. data/spec/units/scrooge_spec.rb +13 -0
  36. metadata +110 -0
@@ -0,0 +1,154 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "Scrooge::Framework::Base singleton" do
4
+
5
+ before(:each) do
6
+ @base = Scrooge::Framework::Base
7
+ end
8
+
9
+ it "should be able to track all available frameworks" do
10
+ @base.frameworks.should include( Scrooge::Framework::Rails )
11
+ end
12
+
13
+ it "should be able to infer the current active framework" do
14
+ lambda{ @base.which_framework? }.should raise_error( Scrooge::Framework::Base::NoSupportedFrameworks )
15
+ with_rails do
16
+ @base.which_framework?().should equal( Scrooge::Framework::Rails )
17
+ end
18
+ end
19
+
20
+ it "should be able to instantiate the active framework" do
21
+ with_rails do
22
+ @base.instantiate.class.should equal( Scrooge::Framework::Rails )
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ describe Scrooge::Framework::Base do
29
+
30
+ before(:each) do
31
+ @base = Scrooge::Framework::Base.new
32
+ end
33
+
34
+ it "should be able to yield it's environment" do
35
+ lambda{ @base.environment }.should raise_error( Scrooge::Framework::Base::NotImplemented )
36
+ end
37
+
38
+ it "should be able to yield it's root path" do
39
+ lambda{ @base.root }.should raise_error( Scrooge::Framework::Base::NotImplemented )
40
+ end
41
+
42
+ it "should be able to setup a resource tracker instance from given status, headers and body" do
43
+ lambda{ @base.resource( {} ) }.should raise_error( Scrooge::Framework::Base::NotImplemented )
44
+ end
45
+
46
+ it "should be able to yield it's temp path" do
47
+ lambda{ @base.tmp }.should raise_error( Scrooge::Framework::Base::NotImplemented )
48
+ end
49
+
50
+ it "should be able to yield it's configuration path" do
51
+ lambda{ @base.config }.should raise_error( Scrooge::Framework::Base::NotImplemented )
52
+ end
53
+
54
+ it "should be able to yield it's logger" do
55
+ lambda{ @base.logger }.should raise_error( Scrooge::Framework::Base::NotImplemented )
56
+ end
57
+
58
+ it "should be able to read from the framework's cache store" do
59
+ lambda{ @base.read_cache( 'storage' ) }.should raise_error( Scrooge::Framework::Base::NotImplemented )
60
+ end
61
+
62
+ it "should be able to write to the framework's cache store" do
63
+ lambda{ @base.write_cache( 'storage', 'payload' ) }.should raise_error( Scrooge::Framework::Base::NotImplemented )
64
+ end
65
+
66
+ it "should be able to yield a scopes path" do
67
+ with_rails do
68
+ @base.stub!(:config).and_return( CONFIG )
69
+ @base.scopes_path.should match( /config\/scrooge\/scopes/ )
70
+ end
71
+ end
72
+
73
+ it "should be able to infer all available scopes" do
74
+ with_rails do
75
+ @base.stub!(:config).and_return( CONFIG )
76
+ @base.send( :ensure_scopes_path )
77
+ @signature = Time.now.to_i.to_s
78
+ FileUtils.mkdir_p( File.join( @base.scopes_path, @signature ) )
79
+ @base.scopes.should include( @signature )
80
+ end
81
+ end
82
+
83
+ it "should be able to determine if there's any previously persisted scopes" do
84
+ with_rails do
85
+ @base.stub!(:config).and_return( CONFIG )
86
+ @base.send( :ensure_scopes_path )
87
+ @base.scopes?().should eql( true )
88
+ end
89
+ end
90
+
91
+ it "should be able to infer the path to a given scope" do
92
+ with_rails do
93
+ @base.stub!(:config).and_return( CONFIG )
94
+ @base.scope_path( '1234567891' ).should match( /scopes\/1234567891/ )
95
+ end
96
+ end
97
+
98
+ it "should be able to determine if a given scope is defined" do
99
+ with_rails do
100
+ @base.stub!(:config).and_return( CONFIG )
101
+ @base.scope?( 9876543211 ).should equal( false )
102
+ end
103
+ end
104
+
105
+ it "should be able to dump the current application tracker to a scope" do
106
+ with_rails do
107
+ @base.stub!(:config).and_return( CONFIG )
108
+ ::Rails.stub!(:env).and_return( "test" )
109
+ lambda{ @base.to_scope! }.should change( @base.scopes, :size )
110
+ end
111
+ end
112
+
113
+ it "should be able to restore a previous scope to the current app tracker" do
114
+ with_rails do
115
+ @base.stub!(:config).and_return( CONFIG )
116
+ ::Rails.stub!(:env).and_return( "test" )
117
+ @scope = @base.to_scope!
118
+ lambda{ @base.from_scope!( @scope ) }.should change( Scrooge::Base.profile.tracker, :object_id )
119
+ end
120
+ end
121
+
122
+ it "should be able to validate previously saved scope signatures" do
123
+ @base.stub!(:scope?).and_return(false)
124
+ lambda{ @base.from_scope!( 'undefined' ) }.should raise_error( Scrooge::Framework::Base::InvalidScopeSignature )
125
+ end
126
+
127
+ it "should be able to interact with the framework's Rack middleware" do
128
+ lambda{ @base.middleware }.should raise_error( Scrooge::Framework::Base::NotImplemented )
129
+ end
130
+
131
+ it "should be able to install tracking middleware" do
132
+ lambda{ @base.install_tracking_middleware() }.should raise_error( Scrooge::Framework::Base::NotImplemented )
133
+ end
134
+
135
+ it "should be able to install scoping middleware" do
136
+ lambda{ @base.install_scope_middleware( 'tracker' ) }.should raise_error( Scrooge::Framework::Base::NotImplemented )
137
+ end
138
+
139
+ it "should be able to register code blocks to run after the framework has been initialized" do
140
+ lambda{ @base.initialized() }.should raise_error( Scrooge::Framework::Base::NotImplemented )
141
+ end
142
+
143
+ it "should be able to map a resource instance to a controller constant" do
144
+ lambda{ @base.controller( 'resource' ) }.should raise_error( Scrooge::Framework::Base::NotImplemented )
145
+ end
146
+
147
+ it "should be able to return a full path to the scrooge configuration file" do
148
+ with_rails do
149
+ @base.stub!(:config).and_return( CONFIG )
150
+ @base.configuration_file.should match( /scrooge.yml/ )
151
+ end
152
+ end
153
+
154
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Scrooge::Framework::Rails do
4
+
5
+ before(:each) do
6
+ @framework = Scrooge::Framework::Rails.new
7
+ end
8
+
9
+ it "should be able to yield it's current environment" do
10
+ with_rails do
11
+ @framework.environment.should eql( 'test' )
12
+ end
13
+ end
14
+
15
+ it "should be able to yield a logger" do
16
+ with_rails do
17
+ ::Rails.stub!(:logger).and_return('')
18
+ ( @framework.logger << 'entry' ).should eql( 'entry' )
19
+ end
20
+ end
21
+
22
+ it "should be able to yield it's configuration" do
23
+ with_rails do
24
+ @framework.config.should match( /scrooge\/spec\/config/ )
25
+ end
26
+ end
27
+
28
+ it "should be able to yield it's root path" do
29
+ with_rails do
30
+ @framework.root.should match( /scrooge\/spec/ )
31
+ end
32
+ end
33
+
34
+ it "should be able to yield it's tmp path" do
35
+ with_rails do
36
+ @framework.tmp.should match( /scrooge\/spec\/tmp/ )
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "Scrooge::Orm::Base singleton" do
4
+
5
+ before(:each) do
6
+ @base = Scrooge::Orm::Base
7
+ end
8
+
9
+ it "should be able to instantiate a supported ORM from a given ORM signature" do
10
+ @base.instantiate( :active_record ).class.should equal(Scrooge::Orm::ActiveRecord)
11
+ end
12
+
13
+ end
14
+
15
+ describe Scrooge::Orm::Base do
16
+
17
+ before(:each) do
18
+ @tracker = mock('tracker')
19
+ @tracker.stub!(:signature).and_return( 'tracker' )
20
+ @base = Scrooge::Orm::Base.new
21
+ end
22
+
23
+ it "should be able to scope to a given resource tracker" do
24
+ lambda{ @base.scope_to( 'resource_tracker_instance' ) }.should raise_error( Scrooge::Orm::Base::NotImplemented )
25
+ end
26
+
27
+ it "should be able to generate a name for a given model" do
28
+ lambda{ @base.name( 'model' ) }.should raise_error( Scrooge::Orm::Base::NotImplemented )
29
+ end
30
+
31
+ it "should be able to generate a table name for a given model" do
32
+ lambda{ @base.table_name( 'model' ) }.should raise_error( Scrooge::Orm::Base::NotImplemented )
33
+ end
34
+
35
+ it "should be able to generate a primary key for a given model" do
36
+ lambda{ @base.primary_key( 'model' ) }.should raise_error( Scrooge::Orm::Base::NotImplemented )
37
+ end
38
+
39
+ it "should be able to generate a per resource scope method" do
40
+ @base.resource_scope_method( @tracker ).should eql( :scope_to_tracker )
41
+ end
42
+
43
+ it "should be able to determine if a given scope method has already been defined" do
44
+ @base.resource_scope_method?( @tracker, @tracker.class ).should equal( false )
45
+ end
46
+
47
+ it "should be able to infer the current trackable resource" do
48
+ Thread.current[:scrooge_resource] = 'resource'
49
+ @base.resource().should eql( 'resource' )
50
+ Thread.current[:scrooge_resource] = nil
51
+ end
52
+
53
+ it "should be able to determine if it's within the context of a trackable resource" do
54
+ @base.resource?().should eql( false )
55
+ end
56
+
57
+ it "should be able to determine if it should track attribute access" do
58
+ @base.track?().should equal( false )
59
+ end
60
+
61
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "Scrooge::Profile singleton" do
4
+
5
+ before(:each) do
6
+ @profile = Scrooge::Profile
7
+ end
8
+
9
+ it "should be able to instantiate it self from a given config path and environment" do
10
+ @profile.setup( File.join( FIXTURES, 'config', 'scrooge.yml' ), :production ).class.should equal( Scrooge::Profile )
11
+ @profile.setup( File.join( FIXTURES, 'config', 'scrooge.yml' ), :test ).options['orm'].should equal( :active_record )
12
+ end
13
+
14
+ end
15
+
16
+ describe "Scrooge::Profile instance" do
17
+
18
+ before(:each) do
19
+ @profile = Scrooge::Profile.setup( File.join( FIXTURES, 'config', 'scrooge.yml' ), :production )
20
+ @profile.framework.stub!(:scopes).and_return( %w(1234567891) )
21
+ @profile.options = { 'scope' => '1234567891'}
22
+ end
23
+
24
+ it "should return a valid ORM instance" do
25
+ @profile.orm.class.should equal( Scrooge::Orm::ActiveRecord )
26
+ end
27
+
28
+ it "should return a valid storage instance" do
29
+ @profile.storage.class.should equal( Scrooge::Storage::Memory )
30
+ end
31
+
32
+ it "should return a valid framework instance" do
33
+ with_rails do
34
+ @profile.framework.class.should equal( Scrooge::Framework::Rails )
35
+ end
36
+ end
37
+
38
+ it "should return a valid tracker instance" do
39
+ @profile.tracker.class.should equal( Scrooge::Tracker::App )
40
+ end
41
+
42
+ it "should be able to determine if the active profile should track or scope" do
43
+ @profile.track?().should equal( false )
44
+ @profile.scope?().should equal( false )
45
+ end
46
+
47
+ it "should be able to infer the current scope" do
48
+ @profile.scope_to.should eql( "1234567891" )
49
+ end
50
+
51
+ it "should be able to determine if it's enabled" do
52
+ @profile.enabled?().should eql( false )
53
+ end
54
+
55
+ it "should neither track or scope if not enabled" do
56
+ @profile.should_receive(:track!).never
57
+ @profile.should_receive(:scope!).never
58
+ @profile.stub!(:enabled?).and_return(false)
59
+ @profile.track_or_scope!
60
+ end
61
+
62
+ it "should be able to determine if it should raise on missing attributes" do
63
+ @profile.raise_on_missing_attribute?().should equal( false )
64
+ end
65
+
66
+ it "should be able to fallback to scope from the environment if none given" do
67
+ @profile.framework.stub!(:scopes).and_return( [] )
68
+ ENV['scope'] = 'scope_from_env'
69
+ @profile.send(:configure!)
70
+ @profile.scope_to.should eql( 'scope_from_env' )
71
+ end
72
+
73
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "Scrooge::Storage::Base singleton" do
4
+
5
+ before(:each) do
6
+ @base = Scrooge::Storage::Base
7
+ end
8
+
9
+ it "should be able to instantiate a storage backend from a given storage signature" do
10
+ @base.instantiate( :memory ).class.should equal(Scrooge::Storage::Memory)
11
+ end
12
+
13
+ end
14
+
15
+ describe Scrooge::Storage::Base do
16
+
17
+ before(:each) do
18
+ @base = Scrooge::Storage::Base.new
19
+ @tracker = mock('tracker')
20
+ @tracker.stub!(:signature).and_return('signature')
21
+ end
22
+
23
+ it "should be able to read from the storage backend" do
24
+ lambda{ @base.read( @tracker ) }.should raise_error( Scrooge::Storage::Base::NotImplemented )
25
+ end
26
+
27
+ it "should be able to write to the storage backend" do
28
+ lambda{ @base.write( @tracker ) }.should raise_error( Scrooge::Storage::Base::NotImplemented )
29
+ end
30
+
31
+ it "should be able to yield a namespaced storage key" do
32
+ @base.expand_key( "signature" ).should eql( "scrooge_storage/signature" )
33
+ end
34
+
35
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Scrooge::Storage::Memory do
4
+
5
+ before(:each) do
6
+ @memory = Scrooge::Storage::Memory.new
7
+ @tracker = mock('tracker')
8
+ @tracker.stub!(:signature).and_return('signature')
9
+ end
10
+
11
+ it "should be able to write a tracker to memory" do
12
+ lambda { @memory.write( @tracker ) }.should change( @memory.storage, :size ).from(0).to(1)
13
+ end
14
+
15
+ it "should be able to read itself from memory" do
16
+ @memory.write( @tracker )
17
+ @memory.read( @tracker ).should eql( @tracker )
18
+ end
19
+
20
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Scrooge::Tracker::App do
4
+
5
+ before(:each) do
6
+ @app = Scrooge::Tracker::App.new
7
+ @resource = Scrooge::Tracker::Resource.new do |resource|
8
+ resource.controller = 'products'
9
+ resource.action = 'show'
10
+ resource.method = :get
11
+ resource.format = :html
12
+ end
13
+ end
14
+
15
+ it "should be able to determine if any resources has been tracked" do
16
+ @app.any?().should equal( false )
17
+ end
18
+
19
+ it "should initialize with an empty set of resources" do
20
+ @app.resources.should eql( Set.new )
21
+ end
22
+
23
+ it "should be able to accept resources" do
24
+ lambda { @app << 'a_resource' }.should change( @app.resources, :size ).from(0).to(1)
25
+ end
26
+
27
+ it "should be able to dump itself to a serializeable representation" do
28
+ @app << @resource
29
+ with_rails do
30
+ @app.marshal_dump().should eql( [ { "products_show_get" => { :method => :get,
31
+ :models => [],
32
+ :format => :html,
33
+ :action => "show",
34
+ :controller => "products" } } ] )
35
+ end
36
+ end
37
+
38
+ it "should be able to restore itself from a serialized representation" do
39
+ @app << @resource
40
+ with_rails do
41
+ Marshal.load( Marshal.dump( @app ) ).should eql( @app )
42
+ end
43
+ end
44
+
45
+ it "should be able to compare itself to other app trackers" do
46
+ with_rails do
47
+ @app.should eql( @app )
48
+ end
49
+ end
50
+
51
+ it "should implemented a custom Object#inspect" do
52
+ @app << @resource
53
+ @app.inspect().should match( /GET/ )
54
+ @app.inspect().should match( /products/ )
55
+ end
56
+
57
+ it "should be able to determine if a resource's been seen before" do
58
+ @app << @resource
59
+ @app.resource_for( @resource ).should eql( @resource )
60
+ end
61
+
62
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Scrooge::Tracker::Base do
4
+
5
+ before(:each) do
6
+ @base = Scrooge::Tracker::Base.new
7
+ end
8
+
9
+ it "should have a numeric representation" do
10
+ @base.to_i.should equal(0)
11
+ end
12
+
13
+ it "should be able to dump itself to serializeable representation" do
14
+ lambda{ @base.marshal_dump }.should raise_error( Scrooge::Tracker::Base::NotImplemented )
15
+ end
16
+
17
+ it "should be able to restore itself from a serializeable representation" do
18
+ lambda{ @base.marshal_load( '' ) }.should raise_error( Scrooge::Tracker::Base::NotImplemented )
19
+ end
20
+
21
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Scrooge::Tracker::Model do
4
+
5
+ before(:each) do
6
+ @model = Scrooge::Tracker::Model.new( 'Post' )
7
+ @model.stub!(:name).and_return( 'Product' )
8
+ @model.stub!(:table_name).and_return( 'products' )
9
+ @model.stub!(:primary_key).and_return( 'id' )
10
+ end
11
+
12
+ it "should be able to determine if any attributes has been tracked" do
13
+ @model.any?().should equal( false )
14
+ end
15
+
16
+ it "should initialize with an empty set of attributes" do
17
+ @model.attributes.should eql( Set.new )
18
+ end
19
+
20
+ it "should be able to accept attributes" do
21
+ lambda { @model << :name }.should change( @model.attributes, :size ).from(0).to(1)
22
+ end
23
+
24
+ it "should be able to dump itself to a serializeable representation" do
25
+ @model << [:name, :description, :price]
26
+ @model.marshal_dump().should eql( { "Product" => [:price, :description, :name] } )
27
+ end
28
+
29
+ it "should be able to restore itself from a serialized representation" do
30
+ @model << [:name, :description, :price]
31
+ lambda{ @model.marshal_load( { "Product" => [:price] } ) }.should change( @model.attributes, :size ).from(3).to(1)
32
+ end
33
+
34
+ it "should be able to render a attribute selection SQL snippet from it's referenced attributes" do
35
+ @model << [:name, :description, :price]
36
+ @model.to_sql().should eql( "products.id, products.price, products.description, products.name" )
37
+ end
38
+
39
+ it "should be able to compare itself to other model trackers" do
40
+ @model << [:name, :description, :price]
41
+ @model.should eql( @model )
42
+ end
43
+
44
+ it "should implemented a custom Object#inspect" do
45
+ @model << [:name, :description]
46
+ @model.inspect().should match( /Product/ )
47
+ @model.inspect().should match( /:name/ )
48
+ end
49
+
50
+ end
@@ -0,0 +1,83 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Scrooge::Tracker::Resource do
4
+
5
+ before(:each) do
6
+ @resource = Scrooge::Tracker::Resource.new do |resource|
7
+ resource.controller = 'products'
8
+ resource.action = 'show'
9
+ resource.method = :get
10
+ resource.format = :html
11
+ end
12
+ @model = Scrooge::Tracker::Model.new( 'Class' )
13
+ @model.stub!(:name).and_return( 'Product' )
14
+ @model.stub!(:table_name).and_return( 'products' )
15
+ @model.stub!(:primary_key).and_return( 'id' )
16
+ end
17
+
18
+ it "should be able to determine if any models has been tracked" do
19
+ @resource.any?().should equal( false )
20
+ end
21
+
22
+ it "should initialize with an empty set of models" do
23
+ @resource.models.should eql( Set.new )
24
+ end
25
+
26
+ it "should be able to accept models" do
27
+ lambda { @resource << @model }.should change( @resource.models, :size ).from(0).to(1)
28
+ end
29
+
30
+ it "should be able to wrap model objects" do
31
+ @resource << 'Model'
32
+ @resource.models.all?{|m| m.is_a?( Scrooge::Tracker::Model ) }.should equal( true )
33
+ end
34
+
35
+ it "should be able to log an attribute access for a given model" do
36
+ @resource << ['Post', :title]
37
+ @resource.models.first.attributes.should eql( Set[:title] )
38
+ end
39
+
40
+ it "should be able to determine if it's trackable" do
41
+ @resource.trackable?().should equal( true )
42
+ @resource.stub!(:method).and_return( :put )
43
+ @resource.trackable?().should equal( false )
44
+ end
45
+
46
+ it "should be able to generate a lookup signature" do
47
+ @resource.signature().should eql( "products_show_get" )
48
+ end
49
+
50
+ it "should be able to dump itself to a serializeable representation" do
51
+ @resource.marshal_dump().should eql( { "products_show_get" => { :models => [],
52
+ :method => :get,
53
+ :format => :html,
54
+ :action => "show",
55
+ :controller => "products"} } )
56
+ end
57
+
58
+ it "should be able to restore itself from a serialized representation" do
59
+ Marshal.load( Marshal.dump( @resource ) ).should eql( @resource )
60
+ end
61
+
62
+ it "should be able to compare itself to other resource trackers" do
63
+ @resource.should eql( @resource )
64
+ end
65
+
66
+ it "should be able to setup Rack middleware" do
67
+ @resource.profile.orm.stub!(:resource_scope_method).and_return(:scoped_to_resource_method)
68
+ @resource << @model
69
+ @resource.middleware().class.should equal( Array )
70
+ @resource.middleware().first.class.should equal( Class )
71
+ @resource.middleware().first.inspect.should match( /Middleware/ )
72
+ @resource.middleware().first.inspect.should match( /Product/ )
73
+ @resource.middleware().first.new( @model ).should respond_to( :call )
74
+ end
75
+
76
+ it "should implemented a custom Object#inspect" do
77
+ @resource << @model
78
+ @resource.inspect().should match( /GET/ )
79
+ @resource.inspect().should match( /products/ )
80
+ @resource.inspect().should match( /Product/ )
81
+ end
82
+
83
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Scrooge::Base do
4
+
5
+ before(:each) do
6
+ @base = Scrooge::Base
7
+ end
8
+
9
+ it "should be able to instantiate it's profile" do
10
+ @base.profile.class.should == Scrooge::Profile
11
+ end
12
+
13
+ end