lib/rspec/scaffold/generator.rb in rspec-scaffold-0.3.0 vs lib/rspec/scaffold/generator.rb in rspec-scaffold-1.0.0
- old
+ new
@@ -11,17 +11,17 @@
@file = file
super Ryan.new(file)
end
def const
- @const ||= Kernel.const_get(name)
+ @const ||= name.split('::').inject(Kernel) { |k, part| k.const_get part }
end
def perform
indent = (' ' * 2)
second_indent = indent * 2
- lines = [%Q(require "#{helper_file}"), %Q(), %Q(describe #{const} do)]
+ lines = [%Q(require "#{Scaffold.helper_file}"), %Q(), %Q(describe #{const} do)]
if class?
initialization_args.each do |arg|
lines << %Q(#{indent}let(:#{arg.to_s.sub(/^[&*]/, '')}) {})
end
lines << %Q()
@@ -41,17 +41,9 @@
end
lines << %Q(#{indent}end) << %Q()
end
lines << %Q(end) << %Q()
lines
- end
-
- def helper_file
- if defined?(::Rails)
- 'rails_helper'
- else
- 'spec_helper'
- end
end
end
end
end