Project

hyrax-spec

0.0
No commit activity in last 3 years
No release in over 3 years
Shared tests, matchers, and smoke tests for the Hyrax Samvera engine.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.3
>= 0

Runtime

~> 3.6
 Project Readme

Hyrax::Spec

Yard Docs

Shared examples and smoke tests for Hyrax applications. See the documentation for more information.

RSpec Matchers

Hyrax::Spec::Matchers includes a variety of custom matchers for use with RSpec. These matchers can be included in your suite in batch by adding require 'hyrax/spec/matchers' to your test helper (usually spec/rails_helper.rb), or individually requiring them (as in require 'hyrax/spec/matchers/have_form_field').

Note: documentation on matchers remains somewhat thin. The best current reference is their use in mahonia, an ETD repository.

FactoryBot Build Strategies for Hyrax

If your test suite uses FactoryBot (formerly FactoryGirl) to create test objects, Hyrax::Spec provides useful custom build strategies that may simplify the setup phase of your tests. To register the build stratgies add the following to your test helper (usually spec/rails_helper.rb):

# spec/rails_helper.rb

require 'hyrax/spec/factory_bot/build_strategies'

ActorCreate

The ActorCreate strategy builds an object and passes it to the Hyrax Actor Stack to be processed. In a normal RSpec Rails environment, this will enqueue (but not perform) several background jobs (charactarization, derivatives, etc...). The specific actor middleware called is Hyrax::CurationConcern.actor.

This strategy is registered by default as actor_create. You can use it with an existing factory, which must define user as a transient attribute.

# factories/my_works.rb
FactoryBot.define do
  factory(:my_work) do
    title ['Comet in Moominland']

    transient do
      user { FactoryBot.create(:user) }
    end
  end
end

# my_work_spec.rb
RSpec.describe MyWork do
  subject(:my_work) { FactoryBot.actor_create(:my_work) }

  it { is_expected.to have_attributes(date_uploaded: an_instance_of(DateTime)) }
end

Contributing

If you're working on a PR for this project, create a feature branch off of main.

This repository follows the Samvera Community Code of Conduct and language recommendations. Please do not create a branch called master for this repository or as part of your pull request; the branch will either need to be removed or renamed before it can be considered for inclusion in the code base and history of this repository.

License

Hyrax::Spec is available under the Apache 2.0 license.