bumbleworks 0.0.74 → 0.0.76

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -1
  3. data/.ruby-version +1 -1
  4. data/bumbleworks.gemspec +2 -2
  5. data/lib/bumbleworks.rb +1 -0
  6. data/lib/bumbleworks/expression.rb +12 -1
  7. data/lib/bumbleworks/process.rb +10 -0
  8. data/lib/bumbleworks/process/error_record.rb +14 -0
  9. data/lib/bumbleworks/schedule.rb +58 -0
  10. data/lib/bumbleworks/task.rb +2 -1
  11. data/lib/bumbleworks/task/finder.rb +4 -0
  12. data/lib/bumbleworks/version.rb +1 -1
  13. data/lib/bumbleworks/workitem.rb +4 -0
  14. data/spec/fixtures/schedules.rb +40 -0
  15. data/spec/integration/entity_spec.rb +7 -7
  16. data/spec/integration/example_configurations_spec.rb +5 -5
  17. data/spec/integration/history_storage_spec.rb +9 -9
  18. data/spec/integration/sample_application_spec.rb +15 -15
  19. data/spec/lib/bumbleworks/configuration_spec.rb +52 -52
  20. data/spec/lib/bumbleworks/entity_spec.rb +66 -68
  21. data/spec/lib/bumbleworks/error_handler_spec.rb +1 -1
  22. data/spec/lib/bumbleworks/error_logger_spec.rb +5 -5
  23. data/spec/lib/bumbleworks/expression_spec.rb +34 -12
  24. data/spec/lib/bumbleworks/hash_storage_spec.rb +2 -2
  25. data/spec/lib/bumbleworks/participant/base_spec.rb +1 -1
  26. data/spec/lib/bumbleworks/participant/entity_interactor_spec.rb +20 -20
  27. data/spec/lib/bumbleworks/participant/error_dispatcher_spec.rb +3 -3
  28. data/spec/lib/bumbleworks/participant/local_participant_spec.rb +1 -1
  29. data/spec/lib/bumbleworks/participant_registration_spec.rb +4 -4
  30. data/spec/lib/bumbleworks/process/error_record_spec.rb +13 -0
  31. data/spec/lib/bumbleworks/process_definition_spec.rb +30 -24
  32. data/spec/lib/bumbleworks/process_spec.rb +86 -54
  33. data/spec/lib/bumbleworks/ruote/exp/broadcast_event_expression_spec.rb +2 -2
  34. data/spec/lib/bumbleworks/ruote/exp/wait_for_event_expression_spec.rb +4 -4
  35. data/spec/lib/bumbleworks/ruote_spec.rb +73 -71
  36. data/spec/lib/bumbleworks/schedule_spec.rb +124 -0
  37. data/spec/lib/bumbleworks/simple_logger_spec.rb +8 -8
  38. data/spec/lib/bumbleworks/storage_adapter_spec.rb +16 -16
  39. data/spec/lib/bumbleworks/support_spec.rb +23 -19
  40. data/spec/lib/bumbleworks/task/finder_spec.rb +46 -46
  41. data/spec/lib/bumbleworks/task_spec.rb +188 -167
  42. data/spec/lib/bumbleworks/tracker_spec.rb +41 -42
  43. data/spec/lib/bumbleworks/tree_builder_spec.rb +9 -7
  44. data/spec/lib/bumbleworks/user_spec.rb +35 -35
  45. data/spec/lib/bumbleworks/workitem_entity_storage_spec.rb +5 -5
  46. data/spec/lib/bumbleworks/workitem_spec.rb +28 -17
  47. data/spec/lib/bumbleworks_spec.rb +57 -51
  48. data/spec/spec_helper.rb +0 -1
  49. data/spec/support/shared_examples.rb +3 -3
  50. metadata +35 -54
@@ -0,0 +1,124 @@
1
+ require File.expand_path(File.join(fixtures_path, 'schedules'))
2
+
3
+ describe Bumbleworks::Schedule do
4
+ let(:fake_schedule) { fake_schedules.first }
5
+ subject { described_class.new(fake_schedule) }
6
+
7
+ before(:each) do
8
+ allow(Bumbleworks.dashboard).to receive_messages(:schedules => fake_schedules)
9
+ end
10
+
11
+ describe '.all' do
12
+ it 'returns instances for each schedule in system' do
13
+ schedules = described_class.all
14
+ expect(schedules.all? { |t| t.class == Bumbleworks::Schedule }).to be_truthy
15
+ expect(schedules.map(&:id)).to match_array([
16
+ "at-0_0!d65a8006da6d9025d48fa916071a6dc1!20140710-1001-dirisoma-rebadihe-20140718000000",
17
+ "cron-0_0!48ec5a9db7d4c61da0ebaa968bd552c3!20140710-1016-nodemika-kudatsufu-20140710101857",
18
+ "cron-0_0!9103b81d6b2cc198ec44b1c7c6461d1e!20140710-1023-dobabako-jabufuso-20140713111500"
19
+ ])
20
+ end
21
+ end
22
+
23
+ describe '.count' do
24
+ it 'returns count of current schedules' do
25
+ expect(described_class.count).to eq 3
26
+ end
27
+ end
28
+
29
+ describe '.new' do
30
+ it 'sets schedule id and fetches original_hash from dashboard' do
31
+ expect(subject.id).to eq(fake_schedule['_id'])
32
+ expect(subject.original_hash).to eq(fake_schedule)
33
+ end
34
+ end
35
+
36
+ describe '#==' do
37
+ it 'returns true if other object has same original hash _id' do
38
+ schedule1 = described_class.new({ '_id' => 'snaggletooth', 'who' => 'cares' })
39
+ schedule2 = described_class.new({ '_id' => 'snaggletooth', 'yeah' => 'whatevs' })
40
+ expect(schedule1).to eq(schedule2)
41
+ end
42
+
43
+ it 'returns false if other object has different original hash _id' do
44
+ schedule1 = described_class.new({ '_id' => 'snaggletooth', 'who' => 'cares' })
45
+ schedule2 = described_class.new({ '_id' => 'snooglebunk', 'yeah' => 'whatevs' })
46
+ expect(schedule1).not_to eq(schedule2)
47
+ end
48
+ end
49
+
50
+ describe '#wfid' do
51
+ it 'returns wfid from original hash' do
52
+ expect(subject.wfid).to eq(fake_schedule['wfid'])
53
+ end
54
+ end
55
+
56
+ describe '#process' do
57
+ it 'returns process for wfid stored in msg' do
58
+ expect(subject.process).to eq(Bumbleworks::Process.new(fake_schedule['wfid']))
59
+ end
60
+ end
61
+
62
+ describe '#expression' do
63
+ it 'returns expression that triggered the schedule' do
64
+ allow(Bumbleworks::Expression).to receive(:from_fei).
65
+ with(:a_flow_expression).and_return(:the_expression)
66
+ expect(subject.expression).to eq(:the_expression)
67
+ end
68
+ end
69
+
70
+ describe '#repeating?' do
71
+ ['every', 'cron'].each do |exp_name|
72
+ it "returns true if expression is '#{exp_name}'" do
73
+ allow(subject).to receive(:expression).and_return(
74
+ double(Bumbleworks::Expression, :tree => [exp_name]))
75
+ expect(subject.repeating?).to be_truthy
76
+ end
77
+ end
78
+
79
+ ['once', 'as_soon_as', 'when'].each do |exp_name|
80
+ it "returns false if expression is '#{exp_name}'" do
81
+ allow(subject).to receive(:expression).and_return(
82
+ double(Bumbleworks::Expression, :tree => [exp_name]))
83
+ expect(subject.repeating?).to be_falsy
84
+ end
85
+ end
86
+ end
87
+
88
+ describe '#once?' do
89
+ it 'returns inverse of #repeating?' do
90
+ allow(subject).to receive_messages(:repeating? => true)
91
+ expect(subject.once?).to be_falsy
92
+ allow(subject).to receive_messages(:repeating? => false)
93
+ expect(subject.once?).to be_truthy
94
+ end
95
+ end
96
+
97
+ describe '#next_at' do
98
+ it 'returns time of next iteration' do
99
+ expect(subject.next_at).to eq(Time.parse('2014-07-18 04:00:00 UTC'))
100
+ end
101
+ end
102
+
103
+ describe '#original_plan' do
104
+ it 'returns original schedule plan' do
105
+ expect(subject.original_plan).to eq("2014-07-18 04:00:00")
106
+ second_fake_schedule = described_class.new(fake_schedules[1])
107
+ expect(second_fake_schedule.original_plan).to eq("1m")
108
+ end
109
+ end
110
+
111
+ describe '#test_clause' do
112
+ it 'returns test clause from expression' do
113
+ allow(subject).to receive_messages(
114
+ :expression => double(Bumbleworks::Expression, :tree => ['once', {'test' => 'pigeons'}, []]))
115
+ expect(subject.test_clause).to eq('pigeons')
116
+ end
117
+
118
+ it 'returns nil when expression does not include test clause' do
119
+ allow(subject).to receive_messages(
120
+ :expression => double(Bumbleworks::Expression, :tree => ['once', {}, []]))
121
+ expect(subject.test_clause).to be_nil
122
+ end
123
+ end
124
+ end
@@ -6,7 +6,7 @@ describe Bumbleworks::SimpleLogger do
6
6
  [:info, :debug, :fatal, :warn, :error].each do |level|
7
7
  describe ".#{level}" do
8
8
  it "adds given object to the log with '#{level}' level" do
9
- described_class.should_receive(:add).
9
+ expect(described_class).to receive(:add).
10
10
  with(level, :something => :happened)
11
11
  described_class.send(level.to_sym, :something => :happened)
12
12
  end
@@ -17,10 +17,10 @@ describe Bumbleworks::SimpleLogger do
17
17
  it 'adds given object to the log at given level' do
18
18
  described_class.add(:info, :super_serious_occurrence)
19
19
  described_class.add(:debug, :weird_thing)
20
- described_class.entries.should == [
20
+ expect(described_class.entries).to eq([
21
21
  { :level => :info, :entry => :super_serious_occurrence },
22
22
  { :level => :debug, :entry => :weird_thing }
23
- ]
23
+ ])
24
24
  end
25
25
  end
26
26
 
@@ -30,22 +30,22 @@ describe Bumbleworks::SimpleLogger do
30
30
  described_class.debug 'other thing'
31
31
  described_class.info 'third thing'
32
32
  described_class.fatal 'final thing'
33
- described_class.entries.should == [
33
+ expect(described_class.entries).to eq([
34
34
  { :level => :info, :entry => 'thing' },
35
35
  { :level => :debug, :entry => 'other thing' },
36
36
  { :level => :info, :entry => 'third thing' },
37
37
  { :level => :fatal, :entry => 'final thing' }
38
- ]
38
+ ])
39
39
  end
40
40
  end
41
41
 
42
42
  describe '.clear!' do
43
43
  it 'deletes all entries' do
44
- described_class.entries.should be_empty
44
+ expect(described_class.entries).to be_empty
45
45
  described_class.info 'thing'
46
- described_class.entries.should_not be_empty
46
+ expect(described_class.entries).not_to be_empty
47
47
  described_class.clear!
48
- described_class.entries.should be_empty
48
+ expect(described_class.entries).to be_empty
49
49
  end
50
50
  end
51
51
  end
@@ -2,24 +2,24 @@ describe Bumbleworks::StorageAdapter do
2
2
  describe '.auto_register?' do
3
3
  it 'returns true if auto_register is true' do
4
4
  described_class.auto_register = true
5
- described_class.auto_register?.should be_true
5
+ expect(described_class.auto_register?).to be_truthy
6
6
  end
7
7
 
8
8
  it 'returns false if auto_register is not true' do
9
9
  described_class.auto_register = :ghosts
10
- described_class.auto_register?.should be_false
10
+ expect(described_class.auto_register?).to be_falsy
11
11
  end
12
12
 
13
13
  it 'is true by default' do
14
14
  described_class.auto_register = nil
15
- described_class.auto_register?.should be_true
15
+ expect(described_class.auto_register?).to be_truthy
16
16
  end
17
17
  end
18
18
 
19
19
  describe '.display_name' do
20
20
  it 'returns storage class name as a string' do
21
- described_class.stub(:storage_class).and_return(String)
22
- described_class.display_name.should == 'String'
21
+ allow(described_class).to receive(:storage_class).and_return(String)
22
+ expect(described_class.display_name).to eq('String')
23
23
  end
24
24
  end
25
25
 
@@ -37,45 +37,45 @@ describe Bumbleworks::StorageAdapter do
37
37
 
38
38
  describe '.allow_history_storage?' do
39
39
  it 'defaults to true' do
40
- described_class.allow_history_storage?.should be_true
40
+ expect(described_class.allow_history_storage?).to be_truthy
41
41
  end
42
42
  end
43
43
 
44
44
  describe '.use?' do
45
45
  before :each do
46
- described_class.stub(:storage_class).and_return(String)
46
+ allow(described_class).to receive(:storage_class).and_return(String)
47
47
  end
48
48
 
49
49
  it 'returns true if argument class is_a storage class' do
50
- described_class.use?('a string').should be_true
51
- described_class.use?(:not_a_string).should be_false
50
+ expect(described_class.use?('a string')).to be_truthy
51
+ expect(described_class.use?(:not_a_string)).to be_falsy
52
52
  end
53
53
  end
54
54
 
55
55
  describe '.wrap_storage_with_driver' do
56
56
  before :each do
57
57
  storage_driver = double('storage_driver')
58
- storage_driver.stub(:new).with(:awesome_stuff).and_return(:new_storage)
59
- described_class.stub(:driver => storage_driver)
58
+ allow(storage_driver).to receive(:new).with(:awesome_stuff).and_return(:new_storage)
59
+ allow(described_class).to receive_messages(:driver => storage_driver)
60
60
  end
61
61
 
62
62
  it 'ignores options, and returns driven storage' do
63
- described_class.wrap_storage_with_driver(:awesome_stuff, { :a => :b }).should == :new_storage
63
+ expect(described_class.wrap_storage_with_driver(:awesome_stuff, { :a => :b })).to eq(:new_storage)
64
64
  end
65
65
  end
66
66
 
67
67
  describe '.new_storage' do
68
68
  before :each do
69
- described_class.stub(:wrap_storage_with_driver).with(:awesome_stuff, { :a => :b }).and_return(:new_storage)
69
+ allow(described_class).to receive(:wrap_storage_with_driver).with(:awesome_stuff, { :a => :b }).and_return(:new_storage)
70
70
  end
71
71
 
72
72
  it 'returns driven storage if driver can use storage' do
73
- described_class.stub(:use?).with(:awesome_stuff).and_return(true)
74
- described_class.new_storage(:awesome_stuff, { :a => :b }).should == :new_storage
73
+ allow(described_class).to receive(:use?).with(:awesome_stuff).and_return(true)
74
+ expect(described_class.new_storage(:awesome_stuff, { :a => :b })).to eq(:new_storage)
75
75
  end
76
76
 
77
77
  it "raises UnsupportedStorage if driver can't use storage" do
78
- described_class.stub(:use?).with(:awesome_stuff).and_return(false)
78
+ allow(described_class).to receive(:use?).with(:awesome_stuff).and_return(false)
79
79
  expect {
80
80
  described_class.new_storage(:awesome_stuff, { :a => :b })
81
81
  }.to raise_error(Bumbleworks::StorageAdapter::UnsupportedStorage)
@@ -1,11 +1,11 @@
1
1
  describe Bumbleworks::Support do
2
2
  describe '.camelize' do
3
3
  it 'turns underscored string into camelcase' do
4
- described_class.camelize('foo_bar_One_two_3').should == 'FooBarOneTwo3'
4
+ expect(described_class.camelize('foo_bar_One_two_3')).to eq('FooBarOneTwo3')
5
5
  end
6
6
 
7
7
  it 'deals with nested classes' do
8
- described_class.camelize('foo_bar/bar_foo').should == 'FooBar::BarFoo'
8
+ expect(described_class.camelize('foo_bar/bar_foo')).to eq('FooBar::BarFoo')
9
9
  end
10
10
  end
11
11
 
@@ -15,20 +15,24 @@ describe Bumbleworks::Support do
15
15
  it "for given directory, creates hash of basename => path pairs" do
16
16
  assembled_hash = described_class.all_files(test_directory)
17
17
 
18
- assembled_hash[File.join(fixtures_path, 'definitions', 'test_process.rb').to_s].should ==
18
+ expect(assembled_hash[File.join(fixtures_path, 'definitions', 'test_process.rb').to_s]).to eq(
19
19
  'test_process'
20
- assembled_hash[File.join(fixtures_path, 'definitions', 'nested_folder', 'test_nested_process.rb').to_s].should ==
20
+ )
21
+ expect(assembled_hash[File.join(fixtures_path, 'definitions', 'nested_folder', 'test_nested_process.rb').to_s]).to eq(
21
22
  'test_nested_process'
23
+ )
22
24
  end
23
25
 
24
26
  it "camelizes names if :camelize option is true " do
25
27
  path = File.join(fixtures_path, 'definitions')
26
28
  assembled_hash = described_class.all_files(test_directory, :camelize => true)
27
29
 
28
- assembled_hash[File.join(fixtures_path, 'definitions', 'test_process.rb').to_s].should ==
30
+ expect(assembled_hash[File.join(fixtures_path, 'definitions', 'test_process.rb').to_s]).to eq(
29
31
  'TestProcess'
30
- assembled_hash[File.join(fixtures_path, 'definitions', 'nested_folder', 'test_nested_process.rb').to_s].should ==
32
+ )
33
+ expect(assembled_hash[File.join(fixtures_path, 'definitions', 'nested_folder', 'test_nested_process.rb').to_s]).to eq(
31
34
  'TestNestedProcess'
35
+ )
32
36
  end
33
37
  end
34
38
 
@@ -46,11 +50,11 @@ describe Bumbleworks::Support do
46
50
  end
47
51
 
48
52
  it 'returns value of constant with given name' do
49
- described_class.constantize('Whatever')::Smoothies.should == 'tasty'
53
+ expect(described_class.constantize('Whatever')::Smoothies).to eq('tasty')
50
54
  end
51
55
 
52
56
  it 'works with nested constants' do
53
- described_class.constantize('Whatever::Smoothies').should == 'tasty'
57
+ expect(described_class.constantize('Whatever::Smoothies')).to eq('tasty')
54
58
  end
55
59
 
56
60
  it 'does not check inheritance tree' do
@@ -62,51 +66,51 @@ describe Bumbleworks::Support do
62
66
 
63
67
  describe '.tokenize' do
64
68
  it 'creates snake_case version of string' do
65
- described_class.tokenize('Albus Dumbledore & his_friend').should == 'albus_dumbledore_and_his_friend'
69
+ expect(described_class.tokenize('Albus Dumbledore & his_friend')).to eq('albus_dumbledore_and_his_friend')
66
70
  end
67
71
 
68
72
  it 'uncamelizes' do
69
- described_class.tokenize('thisStrangeJavalikeWord').should == 'this_strange_javalike_word'
73
+ expect(described_class.tokenize('thisStrangeJavalikeWord')).to eq('this_strange_javalike_word')
70
74
  end
71
75
 
72
76
  it 'returns nil if given nil' do
73
- described_class.tokenize(nil).should be_nil
77
+ expect(described_class.tokenize(nil)).to be_nil
74
78
  end
75
79
 
76
80
  it 'also handles symbols' do
77
- described_class.tokenize(:yourFaceIsNice).should == 'your_face_is_nice'
81
+ expect(described_class.tokenize(:yourFaceIsNice)).to eq('your_face_is_nice')
78
82
  end
79
83
  end
80
84
 
81
85
  describe '.humanize' do
82
86
  it 'creates humanized version of snaky string' do
83
- described_class.humanize('mops_are_so_moppy').should == 'Mops are so moppy'
87
+ expect(described_class.humanize('mops_are_so_moppy')).to eq('Mops are so moppy')
84
88
  end
85
89
 
86
90
  it 'created humanized version of camely string' do
87
- described_class.humanize('thisStrangeJavalikeWord').should == 'This strange javalike word'
91
+ expect(described_class.humanize('thisStrangeJavalikeWord')).to eq('This strange javalike word')
88
92
  end
89
93
 
90
94
  it 'returns nil if given nil' do
91
- described_class.humanize(nil).should be_nil
95
+ expect(described_class.humanize(nil)).to be_nil
92
96
  end
93
97
  end
94
98
 
95
99
  describe '.titleize' do
96
100
  it 'creates titleized version of snaky string' do
97
- described_class.titleize('mops_are_so_moppy').should == 'Mops Are So Moppy'
101
+ expect(described_class.titleize('mops_are_so_moppy')).to eq('Mops Are So Moppy')
98
102
  end
99
103
 
100
104
  it 'created titleized version of camely string' do
101
- described_class.titleize('thisStrangeJavalikeWord').should == 'This Strange Javalike Word'
105
+ expect(described_class.titleize('thisStrangeJavalikeWord')).to eq('This Strange Javalike Word')
102
106
  end
103
107
 
104
108
  it 'created titleized version of humany string' do
105
- described_class.titleize('You are a wonderful toothbrush').should == 'You Are A Wonderful Toothbrush'
109
+ expect(described_class.titleize('You are a wonderful toothbrush')).to eq('You Are A Wonderful Toothbrush')
106
110
  end
107
111
 
108
112
  it 'returns nil if given nil' do
109
- described_class.titleize(nil).should be_nil
113
+ expect(described_class.titleize(nil)).to be_nil
110
114
  end
111
115
  end
112
116
  end
@@ -28,11 +28,11 @@ describe Bumbleworks::Task::Finder do
28
28
  finder = subject.add_query { |wi|
29
29
  wi['fields']['params']['task'] != 'pet_dog'
30
30
  }
31
- finder.map(&:nickname).should =~ [
31
+ expect(finder.map(&:nickname)).to match_array([
32
32
  'eat',
33
33
  'bark',
34
34
  'skip_and_jump'
35
- ]
35
+ ])
36
36
  end
37
37
  end
38
38
 
@@ -43,11 +43,11 @@ describe Bumbleworks::Task::Finder do
43
43
  finder = subject.add_filter { |task|
44
44
  task.nickname != 'pet_dog'
45
45
  }
46
- finder.map(&:nickname).should =~ [
46
+ expect(finder.map(&:nickname)).to match_array([
47
47
  'eat',
48
48
  'bark',
49
49
  'skip_and_jump'
50
- ]
50
+ ])
51
51
  end
52
52
  end
53
53
 
@@ -58,9 +58,9 @@ describe Bumbleworks::Task::Finder do
58
58
  finder = subject.add_subfinder(
59
59
  Bumbleworks::Task::Finder.new.for_role(:cat)
60
60
  )
61
- finder.map(&:nickname).should =~ [
61
+ expect(finder.map(&:nickname)).to match_array([
62
62
  'skip_and_jump'
63
- ]
63
+ ])
64
64
  end
65
65
  end
66
66
 
@@ -69,7 +69,7 @@ describe Bumbleworks::Task::Finder do
69
69
  Bumbleworks.launch!('dog-lifecycle')
70
70
  Bumbleworks.dashboard.wait_for(:cat)
71
71
  tasks = subject.all
72
- tasks.should be_all { |t| t.class == Bumbleworks::Task }
72
+ expect(tasks).to be_all { |t| t.class == Bumbleworks::Task }
73
73
  end
74
74
 
75
75
  it 'uses provided class for task generation' do
@@ -77,31 +77,31 @@ describe Bumbleworks::Task::Finder do
77
77
  Bumbleworks.launch!('dog-lifecycle')
78
78
  Bumbleworks.dashboard.wait_for(:cat)
79
79
  tasks = described_class.new(MyOwnTask).all
80
- tasks.should be_all { |t| t.class == MyOwnTask }
80
+ expect(tasks).to be_all { |t| t.class == MyOwnTask }
81
81
  Object.send(:remove_const, :MyOwnTask)
82
82
  end
83
83
  end
84
84
 
85
85
  describe '#available' do
86
86
  it 'adds both unclaimed and completable filters' do
87
- subject.should_receive(:where_all).with(:unclaimed => true, :completable => true).and_return(subject)
87
+ expect(subject).to receive(:where_all).with(:unclaimed => true, :completable => true).and_return(subject)
88
88
  subject.available
89
89
  end
90
90
 
91
91
  it 'adds OR-ed claimed and not-completable filters if passed false' do
92
- subject.should_receive(:where_any).with(:claimed => true, :completable => false).and_return(subject)
92
+ expect(subject).to receive(:where_any).with(:claimed => true, :completable => false).and_return(subject)
93
93
  subject.available(false)
94
94
  end
95
95
  end
96
96
 
97
97
  describe '#unavailable' do
98
98
  it 'checks if not available' do
99
- subject.should_receive(:available).with(false).and_return(subject)
99
+ expect(subject).to receive(:available).with(false).and_return(subject)
100
100
  subject.unavailable
101
101
  end
102
102
 
103
103
  it 'checks if available when passed false' do
104
- subject.should_receive(:available).with(true).and_return(subject)
104
+ expect(subject).to receive(:available).with(true).and_return(subject)
105
105
  subject.unavailable(false)
106
106
  end
107
107
  end
@@ -109,12 +109,12 @@ describe Bumbleworks::Task::Finder do
109
109
  [:all, :any].each do |join_type|
110
110
  describe "#where_#{join_type}" do
111
111
  it "sets join to #{join_type} if no args" do
112
- subject.should_receive(:join=).with(join_type)
112
+ expect(subject).to receive(:join=).with(join_type)
113
113
  subject.send(:"where_#{join_type}")
114
114
  end
115
115
 
116
116
  it "calls where with :#{join_type} type if args" do
117
- subject.should_receive(:where).with(:filters, join_type)
117
+ expect(subject).to receive(:where).with(:filters, join_type)
118
118
  subject.send(:"where_#{join_type}", :filters)
119
119
  end
120
120
  end
@@ -124,22 +124,22 @@ describe Bumbleworks::Task::Finder do
124
124
  it 'creates a new finder and adds it to queries, when join type mismatch' do
125
125
  parent = described_class.new(:dummy_task_class).where_all
126
126
  child = described_class.new
127
- described_class.stub(:new).with(:dummy_task_class).and_return(child)
128
- child.should_receive(:where_any)
129
- child.should_receive(:available).and_return(child)
130
- child.should_receive(:unavailable).and_return(child)
131
- child.should_receive(:by_nickname).with(:nicholas).and_return(child)
132
- child.should_receive(:for_roles).with([:dinner, :barca]).and_return(child)
133
- child.should_receive(:unclaimed).and_return(child)
134
- child.should_receive(:claimed).and_return(child)
135
- child.should_receive(:for_claimant).with(:dr_clam).and_return(child)
136
- child.should_receive(:for_entity).with(:a_luffly_pirate).and_return(child)
137
- child.should_receive(:for_processes).with([:jasmine, :mulan]).and_return(child)
138
- child.should_receive(:completable).with(true).and_return(child)
139
- child.should_receive(:with_fields).with(:horse => :giant_pony).and_return(child)
140
- child.should_receive(:with_fields).with(:pie => :silly_cake).and_return(child)
141
- parent.should_receive(:add_subfinder).with(child).and_return(parent)
142
- parent.where({
127
+ allow(described_class).to receive(:new).with(:dummy_task_class).and_return(child)
128
+ expect(child).to receive(:where_any)
129
+ expect(child).to receive(:available).and_return(child)
130
+ expect(child).to receive(:unavailable).and_return(child)
131
+ expect(child).to receive(:by_nickname).with(:nicholas).and_return(child)
132
+ expect(child).to receive(:for_roles).with([:dinner, :barca]).and_return(child)
133
+ expect(child).to receive(:unclaimed).and_return(child)
134
+ expect(child).to receive(:claimed).and_return(child)
135
+ expect(child).to receive(:for_claimant).with(:dr_clam).and_return(child)
136
+ expect(child).to receive(:for_entity).with(:a_luffly_pirate).and_return(child)
137
+ expect(child).to receive(:for_processes).with([:jasmine, :mulan]).and_return(child)
138
+ expect(child).to receive(:completable).with(true).and_return(child)
139
+ expect(child).to receive(:with_fields).with(:horse => :giant_pony).and_return(child)
140
+ expect(child).to receive(:with_fields).with(:pie => :silly_cake).and_return(child)
141
+ expect(parent).to receive(:add_subfinder).with(child).and_return(parent)
142
+ expect(parent.where({
143
143
  :available => true,
144
144
  :unavailable => true,
145
145
  :nickname => :nicholas,
@@ -152,24 +152,24 @@ describe Bumbleworks::Task::Finder do
152
152
  :completable => true,
153
153
  :horse => :giant_pony,
154
154
  :pie => :silly_cake
155
- }, :any).should == parent
155
+ }, :any)).to eq parent
156
156
  end
157
157
 
158
158
  it 'adds queries to current finder, when join type matches' do
159
- subject.should_receive(:available).and_return(subject)
160
- subject.should_receive(:unavailable).and_return(subject)
161
- subject.should_receive(:by_nickname).with(:nicholas).and_return(subject)
162
- subject.should_receive(:for_roles).with([:dinner, :barca]).and_return(subject)
163
- subject.should_receive(:unclaimed).and_return(subject)
164
- subject.should_receive(:claimed).and_return(subject)
165
- subject.should_receive(:for_claimant).with(:dr_clam).and_return(subject)
166
- subject.should_receive(:for_entity).with(:a_luffly_pirate).and_return(subject)
167
- subject.should_receive(:for_processes).with([:jasmine, :mulan]).and_return(subject)
168
- subject.should_receive(:completable).with(true).and_return(subject)
169
- subject.should_receive(:with_fields).with(:horse => :giant_pony).and_return(subject)
170
- subject.should_receive(:with_fields).with(:pie => :silly_cake).and_return(subject)
171
- subject.should_receive(:add_subfinder).never
172
- subject.where({
159
+ expect(subject).to receive(:available).and_return(subject)
160
+ expect(subject).to receive(:unavailable).and_return(subject)
161
+ expect(subject).to receive(:by_nickname).with(:nicholas).and_return(subject)
162
+ expect(subject).to receive(:for_roles).with([:dinner, :barca]).and_return(subject)
163
+ expect(subject).to receive(:unclaimed).and_return(subject)
164
+ expect(subject).to receive(:claimed).and_return(subject)
165
+ expect(subject).to receive(:for_claimant).with(:dr_clam).and_return(subject)
166
+ expect(subject).to receive(:for_entity).with(:a_luffly_pirate).and_return(subject)
167
+ expect(subject).to receive(:for_processes).with([:jasmine, :mulan]).and_return(subject)
168
+ expect(subject).to receive(:completable).with(true).and_return(subject)
169
+ expect(subject).to receive(:with_fields).with(:horse => :giant_pony).and_return(subject)
170
+ expect(subject).to receive(:with_fields).with(:pie => :silly_cake).and_return(subject)
171
+ expect(subject).to receive(:add_subfinder).never
172
+ expect(subject.where({
173
173
  :available => true,
174
174
  :unavailable => true,
175
175
  :nickname => :nicholas,
@@ -182,7 +182,7 @@ describe Bumbleworks::Task::Finder do
182
182
  :completable => true,
183
183
  :horse => :giant_pony,
184
184
  :pie => :silly_cake
185
- }).should == subject
185
+ })).to eq subject
186
186
  end
187
187
  end
188
188
  end