Sha256: 640bb79998530bb3dc73fce419ea855e88d8f6c106a049eccb2d69b4df5c880e
Contents?: true
Size: 801 Bytes
Versions: 3
Compression:
Stored size: 801 Bytes
Contents
require "pathname" require_relative "./base_test_data" module RspecTestData class SeedsHelper def self.for_rails self.new(Rails.root / "spec") end def initialize(spec_path) @spec_path = spec_path end def load(test_data_class_name,**args) if test_data_class_name !~ /^RspecTestData::/ test_data_class_name = "RspecTestData::#{test_data_class_name}" end parts = test_data_class_name.split(/::/).map(&:underscore) path = (@spec_path / parts[1..-1].join("/")).to_s + ".test_data.rb" if !File.exist?(path) raise "Expected to find test data for #{test_data_class_name} in '#{path}', but that file doesn't exist." end require_relative path test_data_class_name.constantize.new(**args) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rspec_test_data-1.0.1 | lib/rspec_test_data/seeds_helper.rb |
rspec_test_data-1.0.0 | lib/rspec_test_data/seeds_helper.rb |
rspec_test_data-1.0.0.pre1 | lib/rspec_test_data/seeds_helper.rb |