Sha256: 613a8f558042d95b10f83bf25faf88f8e33db0bc591bda34feb7fefe0cd7cd96
Contents?: true
Size: 1013 Bytes
Versions: 46
Compression:
Stored size: 1013 Bytes
Contents
When /^I define a Metal endpoint called "([^\"]*)":$/ do |class_name, definition| FileUtils.mkdir_p(File.join(rails_root, 'app', 'metal')) file_name = File.join(rails_root, 'app', 'metal', "#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}.rb") File.open(file_name, "w") do |file| file.puts "class #{class_name}" file.puts definition file.puts "end" end step %(the metal endpoint "#{class_name}" is mounted in the Rails 3 routes.rb) unless rails2? end When /^the metal endpoint "([^\"]*)" is mounted in the Rails 3 routes.rb$/ do |class_name| routesrb = File.join(rails_root, "config", "routes.rb") routes = IO.readlines(routesrb) rack_route = "get '/metal(/*other)' => #{class_name}" routes = routes[0..-2] + [rack_route, routes[-1]] File.open(routesrb, "w") do |f| f.puts "$:<< '#{LOCAL_RAILS_ROOT}'" f.puts "require 'app/metal/#{class_name.split(/(?=[A-Z][a-z]*)/).join('_').downcase}'" routes.each do |route_line| f.puts route_line end end end
Version data entries
46 entries across 46 versions & 1 rubygems