bumbleworks 0.0.73 → 0.0.74

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bumbleworks.rb CHANGED
@@ -88,7 +88,7 @@ module Bumbleworks
88
88
  # @yield [configuration] global configuration
89
89
  # @see Bumbleworks.configure
90
90
  def configure!(&block)
91
- @configuration = nil
91
+ clear_configuration!
92
92
  configure(&block)
93
93
  end
94
94
 
@@ -142,12 +142,17 @@ module Bumbleworks
142
142
  end
143
143
 
144
144
  # @public
145
- # Resets Bumbleworks - clears configuration and setup variables, and
146
- # also resets the dashboard.
147
- #
145
+ # Resets Bumbleworks - resets dashboard, purges storage, and clears
146
+ # configuration and setup variables.
148
147
  def reset!
149
- @configuration = nil
150
148
  Bumbleworks::Ruote.reset!
149
+ clear_configuration!
150
+ end
151
+
152
+ # @public
153
+ # Clears configuration completely, resetting to defaults.
154
+ def clear_configuration!
155
+ @configuration = nil
151
156
  end
152
157
 
153
158
  # @public
@@ -146,18 +146,24 @@ module Bumbleworks
146
146
  end
147
147
 
148
148
  def storage
149
- @storage ||= Bumbleworks.storage_adapter.new_storage(Bumbleworks.storage, Bumbleworks.storage_options)
149
+ @storage ||= initialize_storage_adapter
150
150
  end
151
151
 
152
152
  def reset!
153
- if @storage
154
- @storage.purge!
155
- @storage.shutdown
153
+ if Bumbleworks.storage && storage
154
+ storage.purge!
155
+ storage.shutdown
156
156
  end
157
157
  @dashboard.shutdown if @dashboard && @dashboard.respond_to?(:shutdown)
158
158
  @storage = nil
159
159
  @dashboard = nil
160
160
  end
161
+
162
+ private
163
+
164
+ def initialize_storage_adapter
165
+ Bumbleworks.storage_adapter.new_storage(Bumbleworks.storage, Bumbleworks.storage_options)
166
+ end
161
167
  end
162
168
  end
163
169
  end
@@ -1,3 +1,3 @@
1
1
  module Bumbleworks
2
- VERSION = "0.0.73"
2
+ VERSION = "0.0.74"
3
3
  end
@@ -6,7 +6,6 @@ describe 'Entity Module' do
6
6
  }
7
7
 
8
8
  before :each do
9
- Bumbleworks.reset!
10
9
  load File.join(app_root, 'full_initializer.rb')
11
10
  end
12
11
 
@@ -9,10 +9,6 @@ describe 'History storage' do
9
9
  end
10
10
  end
11
11
 
12
- before :each do
13
- Bumbleworks.reset!
14
- end
15
-
16
12
  context 'when storage allows storing history' do
17
13
  before :each do
18
14
  Bumbleworks.stub(:storage_adapter => HashStorageWithHistory)
@@ -4,7 +4,6 @@ describe 'Bumbleworks Sample Application' do
4
4
  }
5
5
 
6
6
  before :each do
7
- Bumbleworks.reset!
8
7
  load File.join(app_root, 'full_initializer.rb')
9
8
  end
10
9
 
@@ -46,7 +46,6 @@ describe Bumbleworks::Expression do
46
46
 
47
47
  describe '#cancel!' do
48
48
  it 'cancels the expression' do
49
- Bumbleworks.storage = {}
50
49
  Bumbleworks.dashboard.should_receive(:cancel_expression).with(fei)
51
50
  subject.cancel!
52
51
  end
@@ -54,7 +53,6 @@ describe Bumbleworks::Expression do
54
53
 
55
54
  describe '#kill!' do
56
55
  it 'kills the expression' do
57
- Bumbleworks.storage = {}
58
56
  Bumbleworks.dashboard.should_receive(:kill_expression).with(fei)
59
57
  subject.kill!
60
58
  end
@@ -1,6 +1,5 @@
1
1
  describe Bumbleworks::ParticipantRegistration do
2
2
  before(:each) do
3
- Bumbleworks.reset!
4
3
  Bumbleworks.root = File.join(fixtures_path, 'apps', 'with_default_directories')
5
4
  end
6
5
 
@@ -2,8 +2,6 @@ require File.expand_path(File.join(fixtures_path, 'participants', 'naughty_parti
2
2
 
3
3
  describe Bumbleworks::Process::ErrorRecord do
4
4
  before :each do
5
- Bumbleworks.reset!
6
- Bumbleworks.storage = {}
7
5
  Bumbleworks::Ruote.register_participants do
8
6
  fall_apart NaughtyParticipant
9
7
  end
@@ -1,9 +1,4 @@
1
1
  describe Bumbleworks::ProcessDefinition do
2
- before :each do
3
- Bumbleworks.reset!
4
- Bumbleworks.storage = {}
5
- end
6
-
7
2
  let(:valid_definition) { %q(
8
3
  Bumbleworks.define_process 'monkeys' do
9
4
  chocolate_covered_skis :are => 'awesome'
@@ -2,8 +2,6 @@ require File.expand_path(File.join(fixtures_path, 'entities', 'rainbow_loom'))
2
2
 
3
3
  describe Bumbleworks::Process do
4
4
  before :each do
5
- Bumbleworks.reset!
6
- Bumbleworks.storage = {}
7
5
  Bumbleworks::Ruote.register_participants
8
6
  Bumbleworks.start_worker!
9
7
 
@@ -1,7 +1,5 @@
1
1
  describe Ruote::Exp::BroadcastEventExpression do
2
2
  before :each do
3
- Bumbleworks.reset!
4
- Bumbleworks.storage = {}
5
3
  Bumbleworks.start_worker!
6
4
  Bumbleworks.dashboard.add_service('tracer', @tracer = Tracer.new)
7
5
  end
@@ -1,7 +1,5 @@
1
1
  describe Ruote::Exp::WaitForEventExpression do
2
2
  before :each do
3
- Bumbleworks.reset!
4
- Bumbleworks.storage = {}
5
3
  Bumbleworks.start_worker!
6
4
  Bumbleworks.dashboard.add_service('tracer', @tracer = Tracer.new)
7
5
  end
@@ -1,9 +1,4 @@
1
1
  describe Bumbleworks::Ruote do
2
- before :each do
3
- Bumbleworks.reset!
4
- Bumbleworks.storage = {}
5
- end
6
-
7
2
  describe ".cancel_process!" do
8
3
  before :each do
9
4
  Bumbleworks.start_worker!
@@ -398,11 +393,15 @@ describe Bumbleworks::Ruote do
398
393
 
399
394
  describe '.reset!' do
400
395
  it 'purges and shuts down storage, then resets storage' do
401
- old_storage = described_class.storage
396
+ old_storage = double('Storage')
397
+ allow(described_class).to receive(:initialize_storage_adapter).and_return(old_storage)
402
398
  old_storage.should_receive(:purge!)
403
399
  old_storage.should_receive(:shutdown)
404
400
  described_class.reset!
405
- described_class.storage.should_not == old_storage
401
+ allow(described_class).to receive(:initialize_storage_adapter).and_return(:new_storage)
402
+ described_class.storage.should == :new_storage
403
+ # clean up
404
+ described_class.instance_variable_set(:@storage, nil)
406
405
  end
407
406
 
408
407
  it 'skips purging and shutting down of storage if no storage' do
@@ -1,7 +1,5 @@
1
1
  describe Bumbleworks::Task::Finder do
2
2
  before :each do
3
- Bumbleworks.reset!
4
- Bumbleworks.storage = {}
5
3
  Bumbleworks::Ruote.register_participants
6
4
  Bumbleworks.start_worker!
7
5
  Bumbleworks.define_process 'dog-lifecycle' do
@@ -2,8 +2,6 @@ describe Bumbleworks::Task do
2
2
  let(:workflow_item) {Ruote::Workitem.new('fields' => {'params' => {'task' => 'go_to_work'} })}
3
3
 
4
4
  before :each do
5
- Bumbleworks.reset!
6
- Bumbleworks.storage = {}
7
5
  Bumbleworks::Ruote.register_participants
8
6
  Bumbleworks.start_worker!
9
7
  end
@@ -3,8 +3,6 @@ require File.expand_path(File.join(fixtures_path, 'trackers'))
3
3
 
4
4
  describe Bumbleworks::Tracker do
5
5
  before(:each) do
6
- Bumbleworks.reset!
7
- Bumbleworks.storage = {}
8
6
  Bumbleworks.dashboard.stub(:get_trackers => fake_trackers)
9
7
  end
10
8
 
@@ -35,12 +35,19 @@ describe Bumbleworks do
35
35
  end
36
36
  end
37
37
 
38
+ describe '.clear_configuration!' do
39
+ it 'resets configuration' do
40
+ old_config = described_class.configuration
41
+ described_class.clear_configuration!
42
+ described_class.configuration.should_not == old_config
43
+ end
44
+ end
45
+
38
46
  describe '.reset!' do
39
47
  it 'resets configuration and resets ruote' do
40
- old_config = described_class.configuration
41
- Bumbleworks::Ruote.should_receive(:reset!)
48
+ expect(Bumbleworks::Ruote).to receive(:reset!).ordered
49
+ expect(described_class).to receive(:clear_configuration!).ordered
42
50
  described_class.reset!
43
- described_class.configuration.should_not == old_config
44
51
  end
45
52
  end
46
53
 
@@ -134,7 +141,6 @@ describe Bumbleworks do
134
141
 
135
142
  describe '.configuration' do
136
143
  before :each do
137
- Bumbleworks.reset!
138
144
  Bumbleworks::StorageAdapter.auto_register = nil
139
145
  end
140
146
 
@@ -149,11 +155,13 @@ describe Bumbleworks do
149
155
 
150
156
  it 'automatically adds Redis adapter if defined' do
151
157
  stub_const('Bumbleworks::Redis::Adapter', Bumbleworks::StorageAdapter)
158
+ Bumbleworks.clear_configuration! # to reload storage adapters
152
159
  described_class.configuration.storage_adapters.should include(Bumbleworks::Redis::Adapter)
153
160
  end
154
161
 
155
162
  it 'automatically adds Sequel adapter if defined' do
156
163
  stub_const('Bumbleworks::Sequel::Adapter', Bumbleworks::StorageAdapter)
164
+ Bumbleworks.clear_configuration! # to reload storage adapters
157
165
  described_class.configuration.storage_adapters.should include(Bumbleworks::Sequel::Adapter)
158
166
  end
159
167
  end
data/spec/spec_helper.rb CHANGED
@@ -16,4 +16,13 @@ RSpec.configure do |config|
16
16
  # the seed, which is printed after each run.
17
17
  # --seed 1234
18
18
  config.order = 'random'
19
+
20
+ config.before(:each) do
21
+ # Yup, we're setting the storage twice - the first time is to
22
+ # ensure that the .reset! isn't trying to access a test double, and
23
+ # the second is to initialize it to a hash for tests.
24
+ Bumbleworks.storage = nil
25
+ Bumbleworks.reset!
26
+ Bumbleworks.storage = {}
27
+ end
19
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bumbleworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.73
4
+ version: 0.0.74
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-03-03 00:00:00.000000000 Z
15
+ date: 2014-03-05 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: ruote
@@ -271,7 +271,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
271
  version: '0'
272
272
  segments:
273
273
  - 0
274
- hash: -2455234384689575722
274
+ hash: 1064429954326837811
275
275
  required_rubygems_version: !ruby/object:Gem::Requirement
276
276
  none: false
277
277
  requirements:
@@ -280,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  version: '0'
281
281
  segments:
282
282
  - 0
283
- hash: -2455234384689575722
283
+ hash: 1064429954326837811
284
284
  requirements: []
285
285
  rubyforge_project:
286
286
  rubygems_version: 1.8.23