neo4j-rspec 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +48 -26
- data/Rakefile +4 -1
- data/lib/neo4j/rspec/matchers/properties.rb +17 -0
- data/lib/neo4j/rspec/matchers/relations.rb +52 -0
- data/lib/neo4j/rspec/matchers.rb +2 -0
- data/lib/neo4j/rspec/version.rb +1 -1
- data/neo4j-rspec.gemspec +1 -1
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cfb94484ad78c24177b2b3d95ec9157d26fd5d3
|
4
|
+
data.tar.gz: aa30199b7e55d6efbdeaa8a30c8126b0ef84cb56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a67537302ca817c9b60782507c48f88e0b82321668bdef26dbe561c3e18f85043b7d185a3ded77990dc6c2db911d12c49619c97407cbd6bebbc7fbed745e7334
|
7
|
+
data.tar.gz: 706b739afb0b3265c8a2dcf042df4a8c37c8d468f1a57e1633b70dd1d04643fd665d240a74d08582dc92e71efa896baca28aec488f0f1dc520f90bcab1eb13f6
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Neo4j::Rspec [![Build Status](https://travis-ci.org/sineed/neo4j-rspec.svg?branch=master)](https://travis-ci.org/sineed/neo4j-rspec)
|
2
2
|
|
3
|
+
This gem contains of several testing one-liners for [neo4j](https://github.com/neo4jrb/neo4j) gem.
|
4
|
+
|
5
|
+
|
3
6
|
## Install
|
7
|
+
|
4
8
|
Add line into your Gemfile:
|
5
9
|
```ruby
|
6
10
|
gem "neo4j-rspec"
|
@@ -11,41 +15,59 @@ or install it directly
|
|
11
15
|
gem install neo4j-rspec
|
12
16
|
```
|
13
17
|
|
18
|
+
|
14
19
|
## Examples
|
15
20
|
|
16
|
-
###
|
21
|
+
### ActiveNode matchers:
|
17
22
|
|
18
|
-
|
19
|
-
it { is_expected.to define_property :general }
|
20
|
-
it { is_expected.to define_property :string, String }
|
21
|
-
it { is_expected.to define_property :boolean, Boolean } # This might need to be `ActiveAttr::Typecasting::Boolean`
|
22
|
-
```
|
23
|
+
- Properties
|
23
24
|
|
25
|
+
```ruby
|
26
|
+
it { is_expected.to define_property :general }
|
27
|
+
it { is_expected.to define_property :string, String }
|
28
|
+
it { is_expected.to define_property :boolean, Boolean } # This might need to be `ActiveAttr::Typecasting::Boolean`
|
29
|
+
```
|
30
|
+
- Relationships
|
24
31
|
|
25
|
-
|
32
|
+
```ruby
|
33
|
+
it { is_expected.to have_many(:comments) }
|
34
|
+
it { is_expected.to have_many(:comments).with_direction(:in) }
|
35
|
+
it { is_expected.to have_many(:comments).with_direction(:in).with_origin(:post) }
|
36
|
+
it { is_expected.to have_many(:written_things).with_direction(:in).without_type.with_model_class([:Post, :Comment]) }
|
37
|
+
```
|
38
|
+
- Constraints
|
26
39
|
|
27
|
-
```ruby
|
28
|
-
it { is_expected.to
|
29
|
-
|
30
|
-
|
31
|
-
it { is_expected.to have_many(:written_things).with_direction(:in).without_type.with_model_class([:Post, :Comment]) }
|
32
|
-
```
|
40
|
+
```ruby
|
41
|
+
it { is_expected.to define_constraint :name, :unique }
|
42
|
+
```
|
43
|
+
- Indexes
|
33
44
|
|
34
|
-
|
45
|
+
```ruby
|
46
|
+
it { is_expected.to define_index(:index_name) }
|
47
|
+
```
|
48
|
+
- Tracking
|
35
49
|
|
36
|
-
```ruby
|
37
|
-
it { is_expected.to
|
38
|
-
|
50
|
+
```ruby
|
51
|
+
it { is_expected.to track_creations } # `created_at`
|
52
|
+
it { is_expected.to track_modifications } # `updated_at`
|
53
|
+
```
|
39
54
|
|
40
|
-
### `created_at` and `updated_at`
|
41
55
|
|
42
|
-
|
43
|
-
it { is_expected.to track_creations } # `created_at`
|
44
|
-
it { is_expected.to track_modifications } # `updated_at`
|
56
|
+
### ActiveRel matchers:
|
45
57
|
|
46
|
-
|
58
|
+
- Directions
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
it { is_expected.to come_from(:Person) }
|
62
|
+
it { is_expected.to lead_to(:any) }
|
63
|
+
```
|
64
|
+
- Types
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
it { is_expected.to have_relationship_type("WROTE") }
|
68
|
+
```
|
69
|
+
|
70
|
+
|
71
|
+
### Need yet another matcher?
|
47
72
|
|
48
|
-
|
49
|
-
- [ ] define_index
|
50
|
-
- [ ] come_from_model
|
51
|
-
- [ ] lead_to_model
|
73
|
+
Welcome! Feel free to post an [issue](https://github.com/sineed/neo4j-rspec/issues/new). Contributions are welcome too.
|
data/Rakefile
CHANGED
@@ -58,6 +58,23 @@ module Neo4j
|
|
58
58
|
"expected the #{model.name} model not to have a #{type} constraint on #{name}"
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
matcher :define_index do |name|
|
63
|
+
fail ArgumentError, 'index name should be given' if name.blank?
|
64
|
+
|
65
|
+
match do |model|
|
66
|
+
model.attributes.key?(name.to_s) &&
|
67
|
+
model.declared_properties[name.to_s].index?
|
68
|
+
end
|
69
|
+
|
70
|
+
failure_message do |model|
|
71
|
+
"expected the #{model.class.name} model to have an exact index on #{name} property"
|
72
|
+
end
|
73
|
+
|
74
|
+
failure_message_when_negated do |model|
|
75
|
+
"expected the #{model.class.name} model not to have an exact index on #{name} property"
|
76
|
+
end
|
77
|
+
end
|
61
78
|
end
|
62
79
|
end
|
63
80
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module RSpec
|
3
|
+
module Matchers
|
4
|
+
module Relations
|
5
|
+
extend ::RSpec::Matchers::DSL
|
6
|
+
|
7
|
+
matcher :come_from do |model_sym|
|
8
|
+
match do |rel|
|
9
|
+
rel.class.from_class == model_sym
|
10
|
+
end
|
11
|
+
|
12
|
+
failure_message do |rel|
|
13
|
+
"expected the #{rel.class.name} relation to come from #{model_sym}"
|
14
|
+
end
|
15
|
+
|
16
|
+
failure_message_when_negated do |rel|
|
17
|
+
"expected the #{rel.class.name} relation not to come from #{model_sym}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
matcher :lead_to do |model_sym|
|
22
|
+
match do |rel|
|
23
|
+
rel.class.to_class == model_sym
|
24
|
+
end
|
25
|
+
|
26
|
+
failure_message do |rel|
|
27
|
+
"expected the #{rel.class.name} relation to lead to #{model_sym}"
|
28
|
+
end
|
29
|
+
|
30
|
+
failure_message_when_negated do |rel|
|
31
|
+
"expected the #{rel.class.name} relation not to lead to #{model_sym}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
matcher :have_relationship_type do |type|
|
36
|
+
match do |rel|
|
37
|
+
rel.type == type
|
38
|
+
end
|
39
|
+
|
40
|
+
failure_message do |rel|
|
41
|
+
"expected the #{rel.class.name} relation to have a relationship type #{type}"
|
42
|
+
end
|
43
|
+
|
44
|
+
failure_message_when_negated do |rel|
|
45
|
+
"expected the #{rel.class.name} relation not to have a relationship type #{type}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
data/lib/neo4j/rspec/matchers.rb
CHANGED
data/lib/neo4j/rspec/version.rb
CHANGED
data/neo4j-rspec.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency "neo4j", "
|
19
|
+
spec.add_dependency "neo4j", "~> 6"
|
20
20
|
spec.add_dependency "rspec", "~> 3.4"
|
21
21
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Tataurov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: neo4j
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6
|
19
|
+
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6
|
26
|
+
version: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.4'
|
41
41
|
description: RSpec matchers for Neo4j.rb
|
@@ -45,9 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .rspec
|
50
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
51
51
|
- Gemfile
|
52
52
|
- LICENSE.txt
|
53
53
|
- README.md
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/neo4j/rspec/matchers.rb
|
57
57
|
- lib/neo4j/rspec/matchers/has_n.rb
|
58
58
|
- lib/neo4j/rspec/matchers/properties.rb
|
59
|
+
- lib/neo4j/rspec/matchers/relations.rb
|
59
60
|
- lib/neo4j/rspec/version.rb
|
60
61
|
- neo4j-rspec.gemspec
|
61
62
|
homepage: https://github.com/sineed/neo4j-rspec
|
@@ -68,18 +69,19 @@ require_paths:
|
|
68
69
|
- lib
|
69
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
71
|
requirements:
|
71
|
-
- -
|
72
|
+
- - ">="
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: '0'
|
74
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
76
|
requirements:
|
76
|
-
- -
|
77
|
+
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
81
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.5.1
|
82
83
|
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: RSpec matchers for Neo4j.rb
|
85
86
|
test_files: []
|
87
|
+
has_rdoc:
|