add step writer for undefined steps, cucumber automagicks

This commit is contained in:
John Bintz 2012-04-18 16:40:23 -04:00
parent 58ebd113ba
commit 6ed2459d61
2 changed files with 21 additions and 1 deletions

View File

@ -2,7 +2,7 @@ module Flowerbox
module CoreExt
module Module
def find_constant(string)
const_get(constants.find { |f| f.to_s.downcase == string.to_s.downcase })
const_get(constants.find { |f| f.to_s.downcase == string.to_s.downcase.gsub('_', '') })
end
def for(env)

View File

@ -0,0 +1,20 @@
require 'flowerbox/reporter/base'
module Flowerbox::Reporter
class StepWriter < Base
def report_undefined(result)
target = File.join(options[:target], result.step_type.downcase, result.original_name.strip.downcase.gsub(%r{[^\w]+}, '_')) + '.js'
if result.test_environment.primarily_coffeescript?
target << '.coffee'
end
if !File.file?(target)
self.puts "Writing #{target}..."
File.open(target, 'wb') { |fh| fh.print result.test_environment.obtain_test_definition_for(result) }
end
end
end
end