rails_event_store-rspec 0.17.0 → 0.18.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.
- checksums.yaml +4 -4
- data/Makefile +13 -5
- data/README.md +0 -20
- data/lib/rails_event_store/rspec.rb +5 -0
- data/lib/rails_event_store/rspec/have_applied.rb +11 -5
- data/lib/rails_event_store/rspec/have_published.rb +11 -5
- data/lib/rails_event_store/rspec/matchers.rb +2 -2
- data/lib/rails_event_store/rspec/version.rb +1 -1
- data/rails_event_store-rspec.gemspec +2 -2
- metadata +4 -6
- data/.rspec +0 -1
- data/Rakefile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c4e3f15a413a75d6d702a92e6117eadf75883aa
|
4
|
+
data.tar.gz: cf3870bd87ef79c7b6a9c0f25fc5fe460f66119f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e78c316aeda27e9f5ee2298d9213bf75f517671564f4e13d39f72dadbb08c2a1c8c1473b79afcf4738801bfc32891b4ab765c00e93c920f8e06fcf5b1361712e
|
7
|
+
data.tar.gz: 49a02ff51c3f535babccf1c8d373d37a663260808089049528ebd9fd57c5037fe6efdefb491b30ba84fe738ae7d9da1ac3a8a0cb42536fca2010707edd2fcd27
|
data/Makefile
CHANGED
@@ -1,20 +1,28 @@
|
|
1
|
-
|
1
|
+
GEM_VERSION = `cat ../RES_VERSION`
|
2
|
+
|
3
|
+
install: ## Install gem dependencies
|
2
4
|
@echo "Installing gem dependencies"
|
3
5
|
@bundle install
|
4
6
|
|
5
|
-
install: install-bundler ## Prepare current development environment
|
6
|
-
|
7
7
|
test: ## Run tests
|
8
8
|
@echo "Running basic tests - beware: this won't guarantee build pass"
|
9
9
|
@bundle exec rspec
|
10
10
|
|
11
11
|
mutate: test ## Run mutation tests
|
12
12
|
@echo "Running mutation tests - only 100% free mutation will be accepted"
|
13
|
-
@bundle exec mutant --include lib --require rails_event_store/rspec --use rspec
|
13
|
+
@bundle exec mutant --include lib --require rails_event_store/rspec --use rspec "RailsEventStore::RSpec*" \
|
14
|
+
--ignore-subject "RailsEventStore::RSpec::Matchers#differ"
|
14
15
|
|
15
|
-
|
16
|
+
build:
|
17
|
+
@gem build -V rails_event_store-rspec.gemspec
|
18
|
+
@mkdir -p pkg/
|
19
|
+
@mv rails_event_store-rspec-$(GEM_VERSION).gem pkg/
|
20
|
+
|
21
|
+
release: build
|
22
|
+
@gem push pkg/rails_event_store-rspec-$(GEM_VERSION).gem
|
16
23
|
|
17
24
|
help:
|
18
25
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
19
26
|
|
27
|
+
.PHONY: help
|
20
28
|
.DEFAULT_GOAL := help
|
data/README.md
CHANGED
@@ -12,26 +12,6 @@ end
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
Configure your rspec to include matchers in all examples first:
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
RSpec.configure do |config|
|
19
|
-
config.include ::RailsEventStore::RSpec::Matchers
|
20
|
-
end
|
21
|
-
```
|
22
|
-
|
23
|
-
You can as well choose to have RES matches in particular test file only:
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
RSpec.describe MySubject do
|
27
|
-
include ::RailsEventStore::RSpec::Matchers
|
28
|
-
|
29
|
-
specify do
|
30
|
-
# matchers available here
|
31
|
-
end
|
32
|
-
end
|
33
|
-
```
|
34
|
-
|
35
15
|
### be_event
|
36
16
|
|
37
17
|
The `be_event` matcher enables you to make expectations on a domain event. It exposes fluent interface.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
1
3
|
module RailsEventStore
|
2
4
|
module RSpec
|
3
5
|
NotSupported = Class.new(StandardError)
|
@@ -10,3 +12,6 @@ require "rails_event_store/rspec/have_published"
|
|
10
12
|
require "rails_event_store/rspec/have_applied"
|
11
13
|
require "rails_event_store/rspec/matchers"
|
12
14
|
|
15
|
+
::RSpec.configure do |config|
|
16
|
+
config.include ::RailsEventStore::RSpec::Matchers
|
17
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module RailsEventStore
|
2
2
|
module RSpec
|
3
3
|
class HaveApplied
|
4
|
-
def initialize(*
|
5
|
-
|
6
|
-
@expected = expected
|
4
|
+
def initialize(expected, *expecteds, differ:)
|
5
|
+
@expected = [expected, *expecteds]
|
7
6
|
@matcher = ::RSpec::Matchers::BuiltIn::Include.new(*@expected)
|
7
|
+
@differ = differ
|
8
8
|
end
|
9
9
|
|
10
10
|
def matches?(aggregate_root)
|
11
|
-
events = aggregate_root.__send__(:unpublished_events)
|
12
|
-
@matcher.matches?(events) && matches_count(events, @expected, @count)
|
11
|
+
@events = aggregate_root.__send__(:unpublished_events)
|
12
|
+
@matcher.matches?(@events) && matches_count(@events, @expected, @count)
|
13
13
|
end
|
14
14
|
|
15
15
|
def exactly(count)
|
@@ -26,8 +26,14 @@ module RailsEventStore
|
|
26
26
|
exactly(1)
|
27
27
|
end
|
28
28
|
|
29
|
+
def failure_message
|
30
|
+
differ.diff_as_string(@expected.to_s, @events.to_s)
|
31
|
+
end
|
32
|
+
|
29
33
|
private
|
30
34
|
|
35
|
+
attr_reader :differ
|
36
|
+
|
31
37
|
def matches_count(events, expected, count)
|
32
38
|
return true unless count
|
33
39
|
raise NotSupported if expected.size > 1
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module RailsEventStore
|
2
2
|
module RSpec
|
3
3
|
class HavePublished
|
4
|
-
def initialize(*
|
5
|
-
|
6
|
-
@expected = expected
|
4
|
+
def initialize(expected, *expecteds, differ:)
|
5
|
+
@expected = [expected, *expecteds]
|
7
6
|
@matcher = ::RSpec::Matchers::BuiltIn::Include.new(*@expected)
|
7
|
+
@differ = differ
|
8
8
|
end
|
9
9
|
|
10
10
|
def matches?(event_store)
|
11
|
-
events = @stream_name ? event_store.read_events_backward(@stream_name)
|
11
|
+
@events = @stream_name ? event_store.read_events_backward(@stream_name)
|
12
12
|
: event_store.read_all_streams_backward
|
13
|
-
@matcher.matches?(events) && matches_count(events, @expected, @count)
|
13
|
+
@matcher.matches?(@events) && matches_count(@events, @expected, @count)
|
14
14
|
end
|
15
15
|
|
16
16
|
def exactly(count)
|
@@ -32,8 +32,14 @@ module RailsEventStore
|
|
32
32
|
exactly(1)
|
33
33
|
end
|
34
34
|
|
35
|
+
def failure_message
|
36
|
+
differ.diff_as_string(@expected.to_s, @events.to_s)
|
37
|
+
end
|
38
|
+
|
35
39
|
private
|
36
40
|
|
41
|
+
attr_reader :differ
|
42
|
+
|
37
43
|
def matches_count(events, expected, count)
|
38
44
|
return true unless count
|
39
45
|
raise NotSupported if expected.size > 1
|
@@ -9,11 +9,11 @@ module RailsEventStore
|
|
9
9
|
alias :event :be_an_event
|
10
10
|
|
11
11
|
def have_published(*expected)
|
12
|
-
HavePublished.new(*expected)
|
12
|
+
HavePublished.new(*expected, differ: differ)
|
13
13
|
end
|
14
14
|
|
15
15
|
def have_applied(*expected)
|
16
|
-
HaveApplied.new(*expected)
|
16
|
+
HaveApplied.new(*expected, differ: differ)
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
spec.add_development_dependency "mutant-rspec", "~> 0.8.11"
|
26
26
|
spec.add_development_dependency "rails", "~> 4.2"
|
27
|
-
spec.add_development_dependency "rails_event_store", "~> 0.
|
27
|
+
spec.add_development_dependency "rails_event_store", "~> 0.17.0"
|
28
28
|
|
29
|
-
spec.
|
29
|
+
spec.add_runtime_dependency "rspec", "~> 3.0"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_event_store-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.17.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.17.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,13 +116,11 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
|
-
- ".rspec"
|
120
119
|
- ".travis.yml"
|
121
120
|
- Gemfile
|
122
121
|
- LICENSE
|
123
122
|
- Makefile
|
124
123
|
- README.md
|
125
|
-
- Rakefile
|
126
124
|
- bin/console
|
127
125
|
- bin/setup
|
128
126
|
- lib/rails_event_store/rspec.rb
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|