Module: EacRubyGemSupport::Rspec::Setup

Extended by:
ActiveSupport::Concern
Includes:
EacRubyGemSupport::Rspec::Specs::Rubocop
Defined in:
lib/eac_ruby_gem_support/rspec/setup.rb

Constant Summary collapse

SETUPS =
%w[load_path example_persistence filesystem_helper shared_examples].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EacRubyGemSupport::Rspec::Specs::Rubocop

#describe_rubocop

Class Method Details

.extended(setup_obj) ⇒ Object



17
18
19
# File 'lib/eac_ruby_gem_support/rspec/setup.rb', line 17

def self.extended(setup_obj)
  SETUPS.each { |s| setup_obj.send("setup_#{s}") }
end

Instance Method Details

#example_persistence_pathPathname

Returns:

  • (Pathname)


41
42
43
# File 'lib/eac_ruby_gem_support/rspec/setup.rb', line 41

def example_persistence_path
  root_tmp.join('example_status_persistence')
end

#root_tmpPathname

The root directory for temporary files.

Returns:

  • (Pathname)


47
48
49
50
51
52
# File 'lib/eac_ruby_gem_support/rspec/setup.rb', line 47

def root_tmp
  r = ::Pathname.new(::Dir.tmpdir)
        .join("#{app_root_path.expand_path.to_path.variableize}_specs_tmp")
  r.mkpath unless r.exist?
  r
end

#setup_example_persistenceObject



31
32
33
# File 'lib/eac_ruby_gem_support/rspec/setup.rb', line 31

def setup_example_persistence
  rspec_config.example_status_persistence_file_path = example_persistence_path.to_path
end

#setup_filesystem_helperObject



21
22
23
24
25
# File 'lib/eac_ruby_gem_support/rspec/setup.rb', line 21

def setup_filesystem_helper
  rspec_config.include ::EacRubyGemSupport::Rspec::Helpers::Filesystem
  rspec_config.include ::EacRubyGemSupport::Rspec::Helpers::Utils
  rspec_config.after(:each) { purge_temp_files }
end

#setup_load_pathObject



27
28
29
# File 'lib/eac_ruby_gem_support/rspec/setup.rb', line 27

def setup_load_path
  $LOAD_PATH.push app_root_path.join('lib').to_path
end

#setup_shared_examplesObject



35
36
37
38
# File 'lib/eac_ruby_gem_support/rspec/setup.rb', line 35

def setup_shared_examples
  require 'eac_ruby_gem_support/rspec/shared_examples/spec_paths'
  require 'eac_ruby_gem_support/rspec/shared_examples/source_target_fixtures'
end