spec.name fails if spec is still nil

spec.name fails if spec is still nil
Merge pull request #3202 from dangoita/patch-1

spec.name fails if spec is still nil