def dependency_to_spec(dep)
      # #to_spec doesn't allow prereleases unless the requirement is
      # for a prerelease. Just use the last valid spec if possible.
      spec = dep.to_spec || dep.to_specs.last
      raise Error.new("Cannot find a gem to satisfy #{dep}") unless spec
      spec
    rescue ::Gem::LoadError => ex
      raise Error.new("Cannot find a gem to satisfy #{dep}: #{ex}")
    end
def dependency_to_spec(dep)
      # #to_spec doesn't allow prereleases unless the requirement is
      # for a prerelease. Just use the last valid spec if possible.
      spec = dep.to_spec || dep.to_specs.last
      raise Error.new("Cannot find a gem to satisfy #{dep}") unless spec
      spec
    rescue ::Gem::LoadError => ex
      raise Error.new("Cannot find a gem to satisfy #{dep}: #{ex}")
    end
Find a spec given a dependency.

 @since 1.0.1
 @param dep [Gem::Dependency] Dependency to solve.
 @return [Gem::Specificiation]