sandthorn 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 406c440420a9d7f88fe93583721b54b2f5d21248
4
- data.tar.gz: 9f9158b4be2dd23d95e952c9a9649a17a2b6b4c5
3
+ metadata.gz: 974b2f1521c09c03ea633790cdc1de37b47b46fb
4
+ data.tar.gz: 782de64f891f07fc78aff62cd53ebd70b9f05846
5
5
  SHA512:
6
- metadata.gz: cc57b92951bd52e571e2428c33fa81b297bfe6a7a488569fd54cf116f822b5dee4549377adb003344004e4f7868a0aa76086b938cf210b6a45dd378373303a7c
7
- data.tar.gz: 2843b99f89f0b2261b0b554f2812dc198b6d21084cf0890a3d2a0b1540bdb1145c49bcf3a5ffeb78a5f07ce1998201a6a21b3e2a24b5da9a43bb0a440fcf8ab8
6
+ metadata.gz: 9fc7334244668d45c4a39e730ab51dadb468267839638fe299b6c4ea131c964078d9dd2e73cfdd0fe23297ebfc257e7dfb6bab715f3a07996478c1d052f4de67
7
+ data.tar.gz: 86b770a90624c2cfed0a1ae9cae04f07f569c7ed3fb75c297cd5a53a9573180d1888b7f57ea3b39754f5c448bb8da7752e411e6f60346d19a168dc72a79e3d78
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sandthorn (0.4.0)
4
+ sandthorn (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -49,7 +49,7 @@ module Sandthorn
49
49
  aggregate_attribute_deltas = get_delta
50
50
 
51
51
  unless aggregate_attribute_deltas.empty?
52
- method_name = caller_locations(1,1)[0].label.gsub("block in ", "")
52
+ method_name = caller_locations(1,1)[0].label.gsub(/block ?(.*) in /, "")
53
53
  increase_current_aggregate_version!
54
54
 
55
55
  data = {
@@ -1,3 +1,3 @@
1
1
  module Sandthorn
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -44,21 +44,21 @@ describe 'Property Delta Event Sourcing' do
44
44
 
45
45
  it 'should be able to set name' do
46
46
  person.change_name "Klabbarparen"
47
- person.name.should eql("Klabbarparen")
47
+ expect(person.name).to eql("Klabbarparen")
48
48
  #puts person.aggregate_events
49
49
  end
50
50
 
51
51
  it 'should be able to build from events' do
52
52
  person.change_name "Klabbarparen"
53
53
  builded = PersonTest.aggregate_build person.aggregate_events
54
- builded.name.should eql(person.name)
55
- builded.aggregate_id.should eql(person.aggregate_id)
54
+ expect(builded.name).to eql(person.name)
55
+ expect(builded.aggregate_id).to eql(person.aggregate_id)
56
56
  end
57
57
 
58
58
  it 'should not have any events when built up' do
59
59
  person.change_name "Mattias"
60
60
  builded = PersonTest.aggregate_build person.aggregate_events
61
- builded.aggregate_events.should be_empty
61
+ expect(builded.aggregate_events).to be_empty
62
62
  end
63
63
 
64
64
  it 'should detect change on array' do
@@ -66,8 +66,8 @@ describe 'Property Delta Event Sourcing' do
66
66
  person.add_to_array "bar"
67
67
 
68
68
  builded = PersonTest.aggregate_build person.aggregate_events
69
- builded.my_array.should include "Foo"
70
- builded.my_array.should include "bar"
69
+ expect(builded.my_array).to include "Foo"
70
+ expect(builded.my_array).to include "bar"
71
71
  end
72
72
 
73
73
  it 'should detect change on hash' do
@@ -75,8 +75,8 @@ describe 'Property Delta Event Sourcing' do
75
75
  person.add_to_hash :bar, "foo"
76
76
 
77
77
  builded = PersonTest.aggregate_build person.aggregate_events
78
- builded.my_hash[:foo].should eql("bar")
79
- builded.my_hash[:bar].should eql("foo")
78
+ expect(builded.my_hash[:foo]).to eql("bar")
79
+ expect(builded.my_hash[:bar]).to eql("foo")
80
80
 
81
81
  person.add_to_hash :foo, "BAR"
82
82
 
@@ -85,6 +85,6 @@ describe 'Property Delta Event Sourcing' do
85
85
  #puts events
86
86
 
87
87
  builded2 = PersonTest.aggregate_build person.aggregate_events
88
- builded2.my_hash[:foo].should eql("BAR")
88
+ expect(builded2.my_hash[:foo]).to eql("BAR")
89
89
  end
90
90
  end
@@ -82,7 +82,7 @@ module Sandthorn
82
82
 
83
83
  it "should get new_name" do
84
84
  dirty_obejct.change_name "new_name"
85
- dirty_obejct.name.should eql "new_name"
85
+ expect(dirty_obejct.name).to eql "new_name"
86
86
  end
87
87
 
88
88
  it "should generate one event on new" do
@@ -98,7 +98,7 @@ module Sandthorn
98
98
  context "when changing sex (attr)" do
99
99
  it "should get new_sex" do
100
100
  dirty_obejct.change_sex "new_sex"
101
- dirty_obejct.sex.should eql "new_sex"
101
+ expect(dirty_obejct.sex).to eql "new_sex"
102
102
  end
103
103
  end
104
104
 
@@ -181,16 +181,16 @@ describe 'when generating state on an aggregate root' do
181
181
  end
182
182
 
183
183
  it 'account should have properties set' do
184
- @account.balance.should eql 99000
185
- @account.unpaid_interest_balance.should be > 1000
184
+ expect(@account.balance).to eql 99000
185
+ expect(@account.unpaid_interest_balance).to be > 1000
186
186
  end
187
187
 
188
188
  it 'should store snapshot data in aggregate_snapshot' do
189
- @account.aggregate_snapshot.should be_a(Hash)
189
+ expect(@account.aggregate_snapshot).to be_a(Hash)
190
190
  end
191
191
 
192
192
  it 'should store aggregate_version in aggregate_snapshot' do
193
- @account.aggregate_snapshot[:aggregate_version].should eql(@original_account.aggregate_current_event_version)
193
+ expect(@account.aggregate_snapshot[:aggregate_version]).to eql(@original_account.aggregate_current_event_version)
194
194
  end
195
195
 
196
196
  it 'should be able to load up from snapshot' do
@@ -198,14 +198,14 @@ describe 'when generating state on an aggregate root' do
198
198
  events = [@account.aggregate_snapshot]
199
199
  loaded = BankAccount.aggregate_build events
200
200
 
201
- loaded.balance.should eql(@original_account.balance)
202
- loaded.account_number.should eql(@original_account.account_number)
203
- loaded.current_interest_info.should eql(@original_account.current_interest_info)
204
- loaded.account_creation_date.should eql(@original_account.account_creation_date)
205
- loaded.unpaid_interest_balance.should eql(@original_account.unpaid_interest_balance)
206
- loaded.last_interest_calculation.should eql(@original_account.last_interest_calculation)
207
- loaded.aggregate_id.should eql(@original_account.aggregate_id)
208
- loaded.aggregate_originating_version.should eql(@account.aggregate_originating_version)
201
+ expect(loaded.balance).to eql(@original_account.balance)
202
+ expect(loaded.account_number).to eql(@original_account.account_number)
203
+ expect(loaded.current_interest_info).to eql(@original_account.current_interest_info)
204
+ expect(loaded.account_creation_date).to eql(@original_account.account_creation_date)
205
+ expect(loaded.unpaid_interest_balance).to eql(@original_account.unpaid_interest_balance)
206
+ expect(loaded.last_interest_calculation).to eql(@original_account.last_interest_calculation)
207
+ expect(loaded.aggregate_id).to eql(@original_account.aggregate_id)
208
+ expect(loaded.aggregate_originating_version).to eql(@account.aggregate_originating_version)
209
209
 
210
210
  end
211
211
 
@@ -228,27 +228,27 @@ end
228
228
  describe 'when saving to repository' do
229
229
  let(:account) {a_test_account.extend Sandthorn::AggregateRootSnapshot}
230
230
  it 'should raise an error if trying to save before creating a snapshot' do
231
- lambda {account.save_snapshot}.should raise_error (Sandthorn::Errors::SnapshotError)
231
+ expect(lambda {account.save_snapshot}).to raise_error (Sandthorn::Errors::SnapshotError)
232
232
  end
233
233
  it 'should not raise an error if snapshot was created' do
234
234
  account.save
235
235
  account.aggregate_snapshot!
236
- lambda {account.save_snapshot}.should_not raise_error
236
+ expect(lambda {account.save_snapshot}).not_to raise_error
237
237
  end
238
238
  it 'should set aggregate_snapshot to nil' do
239
239
  account.save
240
240
  account.aggregate_snapshot!
241
241
  account.save_snapshot
242
- account.aggregate_snapshot.should eql(nil)
242
+ expect(account.aggregate_snapshot).to eql(nil)
243
243
  end
244
244
 
245
245
  it 'should raise error if trying to create snapshot before events are saved on object' do
246
- lambda {account.aggregate_snapshot!}.should raise_error
246
+ expect(lambda {account.aggregate_snapshot!}).to raise_error
247
247
  end
248
248
 
249
249
  it 'should not raise an error if trying to create snapshot on object when events are saved' do
250
250
  account.save
251
- lambda {account.aggregate_snapshot!}.should_not raise_error
251
+ expect( lambda {account.aggregate_snapshot!}).not_to raise_error
252
252
  end
253
253
 
254
254
  it 'should get snapshot on account find when a snapshot is saved' do
@@ -259,14 +259,14 @@ describe 'when saving to repository' do
259
259
 
260
260
  loaded = BankAccount.find account.aggregate_id
261
261
 
262
- loaded.balance.should eql(account.balance)
263
- loaded.account_number.should eql(account.account_number)
264
- loaded.current_interest_info.should eql(account.current_interest_info)
265
- loaded.account_creation_date.should eql(account.account_creation_date)
266
- loaded.unpaid_interest_balance.should eql(account.unpaid_interest_balance)
267
- loaded.last_interest_calculation.should eql(account.last_interest_calculation)
268
- loaded.aggregate_id.should eql(account.aggregate_id)
269
- loaded.aggregate_originating_version.should eql(account.aggregate_originating_version)
262
+ expect(loaded.balance).to eql(account.balance)
263
+ expect(loaded.account_number).to eql(account.account_number)
264
+ expect(loaded.current_interest_info).to eql(account.current_interest_info)
265
+ expect(loaded.account_creation_date).to eql(account.account_creation_date)
266
+ expect(loaded.unpaid_interest_balance).to eql(account.unpaid_interest_balance)
267
+ expect(loaded.last_interest_calculation).to eql(account.last_interest_calculation)
268
+ expect(loaded.aggregate_id).to eql(account.aggregate_id)
269
+ expect(loaded.aggregate_originating_version).to eql(account.aggregate_originating_version)
270
270
 
271
271
  end
272
272
  end
@@ -50,8 +50,8 @@ describe 'when using complex types in events' do
50
50
  end
51
51
  it 'should be able to build from events' do
52
52
  aggr = IAmComplex.aggregate_build @events
53
- aggr.a_date.should be_a(Date)
54
- aggr.hello.should be_a(Hello)
53
+ expect(aggr.a_date).to be_a(Date)
54
+ expect(aggr.hello).to be_a(Hello)
55
55
  end
56
56
 
57
57
  it 'should detect hello changing' do
@@ -62,14 +62,14 @@ describe 'when using complex types in events' do
62
62
  hello.change_me << "Otroligt"
63
63
  aggr.set_hello! hello
64
64
  builded = IAmComplex.aggregate_build aggr.aggregate_events
65
- builded.hello.change_me.should include "Fantastisk"
66
- builded.hello.change_me.should include "Otroligt"
65
+ expect(builded.hello.change_me).to include "Fantastisk"
66
+ expect(builded.hello.change_me).to include "Otroligt"
67
67
  end
68
68
 
69
69
  it 'should detect foo_bar chaning in hello' do
70
70
  aggr = IAmComplex.aggregate_build @events
71
71
  aggr.set_foo_bar_on_hello "morgan"
72
72
  builded = IAmComplex.aggregate_build aggr.aggregate_events
73
- builded.hello.foo_bar.should eql "morgan"
73
+ expect(builded.hello.foo_bar).to eql "morgan"
74
74
  end
75
75
  end
data/spec/spec_helper.rb CHANGED
@@ -19,7 +19,6 @@ module Helpers
19
19
  end
20
20
 
21
21
  RSpec.configure do |config|
22
- config.treat_symbols_as_metadata_keys_with_true_values = true
23
22
  config.run_all_when_everything_filtered = true
24
23
  config.filter_run :focus
25
24
  config.filter_run_excluding benchmark: true
data/spec/tracing_spec.rb CHANGED
@@ -42,19 +42,19 @@ describe "using a traced change" do
42
42
  simple.aggregate_trace "123" do |traced|
43
43
  traced.go
44
44
  end
45
- simple.events_with_trace_info.last[:trace].should eql("123")
45
+ expect(simple.events_with_trace_info.last[:trace]).to eql("123")
46
46
  end
47
47
  end
48
48
  context "when not tracing" do
49
49
  it "should not have any trace event info at all on new" do
50
50
  suspect = UsualSuspect.new "Ronny"
51
51
  event = suspect.aggregate_events.first
52
- event[:trace].should be_nil
52
+ expect(event[:trace]).to be_nil
53
53
  end
54
54
  it "should not have any trace event info at all on regular event" do
55
55
  suspect = UsualSuspect.new "Ronny"
56
56
  event = suspect.aggregate_events.first
57
- event[:trace].should be_nil
57
+ expect(event[:trace]).to be_nil
58
58
  end
59
59
  end
60
60
  context "when changing aggregate in a traced context" do
@@ -64,7 +64,7 @@ describe "using a traced change" do
64
64
  s.charge_suspect_of_crime! "Theft"
65
65
  end
66
66
  event = suspect.events_with_trace_info.last
67
- event[:trace].should eql "Ture Sventon"
67
+ expect(event[:trace]).to eql "Ture Sventon"
68
68
  end
69
69
 
70
70
  it "should record optional other tracing information" do
@@ -73,7 +73,7 @@ describe "using a traced change" do
73
73
  s.charge_suspect_of_crime! "Murder"
74
74
  end
75
75
  event = suspect.events_with_trace_info.last
76
- event[:trace].should eql trace_info
76
+ expect(event[:trace]).to eql trace_info
77
77
  end
78
78
  end
79
79
  context "when initializing a new aggregate in a traced context" do
@@ -81,7 +81,7 @@ describe "using a traced change" do
81
81
  UsualSuspect.aggregate_trace "Ture Sventon" do
82
82
  suspect = UsualSuspect.new("Sonny").extend Sandthorn::EventInspector
83
83
  event = suspect.events_with_trace_info.first
84
- event[:trace].should eql "Ture Sventon"
84
+ expect(event[:trace]).to eql "Ture Sventon"
85
85
  end
86
86
  end
87
87
  it "should record tracing for all events in the trace block" do
@@ -90,7 +90,7 @@ describe "using a traced change" do
90
90
  suspect = UsualSuspect.new("Sonny").extend Sandthorn::EventInspector
91
91
  suspect.charge_suspect_of_crime! "Hit and run"
92
92
  event = suspect.events_with_trace_info.last
93
- event[:trace].should eql trace_info
93
+ expect(event[:trace]).to eql trace_info
94
94
  end
95
95
  end
96
96
  it "should record tracing for all events in the trace block" do
@@ -99,7 +99,7 @@ describe "using a traced change" do
99
99
  suspect = UsualSuspect.new("Conny").extend Sandthorn::EventInspector
100
100
  suspect.charge_suspect_of_crime! "Desception"
101
101
  event = suspect.events_with_trace_info.last
102
- event[:trace].should eql trace_info
102
+ expect(event[:trace]).to eql trace_info
103
103
  end
104
104
  end
105
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandthorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Krantz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-13 00:00:00.000000000 Z
12
+ date: 2014-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler