Top Level Namespace
Defined Under Namespace
Modules: Parspec
Instance Method Summary collapse
Instance Method Details
#load_parspec(file, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/parspec.rb', line 58 def load_parspec(file, = {}) parspec_file = case File.extname(file) when '.rb' then file.sub(/rb$/, 'parspec') when '' then "#{file}.parspec" end if not File.exists?(parspec_file) # TODO: try to find the file in the load_path raise LoadError, "cannot load such file -- #{parspec_file}" end require 'parslet/convenience' require 'parslet/rig/rspec' parspec = Parspec.translate_file(parspec_file, ) # TODO: These are not detected as examples by RSpec ... #tmp_file = Tempfile.new([File.basename(parspec_file), '.rb']) #tmp_file.write(parspec) #require tmp_file.path # only as a fallback or if options[:force_eval] eval(parspec) end |