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

Version Path
honeybadger-1.11.0 features/step_definitions/metal_steps.rb
honeybadger-1.10.3 features/step_definitions/metal_steps.rb
honeybadger-1.11.0.beta4 features/step_definitions/metal_steps.rb
honeybadger-1.11.0.beta3 features/step_definitions/metal_steps.rb
honeybadger-1.11.0.beta2 features/step_definitions/metal_steps.rb
honeybadger-1.10.2 features/step_definitions/metal_steps.rb
honeybadger-1.11.0.beta1 features/step_definitions/metal_steps.rb
honeybadger-1.10.1 features/step_definitions/metal_steps.rb
honeybadger-1.10.0 features/step_definitions/metal_steps.rb
honeybadger-1.9.5 features/step_definitions/metal_steps.rb
honeybadger-1.10.0.beta2 features/step_definitions/metal_steps.rb
honeybadger-1.10.0.beta1 features/step_definitions/metal_steps.rb
honeybadger-1.9.4 features/step_definitions/metal_steps.rb
honeybadger-1.9.3 features/step_definitions/metal_steps.rb
honeybadger-1.9.2 features/step_definitions/metal_steps.rb
honeybadger-1.9.1 features/step_definitions/metal_steps.rb
honeybadger-1.9.0 features/step_definitions/metal_steps.rb
honeybadger-1.9.0.beta3 features/step_definitions/metal_steps.rb
honeybadger-1.9.0.beta2 features/step_definitions/metal_steps.rb
honeybadger-1.9.0.beta1 features/step_definitions/metal_steps.rb