neo4j-rspec 0.2.0 → 0.2.1
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/.travis.yml +7 -0
- data/README.md +2 -18
- data/lib/neo4j/rspec/compat.rb +34 -0
- data/lib/neo4j/rspec/matchers.rb +1 -0
- data/lib/neo4j/rspec/matchers/properties.rb +10 -3
- data/lib/neo4j/rspec/version.rb +1 -1
- data/neo4j-rspec.gemspec +1 -1
- data/travis.gemfile +4 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c07494702e7a337029d2e268c8d1b2d909d56a3e
|
4
|
+
data.tar.gz: 82fef422106a2c7debb6bdf45297b54354016ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5a523760325d6bd1eb2f1f82977f03ac7ad466906836dc39b364782231b3ae64da9b76ac13056dccb493163571a270a88604c0c43e1a4c6a51fa5558131d67b
|
7
|
+
data.tar.gz: 299ce90f0eb799ab8ce27a093339658e10dcf0603a98ce087499e89d6d758c73f0574aa57914ba99572f72bd45cece894168d8f7e39fd7a8f1913d8d2cc535ca
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
This gem contains of several testing one-liners for [neo4j](https://github.com/neo4jrb/neo4j) gem.
|
4
4
|
|
5
|
-
Current version (0.2.x) supports 7th version of neo4jrb gem. If you use 6th version of neo4jrb gem, try 0.1.2 version.
|
6
|
-
|
7
5
|
## Install
|
8
6
|
|
9
7
|
Add line into your Gemfile:
|
@@ -23,50 +21,36 @@ gem install neo4j-rspec
|
|
23
21
|
|
24
22
|
- Properties
|
25
23
|
|
26
|
-
```ruby
|
27
24
|
it { is_expected.to define_property :general }
|
28
|
-
it { is_expected.to define_property :string, String }
|
29
|
-
it { is_expected.to define_property :boolean,
|
30
|
-
```
|
25
|
+
it { is_expected.to define_property :string, :String }
|
26
|
+
it { is_expected.to define_property :boolean, :Boolean }
|
31
27
|
- Relationships
|
32
28
|
|
33
|
-
```ruby
|
34
29
|
it { is_expected.to have_many(:comments) }
|
35
30
|
it { is_expected.to have_many(:comments).with_direction(:in) }
|
36
31
|
it { is_expected.to have_many(:comments).with_direction(:in).with_origin(:post) }
|
37
32
|
it { is_expected.to have_many(:written_things).with_direction(:in).without_type.with_model_class([:Post, :Comment]) }
|
38
|
-
```
|
39
33
|
- Constraints
|
40
34
|
|
41
|
-
```ruby
|
42
35
|
it { is_expected.to define_constraint :name, :unique }
|
43
|
-
```
|
44
36
|
- Indexes
|
45
37
|
|
46
|
-
```ruby
|
47
38
|
it { is_expected.to define_index(:index_name) }
|
48
|
-
```
|
49
39
|
- Tracking
|
50
40
|
|
51
|
-
```ruby
|
52
41
|
it { is_expected.to track_creations } # `created_at`
|
53
42
|
it { is_expected.to track_modifications } # `updated_at`
|
54
|
-
```
|
55
43
|
|
56
44
|
|
57
45
|
### ActiveRel matchers:
|
58
46
|
|
59
47
|
- Directions
|
60
48
|
|
61
|
-
```ruby
|
62
49
|
it { is_expected.to come_from(:Person) }
|
63
50
|
it { is_expected.to lead_to(:any) }
|
64
|
-
```
|
65
51
|
- Types
|
66
52
|
|
67
|
-
```ruby
|
68
53
|
it { is_expected.to have_relationship_type("WROTE") }
|
69
|
-
```
|
70
54
|
|
71
55
|
|
72
56
|
## Need yet another matcher?
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module RSpec
|
3
|
+
module Compat
|
4
|
+
class << self
|
5
|
+
def current
|
6
|
+
case Neo4j::VERSION
|
7
|
+
when /^6/ then Neo4jrb6.new
|
8
|
+
when /^7/ then Neo4jrb7.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Neo4jrb6
|
14
|
+
def property_nesting
|
15
|
+
ActiveAttr::Typecasting
|
16
|
+
end
|
17
|
+
|
18
|
+
def property_constraint?(attr, type)
|
19
|
+
attr[:constraint] == type
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Neo4jrb7
|
24
|
+
def property_nesting
|
25
|
+
Neo4j::Shared
|
26
|
+
end
|
27
|
+
|
28
|
+
def property_constraint?(attr, type)
|
29
|
+
attr.constraint? type
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/neo4j/rspec/matchers.rb
CHANGED
@@ -28,8 +28,15 @@ module Neo4j
|
|
28
28
|
|
29
29
|
matcher :define_property do |name, type = nil|
|
30
30
|
match do |model|
|
31
|
-
|
32
|
-
|
31
|
+
name = name.to_s
|
32
|
+
return false unless model.attributes.key?(name)
|
33
|
+
|
34
|
+
if type
|
35
|
+
nesting = Neo4j::RSpec::Compat.current.property_nesting
|
36
|
+
[nesting, Module].any? { |md| md.constants.any? { |c| type == c } }
|
37
|
+
else
|
38
|
+
true
|
39
|
+
end
|
33
40
|
end
|
34
41
|
|
35
42
|
failure_message do |model|
|
@@ -47,7 +54,7 @@ module Neo4j
|
|
47
54
|
|
48
55
|
match do |model|
|
49
56
|
model.attributes.key?(name.to_s) &&
|
50
|
-
model.attributes[name.to_s]
|
57
|
+
Neo4j::RSpec::Compat.current.property_constraint?(model.attributes[name.to_s], type)
|
51
58
|
end
|
52
59
|
|
53
60
|
failure_message do |model|
|
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.0.0"
|
20
20
|
spec.add_dependency "rspec", "~> 3.4"
|
21
21
|
end
|
data/travis.gemfile
ADDED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
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-21 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:
|
19
|
+
version: 6.0.0
|
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:
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,12 +53,14 @@ files:
|
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
55
|
- lib/neo4j/rspec.rb
|
56
|
+
- lib/neo4j/rspec/compat.rb
|
56
57
|
- lib/neo4j/rspec/matchers.rb
|
57
58
|
- lib/neo4j/rspec/matchers/has_n.rb
|
58
59
|
- lib/neo4j/rspec/matchers/properties.rb
|
59
60
|
- lib/neo4j/rspec/matchers/relations.rb
|
60
61
|
- lib/neo4j/rspec/version.rb
|
61
62
|
- neo4j-rspec.gemspec
|
63
|
+
- travis.gemfile
|
62
64
|
homepage: https://github.com/sineed/neo4j-rspec
|
63
65
|
licenses:
|
64
66
|
- MIT
|