methodmissing-scrooge 1.0.4 → 2.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 (58) hide show
  1. data/README.textile +139 -449
  2. data/Rakefile +20 -19
  3. data/VERSION.yml +2 -2
  4. data/lib/attributes_proxy.rb +121 -0
  5. data/lib/scrooge.rb +206 -47
  6. data/rails/init.rb +1 -10
  7. data/test/helper.rb +88 -0
  8. data/test/models/mysql_user.rb +4 -0
  9. data/test/scrooge_test.rb +75 -0
  10. data/test/setup.rb +3 -0
  11. metadata +11 -76
  12. data/assets/config/scrooge.yml.template +0 -27
  13. data/lib/scrooge/core/string.rb +0 -29
  14. data/lib/scrooge/core/symbol.rb +0 -21
  15. data/lib/scrooge/core/thread.rb +0 -26
  16. data/lib/scrooge/framework/base.rb +0 -315
  17. data/lib/scrooge/framework/rails.rb +0 -132
  18. data/lib/scrooge/middleware/tracker.rb +0 -46
  19. data/lib/scrooge/orm/active_record.rb +0 -159
  20. data/lib/scrooge/orm/base.rb +0 -102
  21. data/lib/scrooge/profile.rb +0 -223
  22. data/lib/scrooge/storage/base.rb +0 -46
  23. data/lib/scrooge/storage/memory.rb +0 -25
  24. data/lib/scrooge/strategy/base.rb +0 -74
  25. data/lib/scrooge/strategy/controller.rb +0 -31
  26. data/lib/scrooge/strategy/scope.rb +0 -15
  27. data/lib/scrooge/strategy/stage.rb +0 -77
  28. data/lib/scrooge/strategy/track.rb +0 -19
  29. data/lib/scrooge/strategy/track_then_scope.rb +0 -41
  30. data/lib/scrooge/tracker/app.rb +0 -161
  31. data/lib/scrooge/tracker/base.rb +0 -66
  32. data/lib/scrooge/tracker/model.rb +0 -150
  33. data/lib/scrooge/tracker/resource.rb +0 -181
  34. data/spec/fixtures/config/scrooge/scopes/1234567891/scope.yml +0 -2
  35. data/spec/fixtures/config/scrooge.yml +0 -20
  36. data/spec/helpers/framework/rails/cache.rb +0 -25
  37. data/spec/spec_helper.rb +0 -55
  38. data/spec/units/scrooge/core/string_spec.rb +0 -21
  39. data/spec/units/scrooge/core/symbol_spec.rb +0 -13
  40. data/spec/units/scrooge/core/thread_spec.rb +0 -15
  41. data/spec/units/scrooge/framework/base_spec.rb +0 -160
  42. data/spec/units/scrooge/framework/rails_spec.rb +0 -40
  43. data/spec/units/scrooge/orm/base_spec.rb +0 -61
  44. data/spec/units/scrooge/profile_spec.rb +0 -79
  45. data/spec/units/scrooge/storage/base_spec.rb +0 -35
  46. data/spec/units/scrooge/storage/memory_spec.rb +0 -20
  47. data/spec/units/scrooge/strategy/base_spec.rb +0 -62
  48. data/spec/units/scrooge/strategy/controller_spec.rb +0 -26
  49. data/spec/units/scrooge/strategy/scope_spec.rb +0 -18
  50. data/spec/units/scrooge/strategy/stage_spec.rb +0 -35
  51. data/spec/units/scrooge/strategy/track_spec.rb +0 -19
  52. data/spec/units/scrooge/strategy/track_then_scope_spec.rb +0 -22
  53. data/spec/units/scrooge/tracker/app_spec.rb +0 -68
  54. data/spec/units/scrooge/tracker/base_spec.rb +0 -29
  55. data/spec/units/scrooge/tracker/model_spec.rb +0 -79
  56. data/spec/units/scrooge/tracker/resource_spec.rb +0 -115
  57. data/spec/units/scrooge_spec.rb +0 -13
  58. data/tasks/scrooge.rake +0 -43
@@ -1,20 +0,0 @@
1
- production:
2
- orm: :active_record
3
- storage: :memory
4
- verbose: false
5
- scope: 1234567891
6
- on_missing_attribute: :reload
7
- strategy: :track_then_scope
8
- warmup: 600 # warmup / track for 10 minutes
9
- logged_in_session: :user_id # session key that represents the logged in user
10
- enabled: true
11
- test:
12
- orm: :active_record
13
- storage: :memory
14
- verbose: true
15
- scope:
16
- on_missing_attribute: :reload
17
- strategy: :track_then_scope
18
- warmup: 600 # warmup / track for 10 minutes
19
- logged_in_session: :user_id # session key that represents the logged in user
20
- enabled: true
@@ -1,25 +0,0 @@
1
- module Spec
2
- module Helpers
3
- module Framework
4
- module Rails
5
- class Cache
6
-
7
- attr_reader :storage
8
-
9
- def initialize
10
- @storage = {}
11
- end
12
-
13
- def read( key )
14
- @storage[key]
15
- end
16
-
17
- def write( key, value )
18
- @storage[key] = value
19
- end
20
-
21
- end
22
- end
23
- end
24
- end
25
- end
data/spec/spec_helper.rb DELETED
@@ -1,55 +0,0 @@
1
- $:.unshift File.dirname(__FILE__) + '/../lib'
2
-
3
- require 'rubygems'
4
- require 'fileutils'
5
- require 'logger'
6
- require 'stringio'
7
- require 'lib/scrooge'
8
- require 'spec/helpers/framework/rails/cache'
9
-
10
- #ActiveRecord::Base.logger = Logger.new(StringIO.new)
11
-
12
- Spec::Runner.configure do |config|
13
-
14
- def self.set_constant( const, value )
15
- eval( "Kernel.const_set :#{const.to_s}, #{value.inspect} unless defined?( #{const.to_s} )" )
16
- end
17
-
18
- set_constant( :FIXTURES, "#{Dir.pwd}/spec/fixtures" )
19
- set_constant( :TMP, "#{Dir.pwd}/spec/tmp" )
20
- set_constant( :CONFIG, "#{Dir.pwd}/spec/config" )
21
-
22
- config.before :all do
23
- [TMP, CONFIG].each do |dir|
24
- FileUtils.mkdir_p dir
25
- end
26
- end
27
-
28
- config.before :each do
29
- end
30
-
31
- config.after :each do
32
- end
33
-
34
- config.after :all do
35
- [TMP, CONFIG].each do |dir|
36
- FileUtils.rm_r( dir ) rescue nil
37
- end
38
- end
39
-
40
- def with_rails
41
- begin
42
- Kernel.const_set :RAILS_ROOT, "#{Dir.pwd}/spec" unless defined?(RAILS_ROOT)
43
- Kernel.const_set :Rails, Class.new unless defined?(Rails)
44
- Kernel.const_set :RAILS_ENV, "test" unless defined?(RAILS_ENV)
45
- ::Rails.stub!(:cache).and_return( Spec::Helpers::Framework::Rails::Cache.new )
46
- ::Rails.stub!(:root).and_return( RAILS_ROOT )
47
- yield
48
- ensure
49
- [:RAILS_ROOT, :RAILS_ENV, :Rails].each do |const|
50
- Kernel.send( :remove_const, const )
51
- end
52
- end
53
- end
54
-
55
- end
@@ -1,21 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Scrooge::Core::String do
4
-
5
- before(:each) do
6
- @string = 'scrooge/base'
7
- end
8
-
9
- it "should be able to convert itself to a constant" do
10
- @string.to_const().should == 'Scrooge::Base'
11
- end
12
-
13
- it "should be able to convert itself to a class" do
14
- @string.to_const!( false ).should == Scrooge::Base
15
- end
16
-
17
- it "should return self if it's not able to constantize" do
18
- 'not/defined'.to_const!( false ).should == 'not/defined'
19
- end
20
-
21
- end
@@ -1,13 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Scrooge::Core::Symbol do
4
-
5
- before(:each) do
6
- @symbol = :active_record
7
- end
8
-
9
- it "should be able to convert itself to a constant" do
10
- @symbol.to_const().should == 'ActiveRecord'
11
- end
12
-
13
- end
@@ -1,15 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe "Scrooge::Core::Thread singleton" do
4
-
5
- it "should be able to yield the current scrooge resource" do
6
- Thread.scrooge_resource.class.should equal( Scrooge::Tracker::Resource )
7
- end
8
-
9
- it "should be able to reset the current scrooge resource" do
10
- @resource = Thread.scrooge_resource
11
- Thread.reset_scrooge_resource!
12
- @resource.object_id.should_not equal( Thread.scrooge_resource.object_id )
13
- end
14
-
15
- end
@@ -1,160 +0,0 @@
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
- FileUtils.rm_r( File.join( @base.scopes_path, @signature ) )
81
- end
82
- end
83
-
84
- it "should be able to determine if there's any previously persisted scopes" do
85
- with_rails do
86
- @base.stub!(:config).and_return( CONFIG )
87
- @base.send( :ensure_scopes_path )
88
- @base.scopes?().should eql( false )
89
- end
90
- end
91
-
92
- it "should be able to infer the path to a given scope" do
93
- with_rails do
94
- @base.stub!(:config).and_return( CONFIG )
95
- @base.scope_path( '1234567891' ).should match( /scopes\/1234567891/ )
96
- end
97
- end
98
-
99
- it "should be able to determine if a given scope is defined" do
100
- with_rails do
101
- @base.stub!(:config).and_return( CONFIG )
102
- @base.scope?( 9876543211 ).should equal( false )
103
- end
104
- end
105
-
106
- it "should be able to dump the current application tracker to a scope" do
107
- with_rails do
108
- @base.stub!(:config).and_return( CONFIG )
109
- ::Rails.stub!(:env).and_return( "test" )
110
- @base.to_scope!()
111
- @base.scopes.size.should == 1
112
- end
113
- end
114
-
115
- it "should be able to restore a previous scope to the current app tracker" do
116
- with_rails do
117
- @base.stub!(:config).and_return( CONFIG )
118
- ::Rails.stub!(:env).and_return( "test" )
119
- @scope = @base.to_scope!
120
- lambda{ Scrooge::Base.profile.scope = @base.from_scope!( @scope ) }.should change( Scrooge::Base.profile.tracker, :object_id )
121
- end
122
- end
123
-
124
- it "should be able to validate previously saved scope signatures" do
125
- @base.stub!(:scope?).and_return(false)
126
- lambda{ @base.from_scope!( 'undefined' ) }.should raise_error( Scrooge::Framework::Base::InvalidScopeSignature )
127
- end
128
-
129
- it "should be able to interact with the framework's Rack middleware" do
130
- lambda{ @base.middleware }.should raise_error( Scrooge::Framework::Base::NotImplemented )
131
- end
132
-
133
- it "should be able to install tracking middleware" do
134
- lambda{ @base.install_tracking_middleware() }.should raise_error( Scrooge::Framework::Base::NotImplemented )
135
- end
136
-
137
- it "should be able to uninstall tracking middleware" do
138
- lambda{ @base.uninstall_tracking_middleware() }.should raise_error( Scrooge::Framework::Base::NotImplemented )
139
- end
140
-
141
- it "should be able to install scoping middleware" do
142
- lambda{ @base.install_scope_middleware( 'tracker' ) }.should raise_error( Scrooge::Framework::Base::NotImplemented )
143
- end
144
-
145
- it "should be able to register code blocks to run after the framework has been initialized" do
146
- lambda{ @base.initialized() }.should raise_error( Scrooge::Framework::Base::NotImplemented )
147
- end
148
-
149
- it "should be able to map a resource instance to a controller constant" do
150
- lambda{ @base.controller( 'resource' ) }.should raise_error( Scrooge::Framework::Base::NotImplemented )
151
- end
152
-
153
- it "should be able to return a full path to the scrooge configuration file" do
154
- with_rails do
155
- @base.stub!(:config).and_return( CONFIG )
156
- @base.configuration_file.should match( /scrooge.yml/ )
157
- end
158
- end
159
-
160
- end
@@ -1,40 +0,0 @@
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
@@ -1,61 +0,0 @@
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
@@ -1,79 +0,0 @@
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
- with_rails do
21
- @profile.framework.stub!(:scopes).and_return( %w(1234567891) )
22
- end
23
- @profile.options = { 'scope' => '1234567891'}
24
- end
25
-
26
- it "should return a valid ORM instance" do
27
- @profile.orm.class.should equal( Scrooge::Orm::ActiveRecord )
28
- end
29
-
30
- it "should return a valid storage instance" do
31
- @profile.storage.class.should equal( Scrooge::Storage::Memory )
32
- end
33
-
34
- it "should return a valid framework instance" do
35
- with_rails do
36
- @profile.framework.class.should equal( Scrooge::Framework::Rails )
37
- end
38
- end
39
-
40
- it "should return a valid tracker instance" do
41
- @profile.tracker.class.should equal( Scrooge::Tracker::App )
42
- end
43
-
44
- it "should be able to infer the current scope" do
45
- @profile.scope.should eql( "1234567891" )
46
- end
47
-
48
- it "should be able to determine if it's enabled" do
49
- @profile.enabled?().should eql( false )
50
- end
51
-
52
- it "should be able to determine if it should raise on missing attributes" do
53
- @profile.raise_on_missing_attribute?().should equal( false )
54
- end
55
-
56
- it "should be able to fallback to scope from the environment if none given" do
57
- @profile.framework.stub!(:scopes).and_return( [] )
58
- ENV['scope'] = 'scope_from_env'
59
- @profile.send(:configure!)
60
- @profile.scope.should eql( 'scope_from_env' )
61
- end
62
-
63
- it "should be able to yield a stategy instance" do
64
- @profile.strategy.class.should == Scrooge::Strategy::Track
65
- end
66
-
67
- it "should be able to expose it's warmup tracking period" do
68
- @profile.warmup.should == 0
69
- end
70
-
71
- it "should be able to return a session key that indicates a logged in session" do
72
- @profile.logged_in_session.should == :user_id
73
- end
74
-
75
- it "should be able to determine if logging should be verbose" do
76
- @profile.verbose?().should == false
77
- end
78
-
79
- end
@@ -1,35 +0,0 @@
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
@@ -1,20 +0,0 @@
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
@@ -1,62 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe 'Scrooge::Strategy::Base singleton' do
4
-
5
- after(:each) do
6
- Scrooge::Strategy::Base.flush!
7
- end
8
-
9
- it "should be able to determine if it has any stages" do
10
- Scrooge::Strategy::Base.stages?().should equal( false )
11
- Scrooge::Strategy::Base.stage( :stage ) do
12
- 'payload'
13
- end
14
- Scrooge::Strategy::Base.stages?().should equal( true )
15
- end
16
-
17
- it "should be able to yield all it's defined stages" do
18
- Scrooge::Strategy::Base.stages.should eql( [] )
19
- end
20
-
21
- it "should be able to register one or more execution stages" do
22
- lambda do
23
- Scrooge::Strategy::Base.stage( :stage ) do
24
- 'payload'
25
- end
26
- end.should change( Scrooge::Strategy::Base.stages, :size ).from(0).to(1)
27
- end
28
-
29
- it "should require at least one defined stage" do
30
- lambda{ @base.scope_to( Scrooge::Strategy::Base.new ) }.should raise_error( Scrooge::Strategy::Base::NoStages )
31
- end
32
-
33
- end
34
-
35
- describe Scrooge::Strategy::Base do
36
-
37
- before(:each) do
38
- Scrooge::Strategy::Base.stage( :stage ) do
39
- 'payload'
40
- end
41
- @base = Scrooge::Strategy::Base.new
42
- Scrooge::Base.profile.stub!(:enabled?).and_return(true)
43
- end
44
-
45
- after(:each) do
46
- Scrooge::Strategy::Base.flush!
47
- end
48
-
49
- it "should be able to infer all defined stages" do
50
- @base.stages.first.class.should eql( Scrooge::Strategy::Stage )
51
- end
52
-
53
- it "should be able to execute itself" do
54
- @base.execute!().class.should == Thread
55
- end
56
-
57
- it "should provide access to it's controller Thread" do
58
- @base.execute!
59
- @base.thread.class.should == Thread
60
- end
61
-
62
- end
@@ -1,26 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Scrooge::Strategy::Base do
4
-
5
- before(:each) do
6
- Scrooge::Strategy::Base.stage( :stage ) do
7
- 'payload'
8
- end
9
- @base = Scrooge::Strategy::Base.new
10
- @controller = Scrooge::Strategy::Controller.new( @base )
11
- end
12
-
13
- after(:each) do
14
- Scrooge::Strategy::Base.flush!
15
- end
16
-
17
- it "should be able to execute a given strategy" do
18
- @controller.run!().value.should include( 'payload' )
19
- end
20
-
21
- it "should be able to provide access to the background thread" do
22
- @controller.run!()
23
- @controller.thread.class.should == Thread
24
- end
25
-
26
- end
@@ -1,18 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Scrooge::Strategy::Scope do
4
-
5
- before(:each) do
6
- @scope = Scrooge::Strategy::Scope.new
7
- @controller = Scrooge::Strategy::Controller.new( @scope )
8
- Scrooge::Base.profile.framework.stub!(:install_scope_middleware).and_return('installed')
9
- Scrooge::Base.profile.stub!(:scope).and_return( '1234567891' )
10
- end
11
-
12
- it "should be able to execute a given strategy" do
13
- with_rails do
14
- lambda{ @controller.run!().value }.should raise_error( SystemExit )
15
- end
16
- end
17
-
18
- end