rspec-siren 1.0.1 → 1.1.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 +7 -0
- data/README.md +2 -0
- data/lib/rspec/siren/matchers.rb +5 -0
- data/lib/rspec/siren/matchers/has_action.rb +28 -0
- data/lib/rspec/siren/version.rb +1 -1
- data/spec/rspec/siren/matchers/has_action_spec.rb +28 -0
- data/spec/support/matchers_spec_helper.rb +7 -0
- metadata +18 -29
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca0e98d6a5845aa4c98ce536a61f76d3aeeab44b
|
4
|
+
data.tar.gz: 62ffddec4b276b3bb8f67ffe1f4d79dbb3c6513f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea0eed6de9177c5a0d9b9e402085f18994a3e89730724339f2f3db80535e0d7e1311c3272f8adcc4620e9ac1d063fe1b6f42f130279c4ddf59c3574a203c1805
|
7
|
+
data.tar.gz: 268cb5841a31805cd607367a62c5c84a57d7a9233418ebec07604322fdf2c142034ed55fe8ab4166a9769b6554a9819379635ac2eb9d29a1ca985f6a29bd31d4
|
data/README.md
CHANGED
data/lib/rspec/siren/matchers.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Siren
|
3
3
|
module Matchers
|
4
|
+
autoload :HasAction, "rspec/siren/matchers/has_action"
|
4
5
|
autoload :HasClass, "rspec/siren/matchers/has_class"
|
5
6
|
autoload :HasEntities, "rspec/siren/matchers/has_entities"
|
6
7
|
autoload :HasLink, "rspec/siren/matchers/has_link"
|
7
8
|
autoload :HasProperty, "rspec/siren/matchers/has_property"
|
8
9
|
|
10
|
+
def have_action(expected_action)
|
11
|
+
HasAction.new(expected_action)
|
12
|
+
end
|
13
|
+
|
9
14
|
def have_class(expected_class)
|
10
15
|
HasClass.new(expected_class)
|
11
16
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Siren
|
3
|
+
module Matchers
|
4
|
+
class HasAction
|
5
|
+
def initialize(expected)
|
6
|
+
@expected = expected
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(target)
|
10
|
+
@target = target
|
11
|
+
@target[:actions] && safe_actions.map{|a| a[:name].to_s }.include?(@expected)
|
12
|
+
end
|
13
|
+
|
14
|
+
def safe_actions
|
15
|
+
Array(@target[:actions])
|
16
|
+
end
|
17
|
+
|
18
|
+
def description
|
19
|
+
"have siren action '#{@expected}'"
|
20
|
+
end
|
21
|
+
|
22
|
+
def failure_message
|
23
|
+
"expected siren object to have action '#{@expected}' found actions: #{safe_actions.inspect}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/rspec/siren/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe RSpec::Siren::Matchers::HasAction do
|
4
|
+
include RSpec::Siren::Matchers
|
5
|
+
include RSpec::Siren::MatchersSpecHelper
|
6
|
+
|
7
|
+
let(:expected_action) { "update-resource"}
|
8
|
+
let(:matcher) { have_action(expected_action) }
|
9
|
+
subject { matcher }
|
10
|
+
|
11
|
+
context "with correct action" do
|
12
|
+
it { should match_siren }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with incorrect action" do
|
16
|
+
let(:expected_action) { "unknown-action"}
|
17
|
+
|
18
|
+
it { should_not match_siren }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when siren has no actions attribute" do
|
22
|
+
it { should_not match_siren }
|
23
|
+
|
24
|
+
def siren_hash
|
25
|
+
super.merge(actions: nil)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -11,6 +11,7 @@ module RSpec
|
|
11
11
|
links: siren_links,
|
12
12
|
entities: siren_entities,
|
13
13
|
properties: siren_properties,
|
14
|
+
actions: siren_actions,
|
14
15
|
}
|
15
16
|
end
|
16
17
|
|
@@ -37,6 +38,12 @@ module RSpec
|
|
37
38
|
}
|
38
39
|
end
|
39
40
|
|
41
|
+
def siren_actions
|
42
|
+
[
|
43
|
+
{ name: "update-resource" },
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
40
47
|
class MatchSirenMatcher < Struct.new(:siren_hash)
|
41
48
|
def matches?(matcher)
|
42
49
|
@matcher = matcher
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-siren
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Neer Friedman
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.7'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.7'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: RSpec for siren hypermedia
|
@@ -66,8 +59,8 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- .rspec
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
71
64
|
- Gemfile
|
72
65
|
- LICENSE.txt
|
73
66
|
- README.md
|
@@ -75,12 +68,14 @@ files:
|
|
75
68
|
- lib/rspec-siren.rb
|
76
69
|
- lib/rspec/siren.rb
|
77
70
|
- lib/rspec/siren/matchers.rb
|
71
|
+
- lib/rspec/siren/matchers/has_action.rb
|
78
72
|
- lib/rspec/siren/matchers/has_class.rb
|
79
73
|
- lib/rspec/siren/matchers/has_entities.rb
|
80
74
|
- lib/rspec/siren/matchers/has_link.rb
|
81
75
|
- lib/rspec/siren/matchers/has_property.rb
|
82
76
|
- lib/rspec/siren/version.rb
|
83
77
|
- rspec-siren.gemspec
|
78
|
+
- spec/rspec/siren/matchers/has_action_spec.rb
|
84
79
|
- spec/rspec/siren/matchers/has_class_spec.rb
|
85
80
|
- spec/rspec/siren/matchers/has_entities_spec.rb
|
86
81
|
- spec/rspec/siren/matchers/has_link_spec.rb
|
@@ -90,36 +85,30 @@ files:
|
|
90
85
|
homepage: https://github.com/neerfri/rspec-siren
|
91
86
|
licenses:
|
92
87
|
- MIT
|
88
|
+
metadata: {}
|
93
89
|
post_install_message:
|
94
90
|
rdoc_options: []
|
95
91
|
require_paths:
|
96
92
|
- lib
|
97
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
94
|
requirements:
|
100
|
-
- -
|
95
|
+
- - ">="
|
101
96
|
- !ruby/object:Gem::Version
|
102
97
|
version: '0'
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
hash: 3305428063326488227
|
106
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
99
|
requirements:
|
109
|
-
- -
|
100
|
+
- - ">="
|
110
101
|
- !ruby/object:Gem::Version
|
111
102
|
version: '0'
|
112
|
-
segments:
|
113
|
-
- 0
|
114
|
-
hash: 3305428063326488227
|
115
103
|
requirements: []
|
116
104
|
rubyforge_project:
|
117
|
-
rubygems_version:
|
105
|
+
rubygems_version: 2.2.2
|
118
106
|
signing_key:
|
119
|
-
specification_version:
|
107
|
+
specification_version: 4
|
120
108
|
summary: A collection of matchers and helpers for easy testing of siren objects via
|
121
109
|
RSpec
|
122
110
|
test_files:
|
111
|
+
- spec/rspec/siren/matchers/has_action_spec.rb
|
123
112
|
- spec/rspec/siren/matchers/has_class_spec.rb
|
124
113
|
- spec/rspec/siren/matchers/has_entities_spec.rb
|
125
114
|
- spec/rspec/siren/matchers/has_link_spec.rb
|