hydramata-works 0.0.1.prerelease
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.hound.yml +818 -0
- data/.rspec +2 -0
- data/.travis.yml +20 -0
- data/CONTRIBUTING.md +220 -0
- data/Gemfile +36 -0
- data/Guardfile +36 -0
- data/LICENSE +15 -0
- data/README.md +36 -0
- data/Rakefile +47 -0
- data/TODO.md +74 -0
- data/VISION.md +19 -0
- data/app/forms/hydramata/works/entity_form.rb +92 -0
- data/app/forms/hydramata/works/validation_service.rb +78 -0
- data/app/models/hydramata/works/data_definition.rb +57 -0
- data/app/models/hydramata/works/entities.rb +11 -0
- data/app/models/hydramata/works/entity.rb +75 -0
- data/app/models/hydramata/works/predicate.rb +35 -0
- data/app/models/hydramata/works/predicate_presentation_sequences/storage.rb +29 -0
- data/app/models/hydramata/works/predicate_set.rb +44 -0
- data/app/models/hydramata/works/predicate_sets/storage.rb +45 -0
- data/app/models/hydramata/works/predicates.rb +14 -0
- data/app/models/hydramata/works/predicates/storage.rb +33 -0
- data/app/models/hydramata/works/presentation_structure.rb +29 -0
- data/app/models/hydramata/works/property.rb +72 -0
- data/app/models/hydramata/works/property_set.rb +89 -0
- data/app/models/hydramata/works/validations.rb +6 -0
- data/app/models/hydramata/works/value.rb +34 -0
- data/app/models/hydramata/works/work_type.rb +49 -0
- data/app/models/hydramata/works/work_types.rb +14 -0
- data/app/models/hydramata/works/work_types/storage.rb +42 -0
- data/app/parsers/hydramata/works/datastream_parser.rb +36 -0
- data/app/parsers/hydramata/works/datastream_parsers/rdf_ntriples_parser.rb +60 -0
- data/app/parsers/hydramata/works/datastream_parsers/simple_xml_parser.rb +27 -0
- data/app/parsers/hydramata/works/predicate_parser.rb +31 -0
- data/app/parsers/hydramata/works/predicate_parsers/simple_parser.rb +13 -0
- data/app/parsers/hydramata/works/validations_parser.rb +22 -0
- data/app/parsers/hydramata/works/value_parser.rb +26 -0
- data/app/parsers/hydramata/works/value_parsers.rb +27 -0
- data/app/parsers/hydramata/works/value_parsers/date_parser.rb +13 -0
- data/app/parsers/hydramata/works/value_parsers/interrogation_parser.rb +18 -0
- data/app/parsers/hydramata/works/value_parsers/simple_parser.rb +14 -0
- data/app/presenters/hydramata/works/base_presenter.rb +146 -0
- data/app/presenters/hydramata/works/dom_attributes_builder.rb +24 -0
- data/app/presenters/hydramata/works/entity_presenter.rb +67 -0
- data/app/presenters/hydramata/works/fieldset_presenter.rb +54 -0
- data/app/presenters/hydramata/works/property_presenter.rb +51 -0
- data/app/presenters/hydramata/works/value_presenter.rb +60 -0
- data/app/renderers/hydramata/works/entity_renderer.rb +45 -0
- data/app/views/hydramata/works/fieldsets/_edit.html.erb +4 -0
- data/app/views/hydramata/works/fieldsets/_show.html.erb +8 -0
- data/app/views/hydramata/works/fieldsets/_show.json.jbuilder +8 -0
- data/app/views/hydramata/works/properties/_edit.html.erb +12 -0
- data/app/views/hydramata/works/properties/_show.html.erb +3 -0
- data/app/views/hydramata/works/properties/_show.json.jbuilder +1 -0
- data/app/views/hydramata/works/works/_edit.html.erb +8 -0
- data/app/views/hydramata/works/works/_new.html.erb +8 -0
- data/app/views/hydramata/works/works/_show.html.erb +3 -0
- data/app/views/hydramata/works/works/_show.json.jbuilder +13 -0
- data/app/wranglers/hydramata/works/fedora_wrangler.rb +66 -0
- data/bin/rails +12 -0
- data/db/migrate/20140606132349_create_hydramata_work_predicates.rb +13 -0
- data/db/migrate/20140606132350_create_hydramata_work_types.rb +9 -0
- data/db/migrate/20140606132351_create_hydramata_work_predicate_sets.rb +13 -0
- data/db/migrate/20140606132352_create_hydramata_work_predicate_presentation_sequences.rb +12 -0
- data/db/migrate/20140623200635_add_validations_to_predicates.rb +5 -0
- data/db/migrate/20140627134133_adding_item_type_schema_dot_org_to_work_type.rb +5 -0
- data/db/migrate/20140627140840_adding_item_prop_schema_dot_org_to_predicate.rb +5 -0
- data/db/seeds.rb +36 -0
- data/documents/administrative-set-strawperson.md +45 -0
- data/documents/diagrams/hydramata-refactor-tasks.dot +88 -0
- data/documents/diagrams/hydramata-sip-dip-aip.dot +88 -0
- data/documents/diagrams/hydramata-work-architecture.dot +129 -0
- data/documents/diagrams/hydramata-work-subcomponents.dot +36 -0
- data/documents/diagrams/map-from-database-to-work-object.dot +44 -0
- data/documents/diagrams/map-from-fedora-to-work-object.dot +51 -0
- data/documents/diagrams/map-from-input-to-work-object.dot +37 -0
- data/documents/diagrams/map-from-work-object-to-database.dot +31 -0
- data/documents/diagrams/work-rendering.dot +53 -0
- data/documents/diagrams/work-structure.dot +32 -0
- data/documents/handling-work.md +224 -0
- data/documents/high-level-stories.md +105 -0
- data/documents/hydramata-components.md +82 -0
- data/documents/interface-between-work-and-permissions.md +131 -0
- data/documents/interface-between-work-and-workflow.md +6 -0
- data/documents/timeline.md +75 -0
- data/fs +3 -0
- data/gemfiles/rails4.1.gemfile +12 -0
- data/gemfiles/rails4.gemfile +13 -0
- data/hydramata-works.gemspec +43 -0
- data/lib/hydramata-works.rb +23 -0
- data/lib/hydramata/works/conversions.rb +21 -0
- data/lib/hydramata/works/conversions/exceptions.rb +18 -0
- data/lib/hydramata/works/conversions/predicate.rb +22 -0
- data/lib/hydramata/works/conversions/predicate_set.rb +28 -0
- data/lib/hydramata/works/conversions/presented_fieldsets.rb +28 -0
- data/lib/hydramata/works/conversions/presenter.rb +13 -0
- data/lib/hydramata/works/conversions/property.rb +31 -0
- data/lib/hydramata/works/conversions/property_set.rb +23 -0
- data/lib/hydramata/works/conversions/translation_key_fragment.rb +20 -0
- data/lib/hydramata/works/conversions/value.rb +20 -0
- data/lib/hydramata/works/conversions/work_type.rb +26 -0
- data/lib/hydramata/works/engine.rb +31 -0
- data/lib/hydramata/works/linters.rb +99 -0
- data/lib/hydramata/works/linters/implement_data_definition_interface_matcher.rb +17 -0
- data/lib/hydramata/works/linters/implement_entity_interface_matcher.rb +16 -0
- data/lib/hydramata/works/linters/implement_predicate_interface_matcher.rb +17 -0
- data/lib/hydramata/works/linters/implement_predicate_set_interface_matcher.rb +8 -0
- data/lib/hydramata/works/linters/implement_property_set_interface_matcher.rb +8 -0
- data/lib/hydramata/works/linters/implement_value_interface_matcher.rb +8 -0
- data/lib/hydramata/works/linters/implement_work_type_interface_matcher.rb +13 -0
- data/lib/hydramata/works/linters/interface_matcher_builder.rb +36 -0
- data/lib/hydramata/works/translator.rb +67 -0
- data/lib/hydramata/works/version.rb +5 -0
- data/lib/hydramata_works.rb +2 -0
- data/lib/tasks/hydramata_work_tasks.rake +4 -0
- data/run_each_spec_in_isolation +16 -0
- data/run_each_spec_in_isolation.txt +110 -0
- data/script/analyzer.rb +124 -0
- data/script/fast_specs +22 -0
- data/spec/features/fedora_to_in_memory_spec.rb +60 -0
- data/spec/features/format_and_view_path_overrides_spec.rb +72 -0
- data/spec/features/in_memory_to_output_buffer_spec.rb +109 -0
- data/spec/features/instantiate_entity_from_persisted_work_type_spec.rb +26 -0
- data/spec/features/new_user_input_to_in_memory_spec.rb +75 -0
- data/spec/features/translation_services_spec.rb +107 -0
- data/spec/features/validate_entity_based_on_work_type_structure_spec.rb +19 -0
- data/spec/fixtures/cassettes/fedora-object.yml +299 -0
- data/spec/fixtures/translations.yml +20 -0
- data/spec/forms/hydramata/works/entity_form_spec.rb +83 -0
- data/spec/forms/hydramata/works/validation_service_spec.rb +32 -0
- data/spec/lib/hydramata-work_spec.rb +14 -0
- data/spec/lib/hydramata/works/conversions/predicate_set_spec.rb +50 -0
- data/spec/lib/hydramata/works/conversions/predicate_spec.rb +43 -0
- data/spec/lib/hydramata/works/conversions/presented_fieldsets_spec.rb +52 -0
- data/spec/lib/hydramata/works/conversions/presenter_spec.rb +22 -0
- data/spec/lib/hydramata/works/conversions/property_set_spec.rb +42 -0
- data/spec/lib/hydramata/works/conversions/property_spec.rb +68 -0
- data/spec/lib/hydramata/works/conversions/translation_key_fragment_spec.rb +45 -0
- data/spec/lib/hydramata/works/conversions/value_spec.rb +36 -0
- data/spec/lib/hydramata/works/conversions/work_type_spec.rb +55 -0
- data/spec/lib/hydramata/works/translator_spec.rb +81 -0
- data/spec/models/hydramata/works/data_definition_spec.rb +53 -0
- data/spec/models/hydramata/works/entity_spec.rb +50 -0
- data/spec/models/hydramata/works/predicate_presentation_sequences/storage_spec.rb +15 -0
- data/spec/models/hydramata/works/predicate_set_spec.rb +63 -0
- data/spec/models/hydramata/works/predicate_sets/storage_spec.rb +37 -0
- data/spec/models/hydramata/works/predicate_spec.rb +16 -0
- data/spec/models/hydramata/works/predicates/storage_spec.rb +78 -0
- data/spec/models/hydramata/works/predicates_spec.rb +18 -0
- data/spec/models/hydramata/works/presentation_structure_spec.rb +27 -0
- data/spec/models/hydramata/works/property_set_spec.rb +135 -0
- data/spec/models/hydramata/works/property_spec.rb +74 -0
- data/spec/models/hydramata/works/value_spec.rb +61 -0
- data/spec/models/hydramata/works/work_type_spec.rb +45 -0
- data/spec/models/hydramata/works/work_types/storage_spec.rb +74 -0
- data/spec/models/hydramata/works/work_types_spec.rb +16 -0
- data/spec/parsers/hydramata/works/datastream_parser_spec.rb +29 -0
- data/spec/parsers/hydramata/works/datastream_parsers/rdf_ntriples_parser_spec.rb +65 -0
- data/spec/parsers/hydramata/works/datastream_parsers/simple_xml_parser_spec.rb +37 -0
- data/spec/parsers/hydramata/works/predicate_parser_spec.rb +30 -0
- data/spec/parsers/hydramata/works/predicate_parsers/simple_parser_spec.rb +20 -0
- data/spec/parsers/hydramata/works/validations_parser_spec.rb +31 -0
- data/spec/parsers/hydramata/works/value_parser_spec.rb +22 -0
- data/spec/parsers/hydramata/works/value_parsers/simple_parser_spec.rb +20 -0
- data/spec/parsers/hydramata/works/value_parsers_spec.rb +36 -0
- data/spec/presenters/hydramata/works/base_presenter_spec.rb +111 -0
- data/spec/presenters/hydramata/works/dom_attributes_builder_spec.rb +26 -0
- data/spec/presenters/hydramata/works/entity_presenter_spec.rb +51 -0
- data/spec/presenters/hydramata/works/fieldset_presenter_spec.rb +58 -0
- data/spec/presenters/hydramata/works/property_presenter_spec.rb +42 -0
- data/spec/presenters/hydramata/works/value_presenter_spec.rb +49 -0
- data/spec/renderers/hydramata/works/entity_renderer_spec.rb +25 -0
- data/spec/spec_active_record_helper.rb +30 -0
- data/spec/spec_fast_helper.rb +12 -0
- data/spec/spec_slow_helper.rb +56 -0
- data/spec/spec_view_helper.rb +14 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +21 -0
- data/spec/views/hydramata/works/fieldsets/_edit.html.erb_spec.rb +29 -0
- data/spec/views/hydramata/works/fieldsets/_show.html.erb_spec.rb +25 -0
- data/spec/views/hydramata/works/properties/_edit.html.erb_spec.rb +22 -0
- data/spec/views/hydramata/works/properties/_show.html.erb_spec.rb +22 -0
- data/spec/views/hydramata/works/works/_edit.html.erb_spec.rb +23 -0
- data/spec/views/hydramata/works/works/_new.html.erb_spec.rb +23 -0
- data/spec/views/hydramata/works/works/_show.html.erb_spec.rb +24 -0
- data/spec/wranglers/hydramata/works/fedora_wrangler_spec.rb +26 -0
- metadata +466 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_fast_helper'
|
2
|
+
require 'hydramata/works/fieldset_presenter'
|
3
|
+
require 'hydramata/works/entity'
|
4
|
+
require 'hydramata/works/work_type'
|
5
|
+
|
6
|
+
module Hydramata
|
7
|
+
module Works
|
8
|
+
describe FieldsetPresenter do
|
9
|
+
let(:fieldset_class) { Struct.new(:name, :work_type) }
|
10
|
+
let(:fieldset) { fieldset_class.new('my_fieldset', work_type) }
|
11
|
+
let(:work_type) { WorkType.new(identity: 'an entity type') }
|
12
|
+
let(:entity) { Entity.new(work_type: work_type) }
|
13
|
+
let(:template) { double('Template', render: true) }
|
14
|
+
subject { described_class.new(entity: entity, fieldset: fieldset, presentation_context: 'show', template_missing_exception: [RuntimeError]) }
|
15
|
+
|
16
|
+
it 'should render as per the template' do
|
17
|
+
expect(template).to receive(:render).
|
18
|
+
with(partial: 'hydramata/works/fieldsets/an_entity_type/my_fieldset/show', object: subject).
|
19
|
+
ordered.
|
20
|
+
and_raise(RuntimeError)
|
21
|
+
expect(template).to receive(:render).
|
22
|
+
with(partial: 'hydramata/works/fieldsets/my_fieldset/show', object: subject).
|
23
|
+
ordered.
|
24
|
+
and_raise(RuntimeError)
|
25
|
+
expect(template).to receive(:render).
|
26
|
+
with(partial: 'hydramata/works/fieldsets/show', object: subject).
|
27
|
+
ordered.
|
28
|
+
and_return('YES')
|
29
|
+
expect(subject.render(template: template)).to eq('YES')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have #container_content_tag_attributes' do
|
33
|
+
expect(subject.container_content_tag_attributes).to have_key(:class)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have an #work_type' do
|
37
|
+
expect(subject.work_type).to eq(entity.work_type)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should be an instance of the presented object\'s class' do
|
41
|
+
expect(subject.instance_of?(fieldset.class)).to be_truthy
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should also be an instance of the presenter class' do
|
45
|
+
expect(subject.instance_of?(described_class)).to be_truthy
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should have a #dom_class' do
|
49
|
+
expect(subject.dom_class).to eq('my-fieldset')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should have a default partial prefixes' do
|
53
|
+
expect(subject.partial_prefixes).to eq([['an_entity_type', 'my_fieldset'], ['my_fieldset']])
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_fast_helper'
|
2
|
+
require 'hydramata/works/property_presenter'
|
3
|
+
require 'hydramata/works/entity'
|
4
|
+
|
5
|
+
module Hydramata
|
6
|
+
module Works
|
7
|
+
describe PropertyPresenter do
|
8
|
+
let(:entity) { Entity.new(work_type: 'an entity type') }
|
9
|
+
let(:property) { double('Property', predicate: 'my_property') }
|
10
|
+
let(:template) { double('Template', render: true) }
|
11
|
+
subject do
|
12
|
+
described_class.new(
|
13
|
+
property: property,
|
14
|
+
entity: entity,
|
15
|
+
presentation_context: 'show',
|
16
|
+
template_missing_exception: [RuntimeError]
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should attempt to render with diminishing specificity' do
|
21
|
+
expect(template).to receive(:render).
|
22
|
+
with(partial: 'hydramata/works/properties/an_entity_type/my_property/show', object: subject).
|
23
|
+
ordered.
|
24
|
+
and_raise(RuntimeError)
|
25
|
+
expect(template).to receive(:render).
|
26
|
+
with(partial: 'hydramata/works/properties/my_property/show', object: subject).
|
27
|
+
ordered.
|
28
|
+
and_raise(RuntimeError)
|
29
|
+
expect(template).to receive(:render).
|
30
|
+
with(partial: 'hydramata/works/properties/show', object: subject).
|
31
|
+
ordered.
|
32
|
+
and_return('YES')
|
33
|
+
expect(subject.render(template: template)).to eq('YES')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have a default partial prefixes' do
|
37
|
+
expect(subject.partial_prefixes).to eq([['an_entity_type','my_property'], ['my_property']])
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_fast_helper'
|
2
|
+
require 'hydramata/works/value_presenter'
|
3
|
+
require 'hydramata/works/entity'
|
4
|
+
require 'hydramata/works/predicate'
|
5
|
+
|
6
|
+
module Hydramata
|
7
|
+
module Works
|
8
|
+
describe ValuePresenter do
|
9
|
+
let(:entity) { Entity.new(work_type: 'an entity type') }
|
10
|
+
let(:predicate) { Predicate.new(identity: 'a predicate') }
|
11
|
+
let(:value) { double('Value') }
|
12
|
+
let(:template) { double('Template', render: true) }
|
13
|
+
subject do
|
14
|
+
described_class.new(
|
15
|
+
value: value,
|
16
|
+
entity: entity,
|
17
|
+
predicate: predicate,
|
18
|
+
presentation_context: 'show',
|
19
|
+
template_missing_exception: [RuntimeError]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should attempt to render with diminishing specificity' do
|
24
|
+
expect(template).to receive(:render).
|
25
|
+
with(partial: 'hydramata/works/values/an_entity_type/a_predicate/show', object: subject).
|
26
|
+
ordered.
|
27
|
+
and_raise(RuntimeError)
|
28
|
+
expect(template).to receive(:render).
|
29
|
+
with(partial: 'hydramata/works/values/a_predicate/show', object: subject).
|
30
|
+
ordered.
|
31
|
+
and_raise(RuntimeError)
|
32
|
+
expect(template).to receive(:render).
|
33
|
+
with(partial: 'hydramata/works/values/show', object: subject).
|
34
|
+
ordered.
|
35
|
+
and_return('YES')
|
36
|
+
expect(subject.render(template: template)).to eq('YES')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should render the value as a string' do
|
40
|
+
allow(template).to receive(:render).and_raise(RuntimeError)
|
41
|
+
expect(subject.render(template: template)).to eq(value.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should have a default partial prefixes' do
|
45
|
+
expect(subject.partial_prefixes).to eq([['an_entity_type','a_predicate'], ['a_predicate']])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_fast_helper'
|
2
|
+
require 'hydramata/works/entity_renderer'
|
3
|
+
|
4
|
+
module Hydramata
|
5
|
+
module Works
|
6
|
+
describe EntityRenderer do
|
7
|
+
let(:entity) { double('Entity', render: true) }
|
8
|
+
let(:presentation_structure) { double('Presentation Structure') }
|
9
|
+
let(:template) { double('Template') }
|
10
|
+
subject do
|
11
|
+
Hydramata::Works::EntityRenderer.new(entity: entity, format: :html, template: template)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should render the template based on all the inputs' do
|
15
|
+
subject.render
|
16
|
+
expect(entity).to have_received(:render).with(template: template)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should default to :html format' do
|
20
|
+
renderer = Hydramata::Works::EntityRenderer.new(entity: entity, template: template)
|
21
|
+
expect(renderer.format).to eq(:html)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# This helper provides a x2 speed increase over the 'spec_slow_helper'
|
2
|
+
#
|
3
|
+
# To validate this assumption, find a spec for an ActiveRecord object
|
4
|
+
# (eg spec/hydramata/works/predicate_spec.rb)
|
5
|
+
# $ time rspec spec/hydramata/works/predicate_spec.rb
|
6
|
+
#
|
7
|
+
# Then change the "require 'spec_active_record_helper'" to "require 'spec_slow_helper'"
|
8
|
+
# $ time rspec spec/hydramata/works/predicate_spec.rb
|
9
|
+
|
10
|
+
require 'active_record'
|
11
|
+
require 'spec_fast_helper'
|
12
|
+
|
13
|
+
if !defined?(Rails)
|
14
|
+
# Sometimes this will be invoked when Rails is defined. In that case the relative
|
15
|
+
# path is ../internal. When Rails is not defined the relative path is different.
|
16
|
+
# By providing an absolute path, I avoid either of those silly things.
|
17
|
+
database = File.expand_path('../internal/db/development.sqlite3', __FILE__)
|
18
|
+
|
19
|
+
connection_info = { adapter: 'sqlite3', database: database, pool: 5, timeout: 5000 }
|
20
|
+
ActiveRecord::Base.establish_connection(connection_info)
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.around do |example|
|
25
|
+
ActiveRecord::Base.transaction do
|
26
|
+
example.run
|
27
|
+
fail ActiveRecord::Rollback
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
unless defined?(Rails)
|
2
|
+
Dir[File.expand_path('../../app/*', __FILE__)].each do |dir|
|
3
|
+
$LOAD_PATH << dir
|
4
|
+
end
|
5
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
6
|
+
|
7
|
+
unless defined?(require_dependency)
|
8
|
+
def require_dependency(*files)
|
9
|
+
require *files
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Why is this a spec_slow_helper instead of spec_helper
|
2
|
+
# Because it is extremely slow to load all of the following dependencies:
|
3
|
+
#
|
4
|
+
# * SimpleCov
|
5
|
+
# * EngineCart (and therefore the underlying internal Rails application)
|
6
|
+
# * Rails
|
7
|
+
#
|
8
|
+
# But overtime the slowness has grown.
|
9
|
+
ENV['RAILS_ENV'] ||= 'test'
|
10
|
+
if ENV['COV'] || ENV['COVERAGE']
|
11
|
+
require 'simplecov'
|
12
|
+
SimpleCov.start 'rails'
|
13
|
+
SimpleCov.command_name 'spec'
|
14
|
+
end
|
15
|
+
|
16
|
+
if ENV['TRAVIS']
|
17
|
+
require 'coveralls'
|
18
|
+
Coveralls.wear!('rails')
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'engine_cart'
|
22
|
+
require File.expand_path('../internal/config/environment.rb', __FILE__)
|
23
|
+
|
24
|
+
EngineCart.load_application!
|
25
|
+
|
26
|
+
require 'rspec/rails'
|
27
|
+
require 'rspec-html-matchers'
|
28
|
+
require 'database_cleaner'
|
29
|
+
|
30
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
31
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
32
|
+
# Require this file using `require 'spec_helper'` to ensure that it is only
|
33
|
+
# loaded once.
|
34
|
+
#
|
35
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
36
|
+
RSpec.configure do |config|
|
37
|
+
config.run_all_when_everything_filtered = true
|
38
|
+
config.filter_run :focus
|
39
|
+
config.raise_errors_for_deprecations!
|
40
|
+
# Run specs in random order to surface order dependencies. If you find an
|
41
|
+
# order dependency and want to debug it, you can fix the order by providing
|
42
|
+
# the seed, which is printed after each run.
|
43
|
+
# --seed 1234
|
44
|
+
config.order = 'random'
|
45
|
+
|
46
|
+
config.before(:suite) do
|
47
|
+
DatabaseCleaner.strategy = :transaction
|
48
|
+
DatabaseCleaner.clean_with(:truncation)
|
49
|
+
end
|
50
|
+
|
51
|
+
config.around(:each) do |example|
|
52
|
+
DatabaseCleaner.cleaning do
|
53
|
+
example.run
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# I'm deliberately not including this, as I was hoping to keep the views tested
|
2
|
+
# in extreme isolation.
|
3
|
+
# require 'spec_fast_helper'
|
4
|
+
|
5
|
+
require 'active_support'
|
6
|
+
require 'action_view'
|
7
|
+
require 'action_controller'
|
8
|
+
|
9
|
+
require 'active_support/core_ext/hash/reverse_merge'
|
10
|
+
|
11
|
+
require 'rspec/rails'
|
12
|
+
require 'rspec-html-matchers'
|
13
|
+
|
14
|
+
ActionController::Base.prepend_view_path(File.expand_path('../../app/views', __FILE__))
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class TestAppGenerator < Rails::Generators::Base
|
4
|
+
source_root './spec/test_app_templates'
|
5
|
+
|
6
|
+
# if you need to generate any additional configuration
|
7
|
+
# into the test app, this generator will be run immediately
|
8
|
+
# after setting up the application
|
9
|
+
|
10
|
+
# def install_engine
|
11
|
+
# generate 'hydramata-works:install'
|
12
|
+
# end
|
13
|
+
|
14
|
+
def run_migrations
|
15
|
+
rake 'db:create'
|
16
|
+
rake 'hydramata_works:install:migrations'
|
17
|
+
rake 'db:migrate'
|
18
|
+
rake 'db:test:prepare'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_view_helper'
|
2
|
+
|
3
|
+
# As of 3.0.x :type tags are no longer inferred.
|
4
|
+
# This means, without the `type: :view` tag, the render method does not exist
|
5
|
+
# in the example context
|
6
|
+
describe 'hydramata/works/fieldsets/_edit.html.erb', type: :view do
|
7
|
+
let(:form) { double('Form') }
|
8
|
+
let(:object) { double('Object', fieldsets: [fieldset1, fieldset2], dom_class: 'my-dom-class') }
|
9
|
+
|
10
|
+
let(:object) { double('Object', t: true, properties: [property1, property2], dom_class: 'my-dom-class') }
|
11
|
+
|
12
|
+
# A short circuit as the render does not normally
|
13
|
+
let(:property1) { double('Property', render: '<div class="property1">Property 1</div>'.html_safe) }
|
14
|
+
let(:property2) { double('Property', render: '<div class="property2">Property 2</div>'.html_safe) }
|
15
|
+
|
16
|
+
it 'renders the object and fieldsets' do
|
17
|
+
expect(object).to receive(:t).with(:name).and_return('Heading')
|
18
|
+
render partial: 'hydramata/works/fieldsets/edit', object: object, locals: { form: form }
|
19
|
+
|
20
|
+
expect(property1).to have_received(:render).with(template: view, locals: { form: form } )
|
21
|
+
expect(property2).to have_received(:render).with(template: view, locals: { form: form } )
|
22
|
+
expect(rendered).to have_tag('fieldset.my-dom-class.fieldset') do
|
23
|
+
with_tag('caption', text: 'Heading')
|
24
|
+
with_tag('.property1', text: 'Property 1')
|
25
|
+
with_tag('.property2', text: 'Property 2')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_view_helper'
|
2
|
+
|
3
|
+
# As of 3.0.x :type tags are no longer inferred.
|
4
|
+
# This means, without the `type: :view` tag, the render method does not exist
|
5
|
+
# in the example context
|
6
|
+
describe 'hydramata/works/fieldsets/_show.html.erb', type: :view do
|
7
|
+
let(:object) { double('Object', t: true, properties: [property1, property2], container_content_tag_attributes: { class: 'my-dom-class' } ) }
|
8
|
+
|
9
|
+
# A short circuit as the render does not normally
|
10
|
+
let(:property1) { double('Property', render: '<div class="property1">Property 1</div>'.html_safe) }
|
11
|
+
let(:property2) { double('Property', render: '<div class="property2">Property 2</div>'.html_safe) }
|
12
|
+
|
13
|
+
it 'renders the object and fieldsets' do
|
14
|
+
expect(object).to receive(:t).with(:name).and_return('Heading')
|
15
|
+
render partial: 'hydramata/works/fieldsets/show', object: object
|
16
|
+
|
17
|
+
expect(property1).to have_received(:render).with(template: view)
|
18
|
+
expect(property2).to have_received(:render).with(template: view)
|
19
|
+
expect(rendered).to have_tag('section.my-dom-class') do
|
20
|
+
with_tag('.heading', text: 'Heading')
|
21
|
+
with_tag('.metadata .property1', text: 'Property 1')
|
22
|
+
with_tag('.metadata .property2', text: 'Property 2')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_view_helper'
|
2
|
+
|
3
|
+
# As of 3.0.x :type tags are no longer inferred.
|
4
|
+
# This means, without the `type: :view` tag, the render method does not exist
|
5
|
+
# in the example context
|
6
|
+
describe 'hydramata/works/properties/_edit.html.erb', type: :view do
|
7
|
+
let(:object) { double('Object', predicate: 'my_predicate', t: true, dom_class: 'my-dom-class') }
|
8
|
+
let(:form) { double('Form') }
|
9
|
+
|
10
|
+
it 'renders the object and fieldsets' do
|
11
|
+
expect(object).to receive(:each_with_index).and_yield('value1', 0).and_yield('value2', 1)
|
12
|
+
expect(object).to receive(:t).with(:predicate).and_return('Label')
|
13
|
+
render partial: 'hydramata/works/properties/edit', object: object, locals: { form: form }
|
14
|
+
|
15
|
+
expect(rendered).to have_tag('.my-dom-class') do
|
16
|
+
with_tag('label', text: 'Label')
|
17
|
+
with_tag('.values input#work_my_predicate_0', value: '', with: { name: 'work[my_predicate][]' })
|
18
|
+
with_tag('.values input#work_my_predicate_1', value: 'value1', with: { name: 'work[my_predicate][]' })
|
19
|
+
with_tag('.values input#work_my_predicate_2', value: 'value2', with: { name: 'work[my_predicate][]' })
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_view_helper'
|
2
|
+
|
3
|
+
# As of 3.0.x :type tags are no longer inferred.
|
4
|
+
# This means, without the `type: :view` tag, the render method does not exist
|
5
|
+
# in the example context
|
6
|
+
describe 'hydramata/works/properties/_show.html.erb', type: :view do
|
7
|
+
let(:value1) { double('Value 1', render: '<dd class="my-dom-class value">value1</dd>'.html_safe ) }
|
8
|
+
let(:value2) { double('Value 2', render: '<dd class="my-dom-class value">value2</dd>'.html_safe ) }
|
9
|
+
let(:object) { double('Object', t: true, dom_class: 'my-dom-class', values: [value1, value2]) }
|
10
|
+
|
11
|
+
it 'renders the object and fieldsets' do
|
12
|
+
expect(object).to receive(:container_content_tag_attributes).with(class: 'label').and_return(class: ['my-dom-class', 'label'])
|
13
|
+
expect(object).to receive(:container_content_tag_attributes).with(class: 'value').and_return(class: ['my-dom-class', 'value']).at_least(1).times
|
14
|
+
expect(object).to receive(:t).with(:name).and_return('Label')
|
15
|
+
render partial: 'hydramata/works/properties/show', object: object
|
16
|
+
|
17
|
+
expect(rendered).to have_tag('.my-dom-class.label', text: 'Label')
|
18
|
+
expect(rendered).to have_tag('.my-dom-class.value', text: 'value1')
|
19
|
+
expect(rendered).to have_tag('.my-dom-class.value', text: 'value2')
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_view_helper'
|
2
|
+
|
3
|
+
# As of 3.0.x :type tags are no longer inferred.
|
4
|
+
# This means, without the `type: :view` tag, the render method does not exist
|
5
|
+
# in the example context
|
6
|
+
describe 'hydramata/works/works/_edit.html.erb', type: :view do
|
7
|
+
let(:object) { double('Object', fieldsets: [fieldset1, fieldset2], dom_class: 'my-dom-class') }
|
8
|
+
|
9
|
+
# A short circuit as the render does not normally
|
10
|
+
let(:fieldset1) { double('Fieldset', render: '<div class="set1">Fieldset 1</div>'.html_safe) }
|
11
|
+
let(:fieldset2) { double('Fieldset', render: '<div class="set2">Fieldset 2</div>'.html_safe) }
|
12
|
+
|
13
|
+
it 'renders the object and fieldsets' do
|
14
|
+
render partial: 'hydramata/works/works/edit', object: object
|
15
|
+
|
16
|
+
expect(fieldset1).to have_received(:render).with(template: view, locals: { form: kind_of(ActionView::Helpers::FormBuilder) })
|
17
|
+
expect(fieldset2).to have_received(:render).with(template: view, locals: { form: kind_of(ActionView::Helpers::FormBuilder) })
|
18
|
+
expect(rendered).to have_tag('form.work.my-dom-class') do
|
19
|
+
with_tag('.set1', text: 'Fieldset 1')
|
20
|
+
with_tag('.set2', text: 'Fieldset 2')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|