hyrax-spec 0.1.0 → 0.2.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/.gitignore +2 -0
- data/CHANGELOG.md +18 -0
- data/lib/hyrax/spec/matchers.rb +1 -0
- data/lib/hyrax/spec/matchers/act.rb +79 -0
- data/lib/hyrax/spec/matchers/have_editable_property.rb +1 -1
- data/lib/hyrax/spec/shared_examples.rb +7 -0
- data/lib/hyrax/spec/shared_examples/basic_metadata.rb +159 -0
- data/lib/hyrax/spec/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56f98b28611537d25097f62fbb3fc0a29134a528
|
4
|
+
data.tar.gz: 05bbf255025da7828354c8c789066666fbd7cedc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a56166d2f65ffaffced6e014e655564804f9f80bfd154b2de60c64b5a1f3d41a0629c7cc2f49317c7f94719be3531d377309506a35ecd9e3bf1e0d8c442a3a42
|
7
|
+
data.tar.gz: c7e4601bc82514dd2d978806bb9453f05d11bd6ae17e9bcaa55404b5e2a5f281b60bc7e22c47021102787b710fefceb2304bd04b4cc0e5668908f848d8d1c523
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
v0.2.0 -- 2017-11-21
|
3
|
+
--------------------
|
4
|
+
|
5
|
+
- Introduce shared examples for Hyrax metadata
|
6
|
+
- 'a model with hyrax core metadata'
|
7
|
+
- 'a model with hyrax basic metadata'
|
8
|
+
- Add `acts` matcher for testing `Hyrax::Actors` c56248d
|
9
|
+
- Bugfix for `have_editable_property` failure reporting. 3a5af61
|
10
|
+
|
11
|
+
v0.1.0 -- 2017-11-07
|
12
|
+
--------------------
|
13
|
+
|
14
|
+
- Initial Release
|
15
|
+
- Add initial Hyrax matchers
|
16
|
+
- `have_editable_property`
|
17
|
+
- `have_form_field`
|
18
|
+
- `list_index_fields`
|
data/lib/hyrax/spec/matchers.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
RSpec::Matchers.define :act do
|
2
|
+
fake_actor = Class.new do
|
3
|
+
attr_reader :created, :updated, :destroyed
|
4
|
+
|
5
|
+
def create(*)
|
6
|
+
@created = true
|
7
|
+
end
|
8
|
+
|
9
|
+
def update(*)
|
10
|
+
@updated = true
|
11
|
+
end
|
12
|
+
|
13
|
+
def destroy(*)
|
14
|
+
@destroyed = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
fail_actor = Class.new do
|
19
|
+
def create(*)
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def update(*)
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
def destroy(*)
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
match do |actor_class|
|
33
|
+
env ||= instance_double(Hyrax::Actors::Environment, curation_concern: nil)
|
34
|
+
@next_actor = fake_actor.new
|
35
|
+
actor = actor_class.new(@next_actor)
|
36
|
+
@create = actor.create(env)
|
37
|
+
@update = actor.update(env)
|
38
|
+
@destroy = actor.destroy(env)
|
39
|
+
|
40
|
+
failure_actor = actor_class.new(fail_actor.new)
|
41
|
+
@fail_create = failure_actor.create(env)
|
42
|
+
@fail_update = failure_actor.update(env)
|
43
|
+
@fail_destroy = failure_actor.destroy(env)
|
44
|
+
|
45
|
+
return false unless @next_actor.created && @next_actor.updated && @next_actor.destroyed
|
46
|
+
return false unless (@succeed && @create && @update && @destroy) ||
|
47
|
+
(!@succeed && !@create && !@update && !@destroy)
|
48
|
+
return false unless (!@recover && !@fail_create && !@fail_update && !@fail_destroy) ||
|
49
|
+
(@recover && @fail_create && @fail_update && @fail_destroy)
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
chain :and_succeed do
|
54
|
+
@succeed = true
|
55
|
+
end
|
56
|
+
|
57
|
+
chain :and_recover do
|
58
|
+
@recover = true
|
59
|
+
end
|
60
|
+
|
61
|
+
chain :with_env, :env
|
62
|
+
|
63
|
+
failure_message do |actor|
|
64
|
+
msg = "expected #{actor.class} to behave like a Hyrax::Actor but"
|
65
|
+
msg += "\n\t#create returned #{@create}" unless @create == true || !@succeed
|
66
|
+
msg += "\n\t#create was not called on the next actor" unless @next_actor.created
|
67
|
+
msg += "\n\tunexpectedly recovered from failure on #create" unless @recover || !@fail_create
|
68
|
+
msg += "\n\tdid not recover from failure on #create" unless !@recover || @fail_create
|
69
|
+
msg += "\n\t#update returned #{@update}" unless @update == true || !@succeed
|
70
|
+
msg += "\n\t#update was not called on the next actor" unless @next_actor.updated
|
71
|
+
msg += "\n\tunexpectedly recovered from failure on #update" unless @recover || !@fail_update
|
72
|
+
msg += "\n\tdid not recover from failure on #update" unless !@recover || @fail_update
|
73
|
+
msg += "\n\t#destroy returned #{@destroy}" unless @destroy == true || !@succeed
|
74
|
+
msg += "\n\t#destroy was not called on the next actor" unless @next_actor.destroyed
|
75
|
+
msg += "\n\tunexpectedly recovered from failure on #destroy" unless @recover || !@fail_destroy
|
76
|
+
msg += "\n\tdid not recover from failure on #destroy" unless !@recover || @fail_destroy
|
77
|
+
msg
|
78
|
+
end
|
79
|
+
end
|
@@ -44,7 +44,7 @@ RSpec::Matchers.define :have_editable_property do |property, predicate|
|
|
44
44
|
|
45
45
|
return msg + "\n\tNo property for `#{property}` was found." if @missing_property
|
46
46
|
|
47
|
-
msg += "\n\tThe configured predicate was #{actual_predicate.to_base}" unless
|
47
|
+
msg += "\n\tThe configured predicate was #{@actual_predicate.to_base}" unless
|
48
48
|
@actual_predicate == predicate
|
49
49
|
msg
|
50
50
|
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
RSpec.shared_examples 'a model with hyrax core metadata' do |**opts|
|
2
|
+
subject(:model) { described_class.new }
|
3
|
+
let(:except) { Array(opts[:except]) }
|
4
|
+
|
5
|
+
it do
|
6
|
+
skip if except.include?(:date_modified)
|
7
|
+
is_expected
|
8
|
+
.to have_editable_property(:date_modified)
|
9
|
+
.with_predicate(RDF::Vocab::DC.modified)
|
10
|
+
.as_single_valued
|
11
|
+
end
|
12
|
+
|
13
|
+
it do
|
14
|
+
skip if except.include?(:date_uploaded)
|
15
|
+
is_expected
|
16
|
+
.to have_editable_property(:date_uploaded)
|
17
|
+
.with_predicate(RDF::Vocab::DC.dateSubmitted)
|
18
|
+
.as_single_valued
|
19
|
+
end
|
20
|
+
|
21
|
+
it do
|
22
|
+
skip if except.include?(:depositor)
|
23
|
+
is_expected
|
24
|
+
.to have_editable_property(:depositor)
|
25
|
+
.with_predicate(RDF::Vocab::MARCRelators.dpt)
|
26
|
+
.as_single_valued
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#first_title' do
|
30
|
+
it 'is nil when empty' do
|
31
|
+
skip if except.include?(:first_title) || except.include?(:title)
|
32
|
+
expect(model.first_title).to be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'is a single title' do
|
36
|
+
skip if except.include?(:first_title) || except.include?(:title)
|
37
|
+
expect { model.title = ['Comet in Moominland', 'Moomin Midwinter'] }
|
38
|
+
.to change { model.first_title }
|
39
|
+
.to an_instance_of(String)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it do
|
44
|
+
skip if except.include?(:title)
|
45
|
+
is_expected.to have_editable_property(:title, RDF::Vocab::DC.title)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
RSpec.shared_examples 'a model with hyrax basic metadata' do |**opts|
|
50
|
+
subject(:model) { described_class.new }
|
51
|
+
let(:except) { Array(opts[:except]) }
|
52
|
+
|
53
|
+
it_behaves_like 'a model with hyrax core metadata', opts
|
54
|
+
|
55
|
+
it do
|
56
|
+
skip if except.include?(:label)
|
57
|
+
is_expected
|
58
|
+
.to have_editable_property(:label)
|
59
|
+
.with_predicate('info:fedora/fedora-system:def/model#downloadFilename')
|
60
|
+
.as_single_valued
|
61
|
+
end
|
62
|
+
|
63
|
+
it do
|
64
|
+
skip if except.include?(:relative_path)
|
65
|
+
is_expected
|
66
|
+
.to have_editable_property(:relative_path)
|
67
|
+
.with_predicate('http://scholarsphere.psu.edu/ns#relativePath')
|
68
|
+
.as_single_valued
|
69
|
+
end
|
70
|
+
|
71
|
+
it do
|
72
|
+
skip if except.include?(:import_url)
|
73
|
+
is_expected
|
74
|
+
.to have_editable_property(:import_url)
|
75
|
+
.with_predicate('http://scholarsphere.psu.edu/ns#importUrl')
|
76
|
+
.as_single_valued
|
77
|
+
end
|
78
|
+
|
79
|
+
it do
|
80
|
+
skip if except.include?(:bibliographic_citation)
|
81
|
+
is_expected.to have_editable_property(:bibliographic_citation, RDF::Vocab::DC.bibliographicCitation)
|
82
|
+
end
|
83
|
+
|
84
|
+
it do
|
85
|
+
skip if except.include?(:contributor)
|
86
|
+
is_expected.to have_editable_property(:contributor, RDF::Vocab::DC11.contributor)
|
87
|
+
end
|
88
|
+
|
89
|
+
it do
|
90
|
+
skip if except.include?(:creator)
|
91
|
+
is_expected.to have_editable_property(:creator, RDF::Vocab::DC11.creator)
|
92
|
+
end
|
93
|
+
|
94
|
+
it do
|
95
|
+
skip if except.include?(:date_created)
|
96
|
+
is_expected.to have_editable_property(:date_created, RDF::Vocab::DC.created)
|
97
|
+
end
|
98
|
+
|
99
|
+
it do
|
100
|
+
skip if except.include?(:description)
|
101
|
+
is_expected.to have_editable_property(:description, RDF::Vocab::DC11.description)
|
102
|
+
end
|
103
|
+
|
104
|
+
it do
|
105
|
+
skip if except.include?(:identifier)
|
106
|
+
is_expected.to have_editable_property(:identifier, RDF::Vocab::DC.identifier)
|
107
|
+
end
|
108
|
+
|
109
|
+
it do
|
110
|
+
skip if except.include?(:keyword)
|
111
|
+
is_expected.to have_editable_property(:keyword, RDF::Vocab::DC11.relation)
|
112
|
+
end
|
113
|
+
|
114
|
+
it do
|
115
|
+
skip if except.include?(:language)
|
116
|
+
is_expected.to have_editable_property(:language, RDF::Vocab::DC11.language)
|
117
|
+
end
|
118
|
+
|
119
|
+
it do
|
120
|
+
skip if except.include?(:license)
|
121
|
+
is_expected.to have_editable_property(:license, RDF::Vocab::DC.rights)
|
122
|
+
end
|
123
|
+
|
124
|
+
it do
|
125
|
+
skip if except.include?(:publisher)
|
126
|
+
is_expected.to have_editable_property(:publisher, RDF::Vocab::DC11.publisher)
|
127
|
+
end
|
128
|
+
|
129
|
+
it do
|
130
|
+
skip if except.include?(:related_url)
|
131
|
+
is_expected.to have_editable_property(:related_url, RDF::RDFS.seeAlso)
|
132
|
+
end
|
133
|
+
|
134
|
+
it do
|
135
|
+
skip if except.include?(:resource_type)
|
136
|
+
is_expected.to have_editable_property(:resource_type, RDF::Vocab::DC.type)
|
137
|
+
end
|
138
|
+
|
139
|
+
it do
|
140
|
+
skip if except.include?(:rights_statement)
|
141
|
+
is_expected.to have_editable_property(:rights_statement, RDF::Vocab::EDM.rights)
|
142
|
+
end
|
143
|
+
|
144
|
+
it do
|
145
|
+
skip if except.include?(:source)
|
146
|
+
is_expected.to have_editable_property(:source, RDF::Vocab::DC.source)
|
147
|
+
end
|
148
|
+
|
149
|
+
it do
|
150
|
+
skip if except.include?(:subject)
|
151
|
+
is_expected.to have_editable_property(:subject, RDF::Vocab::DC11.subject)
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#based_near' do
|
155
|
+
it 'builds as a location'
|
156
|
+
it 'is controlled'
|
157
|
+
it 'accepts nested attributes'
|
158
|
+
end
|
159
|
+
end
|
data/lib/hyrax/spec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyrax-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rubocop.yml"
|
64
64
|
- ".travis.yml"
|
65
|
+
- CHANGELOG.md
|
65
66
|
- Gemfile
|
66
67
|
- Guardfile
|
67
68
|
- LICENSE
|
@@ -70,9 +71,12 @@ files:
|
|
70
71
|
- hyrax-spec.gemspec
|
71
72
|
- lib/hyrax/spec.rb
|
72
73
|
- lib/hyrax/spec/matchers.rb
|
74
|
+
- lib/hyrax/spec/matchers/act.rb
|
73
75
|
- lib/hyrax/spec/matchers/have_editable_property.rb
|
74
76
|
- lib/hyrax/spec/matchers/have_form_field.rb
|
75
77
|
- lib/hyrax/spec/matchers/list_index_fields.rb
|
78
|
+
- lib/hyrax/spec/shared_examples.rb
|
79
|
+
- lib/hyrax/spec/shared_examples/basic_metadata.rb
|
76
80
|
- lib/hyrax/spec/version.rb
|
77
81
|
- spec/hyrax/spec/spec_helper.rb
|
78
82
|
- spec/hyrax/spec/version_spec.rb
|