module Speculate::Generator

Constants

Error

Public Instance Methods

generate(pair) click to toggle source
# File lib/speculate/generator.rb, line 5
def generate pair
  unless pair.outdated?
    raise Error,
      "Must not call generate for #{pair.speculation.path} -> #{pair.spec.path}, because it is not outdated"
  end
  puts "Generating: #{pair.speculation.path} -> #{pair.spec.path}"
  text = Speculate::Parser.new(pair.speculation).parse
  File.open(pair.spec.path, "w"){ |f|
    f.puts _header(pair.speculation.path)
    f.puts text
    f.puts _footer
  }
end

Private Instance Methods

_header(name) click to toggle source
# File lib/speculate/generator.rb, line 26
def _header name
  %{RSpec.describe #{name.inspect} do}
end