hyrax-spec 0.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/.gitignore +1 -0
 - data/.rubocop.yml +13 -0
 - data/.travis.yml +19 -0
 - data/Gemfile +13 -0
 - data/Guardfile +18 -0
 - data/LICENSE +13 -0
 - data/README.md +10 -0
 - data/Rakefile +25 -0
 - data/hyrax-spec.gemspec +28 -0
 - data/lib/hyrax/spec.rb +15 -0
 - data/lib/hyrax/spec/matchers.rb +13 -0
 - data/lib/hyrax/spec/matchers/have_editable_property.rb +51 -0
 - data/lib/hyrax/spec/matchers/have_form_field.rb +70 -0
 - data/lib/hyrax/spec/matchers/list_index_fields.rb +30 -0
 - data/lib/hyrax/spec/version.rb +5 -0
 - data/spec/hyrax/spec/spec_helper.rb +1 -0
 - data/spec/hyrax/spec/version_spec.rb +5 -0
 - data/spec/hyrax/spec_spec.rb +5 -0
 - data/spec/spec_helper.rb +24 -0
 - metadata +109 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 201d0cd5f1c435e883f7a18f573c14d367490e1b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a8af2de8319a29318c3da006e60a93b98f6160a9
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6f01717f038d919a22bf265850c78d8fdadb845cca0e9e34dc5a47d1eeeb08b8f07f1dc9b0561594b1108ea361d3c9d8150bd09116b5e8497b54b47b6032626d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b524cf308449c9131382e182992b6e96e927c7611d9f40aa8c00a753788302160061973729aab3a8452a2eeef0dba4228c04112da4d06736ae2bf1510da6d754
         
     | 
    
        data/.gitignore
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gemfile.lock
         
     | 
    
        data/.rubocop.yml
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    | 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
            source "https://rubygems.org"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            # Please see hyrax-spec.gemspec for dependency information.
         
     | 
| 
      
 5 
     | 
    
         
            +
            gemspec
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            group :development, :test do
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'coveralls',   require: false
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem 'guard-rspec', require: false
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem 'pry'          unless ENV['CI']
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem 'pry-byebug'   unless ENV['CI']
         
     | 
| 
      
 12 
     | 
    
         
            +
              gem 'simplecov',   require: false
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
    
        data/Guardfile
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # A Guardfile
         
     | 
| 
      
 2 
     | 
    
         
            +
            # More info at https://github.com/guard/guard#readme
         
     | 
| 
      
 3 
     | 
    
         
            +
            guard :rspec, cmd: "bundle exec rspec" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              require "guard/rspec/dsl"
         
     | 
| 
      
 5 
     | 
    
         
            +
              dsl = Guard::RSpec::Dsl.new(self)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              # Feel free to open issues for suggestions and improvements
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              # RSpec files
         
     | 
| 
      
 10 
     | 
    
         
            +
              rspec = dsl.rspec
         
     | 
| 
      
 11 
     | 
    
         
            +
              watch(rspec.spec_helper) { rspec.spec_dir }
         
     | 
| 
      
 12 
     | 
    
         
            +
              watch(rspec.spec_support) { rspec.spec_dir }
         
     | 
| 
      
 13 
     | 
    
         
            +
              watch(rspec.spec_files)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              # Ruby files
         
     | 
| 
      
 16 
     | 
    
         
            +
              ruby = dsl.ruby
         
     | 
| 
      
 17 
     | 
    
         
            +
              dsl.watch_spec_files_for(ruby.lib_files)
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
               Copyright 2017 Data Curation Experts, LLC
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
               Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
      
 4 
     | 
    
         
            +
               you may not use this file except in compliance with the License.
         
     | 
| 
      
 5 
     | 
    
         
            +
               You may obtain a copy of the License at
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                   http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
               Unless required by applicable law or agreed to in writing, software
         
     | 
| 
      
 10 
     | 
    
         
            +
               distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
      
 11 
     | 
    
         
            +
               WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
      
 12 
     | 
    
         
            +
               See the License for the specific language governing permissions and
         
     | 
| 
      
 13 
     | 
    
         
            +
               limitations under the License.
         
     | 
    
        data/README.md
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env rake
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            begin
         
     | 
| 
      
 4 
     | 
    
         
            +
              require 'bundler/setup'
         
     | 
| 
      
 5 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 6 
     | 
    
         
            +
              puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
         
     | 
| 
      
 7 
     | 
    
         
            +
            end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'rubocop/rake_task'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Bundler::GemHelper.install_tasks
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            desc 'Run style checker'
         
     | 
| 
      
 15 
     | 
    
         
            +
            RuboCop::RakeTask.new(:rubocop) do |task|
         
     | 
| 
      
 16 
     | 
    
         
            +
              task.fail_on_error = true
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            desc 'Run specs'
         
     | 
| 
      
 20 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:spec)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            desc 'Check style and run specs'
         
     | 
| 
      
 23 
     | 
    
         
            +
            task ci: ['rubocop', 'spec']
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            task default: :ci
         
     | 
    
        data/hyrax-spec.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'hyrax/spec/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.authors       = ['Tom Johnson']
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.email         = ['tom@curationexperts.com']
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.description   = 'Shared tests, matchers, and smoke tests for the Hyrax Samvera engine.'
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.summary       = <<-EOF
         
     | 
| 
      
 11 
     | 
    
         
            +
              These are some tests and matchers for Hyrax.
         
     | 
| 
      
 12 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage      = 'http://github.com/curationexperts/hyrax-spec'
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              spec.files         = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
         
     | 
| 
      
 17 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.name          = 'hyrax-spec'
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 21 
     | 
    
         
            +
              spec.version       = Hyrax::Spec::VERSION
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.license       = 'Apache-2.0'
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_dependency 'rspec', '~> 3.6'
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_development_dependency 'bixby', '~> 0.3'
         
     | 
| 
      
 27 
     | 
    
         
            +
              spec.add_development_dependency 'rake'
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/hyrax/spec.rb
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'hyrax' # @see http://rubygems.org/gems/hyrax
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rspec' # @see http://rubygems.org/gems/rspec
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Hyrax
         
     | 
| 
      
 5 
     | 
    
         
            +
              ##
         
     | 
| 
      
 6 
     | 
    
         
            +
              # `Hyrax::Spec` offers shared examples, contexts and matchers for Hyrax and
         
     | 
| 
      
 7 
     | 
    
         
            +
              # its components.
         
     | 
| 
      
 8 
     | 
    
         
            +
              #
         
     | 
| 
      
 9 
     | 
    
         
            +
              # @example Requiring the `Hyrax::Spec` module
         
     | 
| 
      
 10 
     | 
    
         
            +
              #   require 'hyrax/spec'
         
     | 
| 
      
 11 
     | 
    
         
            +
              #
         
     | 
| 
      
 12 
     | 
    
         
            +
              # @see http://rspec.info/documentation
         
     | 
| 
      
 13 
     | 
    
         
            +
              module Spec
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rspec/matchers' # @see http://rubygems.org/gems/rspec
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Myrax
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Spec
         
     | 
| 
      
 5 
     | 
    
         
            +
                ##
         
     | 
| 
      
 6 
     | 
    
         
            +
                # RSpec matchers for common Hyrax tests
         
     | 
| 
      
 7 
     | 
    
         
            +
                module Matchers
         
     | 
| 
      
 8 
     | 
    
         
            +
                  require 'hyrax/spec/matchers/have_editable_property'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  require 'hyrax/spec/matchers/have_form_field'
         
     | 
| 
      
 10 
     | 
    
         
            +
                  require 'hyrax/spec/matchers/list_index_fields'
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,51 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :have_editable_property do |property, predicate|
         
     | 
| 
      
 2 
     | 
    
         
            +
              match do |model|
         
     | 
| 
      
 3 
     | 
    
         
            +
                predicate ||= chain_predicate
         
     | 
| 
      
 4 
     | 
    
         
            +
                values    = ['Comet in Moominland', 'Moomin Midwinter']
         
     | 
| 
      
 5 
     | 
    
         
            +
                values    = values.first if @single
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                # find the matching property or set @missing_property to true and fail
         
     | 
| 
      
 8 
     | 
    
         
            +
                config = model.class.properties.fetch(property.to_s) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @missing_property = true
         
     | 
| 
      
 10 
     | 
    
         
            +
                  return false
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                # fail if setting the property doesn't change the values
         
     | 
| 
      
 14 
     | 
    
         
            +
                expect { model.set_value(property, values) }
         
     | 
| 
      
 15 
     | 
    
         
            +
                  .to change { Array(model.get_values(property)) }
         
     | 
| 
      
 16 
     | 
    
         
            +
                  .to contain_exactly(*values)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # if we haven't failed yet & we don't need to verify the predicate, succeed.
         
     | 
| 
      
 19 
     | 
    
         
            +
                return true unless predicate
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                # cast the predicate to a URI
         
     | 
| 
      
 22 
     | 
    
         
            +
                predicate = RDF::URI.intern(predicate)
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                # fail if the configured predicate is wrong
         
     | 
| 
      
 25 
     | 
    
         
            +
                @actual_predicate = config.predicate
         
     | 
| 
      
 26 
     | 
    
         
            +
                return false unless @actual_predicate == predicate
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                # fail if the rdf doesn't have the correct statements
         
     | 
| 
      
 29 
     | 
    
         
            +
                Array(values).each do |value|
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(model.resource.statements)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    .to include(RDF::Statement(model.rdf_subject, predicate, value))
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              chain :with_predicate, :chain_predicate
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              chain :as_single_valued do
         
     | 
| 
      
 38 
     | 
    
         
            +
                @single = true
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              failure_message do |model|
         
     | 
| 
      
 42 
     | 
    
         
            +
                msg = "expected #{model.class} to have an editable property `#{property}`"
         
     | 
| 
      
 43 
     | 
    
         
            +
                msg += " with predicate #{predicate.to_base}." if predicate
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                return msg + "\n\tNo property for `#{property}` was found." if @missing_property
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                msg += "\n\tThe configured predicate was #{actual_predicate.to_base}" unless
         
     | 
| 
      
 48 
     | 
    
         
            +
                  @actual_predicate == predicate
         
     | 
| 
      
 49 
     | 
    
         
            +
                msg
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,70 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :have_form_field do |name|
         
     | 
| 
      
 2 
     | 
    
         
            +
              match do |rendered_form|
         
     | 
| 
      
 3 
     | 
    
         
            +
                raise 'Specify a model with `.on_model(Klass)` to use this matcher.' unless
         
     | 
| 
      
 4 
     | 
    
         
            +
                  model_class
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                @selector = "#{model_class.to_s.downcase}_#{name}"
         
     | 
| 
      
 7 
     | 
    
         
            +
                @field    = rendered_form.find_css("##{@selector}").first
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                @options_missing = []
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                return false unless @field
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                @multiple = case @field.node_name
         
     | 
| 
      
 14 
     | 
    
         
            +
                            when 'input'
         
     | 
| 
      
 15 
     | 
    
         
            +
                              @field.attributes['class'].value.include? 'multi_value'
         
     | 
| 
      
 16 
     | 
    
         
            +
                            when 'select'
         
     | 
| 
      
 17 
     | 
    
         
            +
                              @field.attributes['multiple']
         
     | 
| 
      
 18 
     | 
    
         
            +
                            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                if label
         
     | 
| 
      
 21 
     | 
    
         
            +
                  label_node   = rendered_form.find_css("label[for=\"#{@selector}\"]")
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @label_text  = label_node && label_node.xpath('text()').first.text
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @label_match = @label_text =~ /\s*#{label}\s*$/
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                if @options
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @option_values =
         
     | 
| 
      
 28 
     | 
    
         
            +
                    @field.css('option').map { |opt| opt.attributes['value'].try(:value) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @options_missing = (@options - @option_values)
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                @field &&
         
     | 
| 
      
 33 
     | 
    
         
            +
                  (@single ^ @multiple) &&
         
     | 
| 
      
 34 
     | 
    
         
            +
                  (!label || @label_match) &&
         
     | 
| 
      
 35 
     | 
    
         
            +
                  @options_missing.empty?
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              chain :on_model,   :model_class
         
     | 
| 
      
 39 
     | 
    
         
            +
              chain :and_label,  :label
         
     | 
| 
      
 40 
     | 
    
         
            +
              chain :with_label, :label
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              chain :as_single_valued do
         
     | 
| 
      
 43 
     | 
    
         
            +
                @single = true
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              chain :and_options do |*options|
         
     | 
| 
      
 47 
     | 
    
         
            +
                @options = options
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              chain :with_options do |*options|
         
     | 
| 
      
 51 
     | 
    
         
            +
                @options = options
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              failure_message do |rendered_form|
         
     | 
| 
      
 55 
     | 
    
         
            +
                msg = "expected #{rendered_form} to have field #{name}"
         
     | 
| 
      
 56 
     | 
    
         
            +
                msg += ' as ' + (@single ? 'single valued' : 'multivalued')
         
     | 
| 
      
 57 
     | 
    
         
            +
                msg += " for class #{model_class}"          if     model_class
         
     | 
| 
      
 58 
     | 
    
         
            +
                msg += " with label #{label}"               if     label
         
     | 
| 
      
 59 
     | 
    
         
            +
                msg += " with options #{@options}"          if     @options
         
     | 
| 
      
 60 
     | 
    
         
            +
                msg += "\n\tNo field found: #{@selector}."  unless @field
         
     | 
| 
      
 61 
     | 
    
         
            +
                msg += "\n\tField not multivalued."         unless @single || @multiple
         
     | 
| 
      
 62 
     | 
    
         
            +
                msg += "\n\tField not single valued."       if     @single && @multiple
         
     | 
| 
      
 63 
     | 
    
         
            +
                msg += "\n\tLabel was #{@label_text}."      unless @label_match && @field
         
     | 
| 
      
 64 
     | 
    
         
            +
                msg += "\n\tOptions were #{@option_values}" unless @options_missing.empty?
         
     | 
| 
      
 65 
     | 
    
         
            +
                msg += "\n\t#{@field}."                     if     @field
         
     | 
| 
      
 66 
     | 
    
         
            +
                msg
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
            end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            RSpec::Matchers.alias_matcher :have_multivalued_field, :have_form_field
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :list_index_fields do |*names|
         
     | 
| 
      
 2 
     | 
    
         
            +
              match do |rendered_view|
         
     | 
| 
      
 3 
     | 
    
         
            +
                @missing_names = decorated_names(names) - labels_for(rendered_view)
         
     | 
| 
      
 4 
     | 
    
         
            +
                @missing_names.empty?
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              match_when_negated do |rendered_view|
         
     | 
| 
      
 8 
     | 
    
         
            +
                @missing_names = decorated_names(names) - labels_for(rendered_view)
         
     | 
| 
      
 9 
     | 
    
         
            +
                @not_missing = (decorated_names(names) - @missing_names)
         
     | 
| 
      
 10 
     | 
    
         
            +
                @not_missing.empty?
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def decorated_names(names)
         
     | 
| 
      
 14 
     | 
    
         
            +
                names.map { |name| name.end_with?(':') ? name : name + ':' }
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def labels_for(view)
         
     | 
| 
      
 18 
     | 
    
         
            +
                view.find('.metadata').all('.attribute-label').map(&:text)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              failure_message do |rendered_view|
         
     | 
| 
      
 22 
     | 
    
         
            +
                msg = "expected #{rendered_view} to list index fields #{names}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                msg + "\n\tthe fields #{@missing_names} were not present."
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              failure_message_when_negated do |rendered_view|
         
     | 
| 
      
 27 
     | 
    
         
            +
                msg = "expected #{rendered_view} not to list index fields #{names}"
         
     | 
| 
      
 28 
     | 
    
         
            +
                msg + "\n\tbut #{@not_missing} were present."
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'hyrax'
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'bundler/setup'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            begin
         
     | 
| 
      
 4 
     | 
    
         
            +
              require 'simplecov'
         
     | 
| 
      
 5 
     | 
    
         
            +
              require 'coveralls'
         
     | 
| 
      
 6 
     | 
    
         
            +
            rescue LoadError => e
         
     | 
| 
      
 7 
     | 
    
         
            +
              STDERR.puts "Coverage Skipped: #{e.message}"
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            begin
         
     | 
| 
      
 11 
     | 
    
         
            +
              require 'pry' unless ENV['CI']
         
     | 
| 
      
 12 
     | 
    
         
            +
            rescue LoadError => e
         
     | 
| 
      
 13 
     | 
    
         
            +
              STDERR.puts "Couldn't load Pry: #{e.message}"
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 17 
     | 
    
         
            +
              config.filter_run_excluding :slow
         
     | 
| 
      
 18 
     | 
    
         
            +
              config.run_all_when_everything_filtered = true
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              # disable should syntax
         
     | 
| 
      
 21 
     | 
    
         
            +
              config.expect_with :rspec do |c|
         
     | 
| 
      
 22 
     | 
    
         
            +
                c.syntax = :expect
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,109 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: hyrax-spec
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Tom Johnson
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-11-07 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: bixby
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0.3'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0.3'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            description: Shared tests, matchers, and smoke tests for the Hyrax Samvera engine.
         
     | 
| 
      
 56 
     | 
    
         
            +
            email:
         
     | 
| 
      
 57 
     | 
    
         
            +
            - tom@curationexperts.com
         
     | 
| 
      
 58 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 59 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 60 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 61 
     | 
    
         
            +
            files:
         
     | 
| 
      
 62 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 63 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
      
 64 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 65 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 66 
     | 
    
         
            +
            - Guardfile
         
     | 
| 
      
 67 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 68 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 69 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 70 
     | 
    
         
            +
            - hyrax-spec.gemspec
         
     | 
| 
      
 71 
     | 
    
         
            +
            - lib/hyrax/spec.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - lib/hyrax/spec/matchers.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/hyrax/spec/matchers/have_editable_property.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - lib/hyrax/spec/matchers/have_form_field.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/hyrax/spec/matchers/list_index_fields.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - lib/hyrax/spec/version.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - spec/hyrax/spec/spec_helper.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - spec/hyrax/spec/version_spec.rb
         
     | 
| 
      
 79 
     | 
    
         
            +
            - spec/hyrax/spec_spec.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            homepage: http://github.com/curationexperts/hyrax-spec
         
     | 
| 
      
 82 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 83 
     | 
    
         
            +
            - Apache-2.0
         
     | 
| 
      
 84 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 85 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 86 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 87 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 88 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 89 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 90 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 91 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 92 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 93 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 94 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 95 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 96 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 97 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 98 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 99 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 100 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 101 
     | 
    
         
            +
            rubygems_version: 2.6.13
         
     | 
| 
      
 102 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 103 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 104 
     | 
    
         
            +
            summary: These are some tests and matchers for Hyrax.
         
     | 
| 
      
 105 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 106 
     | 
    
         
            +
            - spec/hyrax/spec/spec_helper.rb
         
     | 
| 
      
 107 
     | 
    
         
            +
            - spec/hyrax/spec/version_spec.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - spec/hyrax/spec_spec.rb
         
     | 
| 
      
 109 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     |