valkyrie_active_fedora 0.0.1
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 +77 -0
- data/.rubocop.yml +276 -0
- data/.rubocop_todo.yml +20 -0
- data/.solr_wrapper +6 -0
- data/.travis.yml +19 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +17 -0
- data/LICENSE +201 -0
- data/README.md +46 -0
- data/Rakefile +17 -0
- data/config/fedora.yml +14 -0
- data/config/service_mappings.yml +9 -0
- data/config/solr.yml +15 -0
- data/lib/generators/valkyrie_active_fedora/config/USAGE +9 -0
- data/lib/generators/valkyrie_active_fedora/config/config_generator.rb +10 -0
- data/lib/generators/valkyrie_active_fedora/config/fedora/fedora_generator.rb +16 -0
- data/lib/generators/valkyrie_active_fedora/config/fedora/templates/.fcrepo_wrapper.yml +4 -0
- data/lib/generators/valkyrie_active_fedora/config/fedora/templates/fcrepo_wrapper_test.yml +4 -0
- data/lib/generators/valkyrie_active_fedora/config/fedora/templates/fedora.yml +15 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/solr_generator.rb +19 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/.solr_wrapper.yml +8 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr.yml +7 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/_rest_managed.json +3 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/admin-extra.html +31 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/elevate.xml +36 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/protwords.txt +21 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/schema.xml +379 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/scripts.conf +24 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/solrconfig.xml +325 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/spellings.txt +2 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/stopwords.txt +58 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/stopwords_en.txt +58 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/synonyms.txt +31 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/xslt/example.xsl +132 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/xslt/example_atom.xsl +67 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/xslt/example_rss.xsl +66 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/xslt/luke.xsl +337 -0
- data/lib/generators/valkyrie_active_fedora/config/solr/templates/solr_wrapper_test.yml +8 -0
- data/lib/generators/valkyrie_active_fedora/model/USAGE +11 -0
- data/lib/generators/valkyrie_active_fedora/model/model_generator.rb +31 -0
- data/lib/generators/valkyrie_active_fedora/model/templates/datastream.rb.erb +32 -0
- data/lib/generators/valkyrie_active_fedora/model/templates/datastream_spec.rb.erb +13 -0
- data/lib/generators/valkyrie_active_fedora/model/templates/model.rb.erb +46 -0
- data/lib/generators/valkyrie_active_fedora/model/templates/model_spec.rb.erb +38 -0
- data/lib/tasks/valkyrie_active_fedora_dev.rake +67 -0
- data/lib/valkyrie_active_fedora.rb +11 -0
- data/lib/valkyrie_active_fedora/base.rb +39 -0
- data/lib/valkyrie_active_fedora/engine.rb +12 -0
- data/lib/valkyrie_active_fedora/version.rb +4 -0
- data/spec/.gitignore +1 -0
- data/spec/rails_helper.rb +3 -0
- data/spec/spec_helper.rb +108 -0
- data/spec/unit/base_spec.rb +36 -0
- data/tasks/valkyrie_active_fedora_dev.rake +17 -0
- data/valkyrie_active_fedora.gemspec +47 -0
- metadata +314 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Generate a class that inherits from ActiveFedora::Base
|
|
3
|
+
|
|
4
|
+
Example:
|
|
5
|
+
rails generate active_fedora:model Journal
|
|
6
|
+
|
|
7
|
+
This will create:
|
|
8
|
+
app/models/journal.rb
|
|
9
|
+
app/models/datastreams/journal_metadata.rb
|
|
10
|
+
spec/models/journal_spec.rb
|
|
11
|
+
spec/models/datastreams/journal_metadata_spec.rb
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
|
|
3
|
+
module ActiveFedora
|
|
4
|
+
class ModelGenerator < Rails::Generators::NamedBase
|
|
5
|
+
source_root ::File.expand_path('../templates', __FILE__)
|
|
6
|
+
check_class_collision
|
|
7
|
+
|
|
8
|
+
class_option :directory, type: :string, default: 'models', desc: "Which directory to generate? (i.e. app/DIRECTORY)"
|
|
9
|
+
class_option :datastream_directory, type: :string, default: 'models/datastreams', desc: "Which datastream directory to generate? (i.e. models/datastreams)"
|
|
10
|
+
class_option :has_subresource, type: :string, default: nil, desc: "Name a file to attach"
|
|
11
|
+
class_option :datastream, type: :string, default: nil, desc: "Name a metadata datastream to create"
|
|
12
|
+
|
|
13
|
+
def install
|
|
14
|
+
template('model.rb.erb', ::File.join('app', directory, "#{file_name}.rb"))
|
|
15
|
+
template('model_spec.rb.erb', ::File.join('spec', directory, "#{file_name}_spec.rb"))
|
|
16
|
+
return unless options[:datastream]
|
|
17
|
+
template('datastream.rb.erb', ::File.join('app', datastream_directory, "#{file_name}_metadata.rb"))
|
|
18
|
+
template('datastream_spec.rb.erb', ::File.join('spec', datastream_directory, "#{file_name}_metadata_spec.rb"))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
protected
|
|
22
|
+
|
|
23
|
+
def directory
|
|
24
|
+
options[:directory]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def datastream_directory
|
|
28
|
+
options[:datastream_directory]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Generated via
|
|
2
|
+
# `rails generate active_fedora:model <%= class_name %>`
|
|
3
|
+
class <%= class_name %>Metadata < ActiveFedora::OmDatastream
|
|
4
|
+
|
|
5
|
+
# Define a terminology for parsing this XML document
|
|
6
|
+
# See: https://github.com/samvera/om/wiki/Tame-your-XML-with-OM
|
|
7
|
+
#
|
|
8
|
+
# set_terminology do |t|
|
|
9
|
+
# t.root(path: "fields")
|
|
10
|
+
# t.title
|
|
11
|
+
# t.author
|
|
12
|
+
# end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# Describe what an empty document looks like
|
|
16
|
+
#
|
|
17
|
+
# def self.xml_template
|
|
18
|
+
# Nokogiri::XML.parse("<fields/>")
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# "If you need to add additional attributes to the SOLR document, define the
|
|
24
|
+
# #to_solr method and make sure to use super"
|
|
25
|
+
#
|
|
26
|
+
# def to_solr(solr_document={}, options={})
|
|
27
|
+
# super(solr_document, options)
|
|
28
|
+
# solr_document["my_attribute_s"] = my_attribute
|
|
29
|
+
# return solr_document
|
|
30
|
+
# end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated via
|
|
2
|
+
# `rails generate active_fedora:model <%= class_name %>`
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
|
|
5
|
+
describe <%= class_name %>Metadata do
|
|
6
|
+
it 'should have a title' do
|
|
7
|
+
pending "Create a terminology for <%= class_name %>Metadata, then enable this test"
|
|
8
|
+
subject.title = 'War and Peace'
|
|
9
|
+
expect(subject.title).to eq ['War and Peace']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Generated via
|
|
2
|
+
# `rails generate active_fedora:model <%= class_name %>`
|
|
3
|
+
class <%= class_name %> < ActiveFedora::Base
|
|
4
|
+
<% if options['datastream'] %>
|
|
5
|
+
has_subresource :descMetadata, class_name: "<%= options['datastream'] %>"
|
|
6
|
+
<% else %>
|
|
7
|
+
# Define some properties to store:
|
|
8
|
+
#
|
|
9
|
+
property :title, predicate: ::RDF::Vocab::DC.title do |index|
|
|
10
|
+
index.as :stored_searchable, :facetable
|
|
11
|
+
end
|
|
12
|
+
property :creator, predicate: ::RDF::Vocab::DC.creator do |index|
|
|
13
|
+
index.as :stored_searchable, :facetable
|
|
14
|
+
end
|
|
15
|
+
property :contributor, predicate: ::RDF::Vocab::DC.contributor do |index|
|
|
16
|
+
index.as :stored_searchable, :facetable
|
|
17
|
+
end
|
|
18
|
+
property :description, predicate: ::RDF::Vocab::DC.description do |index|
|
|
19
|
+
index.as :stored_searchable
|
|
20
|
+
end
|
|
21
|
+
<%- end -%>
|
|
22
|
+
<% if options['has_subresource'] %>
|
|
23
|
+
has_subresource :<%= options['has_subresource'] %>"
|
|
24
|
+
<% else %>
|
|
25
|
+
# Uncomment the following lines to add an #attachment method that is a file
|
|
26
|
+
#
|
|
27
|
+
# has_subresource "attachment"
|
|
28
|
+
<% end %>
|
|
29
|
+
#
|
|
30
|
+
# If you need to add additional attributes to the SOLR document, extend the default indexer:
|
|
31
|
+
#
|
|
32
|
+
# def indexer
|
|
33
|
+
# MyApp::IndexingService
|
|
34
|
+
# end
|
|
35
|
+
#
|
|
36
|
+
# This can go into app/services/my_app/indexing_service.rb
|
|
37
|
+
# module MyApp
|
|
38
|
+
# class IndexingService < ActiveFedora::IndexingService
|
|
39
|
+
# def generate_solr_document
|
|
40
|
+
# super.tap do |solr_doc|
|
|
41
|
+
# solr_doc["my_attribute_s"] = object.my_attribute
|
|
42
|
+
# end
|
|
43
|
+
# end
|
|
44
|
+
# end
|
|
45
|
+
# end
|
|
46
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Generated via
|
|
2
|
+
# `rails generate active_fedora:model <%= class_name %>`
|
|
3
|
+
require 'rails_helper'
|
|
4
|
+
require 'active_fedora/test_support'
|
|
5
|
+
|
|
6
|
+
describe <%= class_name %> do
|
|
7
|
+
it_behaves_like 'An ActiveModel'
|
|
8
|
+
include ActiveFedora::TestSupport
|
|
9
|
+
subject { <%= class_name %>.new }
|
|
10
|
+
|
|
11
|
+
describe "when persisted to fedora" do
|
|
12
|
+
before { subject.save! }
|
|
13
|
+
after { subject.destroy }
|
|
14
|
+
it 'should exist' do
|
|
15
|
+
expect(<%= class_name %>.exists?(subject.id)).to be true
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
<% if options['datastream'] %>
|
|
20
|
+
it 'should have a descMetadata datastream' do
|
|
21
|
+
expect(subject.descMetadata).to be_kind_of <%= options['descMetadata'] ? options['descMetadata'] : "#{class_name}Metadata" %>
|
|
22
|
+
end
|
|
23
|
+
<% else %>
|
|
24
|
+
it 'should have a title' do
|
|
25
|
+
subject.title = ['War and Peace']
|
|
26
|
+
expect(subject.title).to eq ['War and Peace']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "#to_solr" do
|
|
30
|
+
subject { <%= class_name %>.new(title: ['War and Peace']).to_solr }
|
|
31
|
+
|
|
32
|
+
it 'should have a title' do
|
|
33
|
+
expect(subject['title_tesim']).to eq ['War and Peace']
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
<% end %>
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
|
|
2
|
+
|
|
3
|
+
require 'solr_wrapper'
|
|
4
|
+
require 'fcrepo_wrapper'
|
|
5
|
+
require 'active_fedora/rake_support'
|
|
6
|
+
|
|
7
|
+
namespace :valkyrie_active_fedora do
|
|
8
|
+
# Use yard to build docs
|
|
9
|
+
begin
|
|
10
|
+
require 'yard'
|
|
11
|
+
require 'yard/rake/yardoc_task'
|
|
12
|
+
project_root = APP_ROOT
|
|
13
|
+
doc_destination = File.join(project_root, 'doc')
|
|
14
|
+
|
|
15
|
+
YARD::Rake::YardocTask.new(:doc) do |yt|
|
|
16
|
+
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
|
17
|
+
[ '-', File.join(project_root, 'README.md')]
|
|
18
|
+
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
|
|
19
|
+
end
|
|
20
|
+
rescue LoadError
|
|
21
|
+
desc "Generate YARD Documentation"
|
|
22
|
+
task :doc do
|
|
23
|
+
abort "Please install the YARD gem to generate rdoc."
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
require 'rspec/core/rake_task'
|
|
28
|
+
desc 'Run tests only'
|
|
29
|
+
RSpec::Core::RakeTask.new(:rspec) do |spec|
|
|
30
|
+
spec.rspec_opts = ['--backtrace'] if ENV['CI']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
require 'rubocop/rake_task'
|
|
34
|
+
desc 'Run style checker'
|
|
35
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
36
|
+
task.requires << 'rubocop-rspec'
|
|
37
|
+
task.fail_on_error = true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
41
|
+
spec.rcov = true
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc "CI build"
|
|
45
|
+
task :ci do
|
|
46
|
+
Rake::Task['valkyrie_active_fedora:rubocop'].invoke unless ENV['NO_RUBOCOP']
|
|
47
|
+
ENV['environment'] = "test"
|
|
48
|
+
with_test_server do
|
|
49
|
+
Rake::Task['valkyrie_active_fedora:coverage'].invoke
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
desc "Execute specs with coverage"
|
|
54
|
+
task :coverage do
|
|
55
|
+
# Put spec opts in a file named .rspec in root
|
|
56
|
+
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
|
|
57
|
+
ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
|
|
58
|
+
Rake::Task["valkyrie_active_fedora:spec"].invoke
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
desc "Execute specs with coverage"
|
|
62
|
+
task :spec do
|
|
63
|
+
with_test_server do
|
|
64
|
+
Rake::Task["valkyrie_active_fedora:rspec"].invoke
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'active_support/descendants_tracker'
|
|
2
|
+
# require 'active_fedora/errors'
|
|
3
|
+
# require 'active_fedora/log_subscriber'
|
|
4
|
+
|
|
5
|
+
module ValkyrieActiveFedora
|
|
6
|
+
# This class ties together many of the lower-level modules, and
|
|
7
|
+
# implements something akin to an ActiveRecord-alike interface to
|
|
8
|
+
# fedora. If you want to represent a fedora object in the ruby
|
|
9
|
+
# space, this is the class you want to extend.
|
|
10
|
+
#
|
|
11
|
+
# =The Basics
|
|
12
|
+
# class Oralhistory < ActiveFedora::Base
|
|
13
|
+
# property :creator, predicate: RDF::Vocab::DC.creator
|
|
14
|
+
# end
|
|
15
|
+
#
|
|
16
|
+
# The above example creates a Fedora object with a property named "creator"
|
|
17
|
+
#
|
|
18
|
+
# Attached files defined with +has_subresource+ and iis accessed via the +attached_files+ member hash.
|
|
19
|
+
#
|
|
20
|
+
class Base < ActiveFedora::Base
|
|
21
|
+
def valkyrie_resource
|
|
22
|
+
klass = "Valkyrie::#{self.class.to_s}".constantize
|
|
23
|
+
rescue NameError
|
|
24
|
+
nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def attributes_including_linked_ids
|
|
28
|
+
local_attributes = attributes.dup
|
|
29
|
+
reflections.keys.each do |key|
|
|
30
|
+
id_method = "#{key.to_s.singularize}_ids"
|
|
31
|
+
next unless self.respond_to? id_method
|
|
32
|
+
local_attributes.merge!(id_method => self.send(id_method)).with_indifferent_access
|
|
33
|
+
end
|
|
34
|
+
local_attributes
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# ActiveSupport.run_load_hooks(:valkyrie_active_fedora, Base)
|
|
39
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module ValkyrieActiveFedora
|
|
3
|
+
class Engine < ::Rails::Engine
|
|
4
|
+
isolate_namespace ValkyrieActiveFedora
|
|
5
|
+
|
|
6
|
+
require 'valkyrie_active_fedora'
|
|
7
|
+
|
|
8
|
+
# def self.engine_mount
|
|
9
|
+
# ValkyrieActiveFedora::Engine.routes.find_script_name({})
|
|
10
|
+
# end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/spec/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
internal
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
ENV["environment"] ||= "test"
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require 'simplecov'
|
|
5
|
+
require 'coveralls'
|
|
6
|
+
|
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
8
|
+
[
|
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
10
|
+
Coveralls::SimpleCov::Formatter
|
|
11
|
+
]
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
SimpleCov.start "rails" do
|
|
15
|
+
add_filter "/spec/"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
require 'active-fedora'
|
|
19
|
+
require 'valkyrie'
|
|
20
|
+
require 'valkyrie_active_fedora'
|
|
21
|
+
require 'rspec'
|
|
22
|
+
require 'rspec/its'
|
|
23
|
+
require 'equivalent-xml/rspec_matchers'
|
|
24
|
+
require 'logger'
|
|
25
|
+
require 'pry' unless ENV['TRAVIS']
|
|
26
|
+
|
|
27
|
+
ActiveFedora::Base.logger = Logger.new(STDERR)
|
|
28
|
+
ActiveFedora::Base.logger.level = Logger::WARN
|
|
29
|
+
|
|
30
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
|
|
31
|
+
|
|
32
|
+
$VERBOSE = nil
|
|
33
|
+
|
|
34
|
+
# This loads the Fedora and Solr config info from /config/fedora.yml
|
|
35
|
+
# You can load it from a different location by passing a file path as an argument.
|
|
36
|
+
def restore_spec_configuration
|
|
37
|
+
ActiveFedora.init(fedora_config_path: File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
|
|
38
|
+
end
|
|
39
|
+
restore_spec_configuration
|
|
40
|
+
|
|
41
|
+
require 'active_fedora/cleaner'
|
|
42
|
+
RSpec.configure do |config|
|
|
43
|
+
# Stub out test stuff.
|
|
44
|
+
config.before(:each) do
|
|
45
|
+
begin
|
|
46
|
+
ActiveFedora::Cleaner.clean!
|
|
47
|
+
rescue Faraday::ConnectionFailed, RSolr::Error::ConnectionRefused => e
|
|
48
|
+
$stderr.puts e.message
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
53
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
54
|
+
# assertions if you prefer.
|
|
55
|
+
config.expect_with :rspec do |expectations|
|
|
56
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
57
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
58
|
+
# defined using `chain`, e.g.:
|
|
59
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
60
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
61
|
+
# ...rather than:
|
|
62
|
+
# # => "be bigger than 2"
|
|
63
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
|
67
|
+
|
|
68
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
69
|
+
|
|
70
|
+
# This allows you to limit a spec run to individual examples or groups
|
|
71
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
|
72
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
|
73
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
|
74
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
75
|
+
config.filter_run_when_matching :focus
|
|
76
|
+
|
|
77
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
|
78
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
79
|
+
# file, and it's useful to allow more verbose output when running an
|
|
80
|
+
# individual spec file.
|
|
81
|
+
if config.files_to_run.one?
|
|
82
|
+
# Use the documentation formatter for detailed output,
|
|
83
|
+
# unless a formatter has already been configured
|
|
84
|
+
# (e.g. via a command-line flag).
|
|
85
|
+
config.default_formatter = 'doc'
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Print the 10 slowest examples and example groups at the
|
|
89
|
+
# end of the spec run, to help surface which specs are running
|
|
90
|
+
# particularly slow.
|
|
91
|
+
config.profile_examples = 10
|
|
92
|
+
|
|
93
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
94
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
95
|
+
# the seed, which is printed after each run.
|
|
96
|
+
# --seed 1234
|
|
97
|
+
config.order = :random
|
|
98
|
+
|
|
99
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
100
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
101
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
102
|
+
# as the one that triggered the failure.
|
|
103
|
+
Kernel.srand config.seed
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def fixture(file)
|
|
107
|
+
File.open(File.join(File.dirname(__FILE__), 'fixtures', file), 'rb')
|
|
108
|
+
end
|