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.16.7 features/step_definitions/metal_steps.rb
honeybadger-1.16.6 features/step_definitions/metal_steps.rb
honeybadger-1.16.5 features/step_definitions/metal_steps.rb
honeybadger-1.16.4 features/step_definitions/metal_steps.rb
honeybadger-1.16.3 features/step_definitions/metal_steps.rb
honeybadger-1.16.2 features/step_definitions/metal_steps.rb
honeybadger-1.16.1 features/step_definitions/metal_steps.rb
honeybadger-1.16.0 features/step_definitions/metal_steps.rb
honeybadger-1.15.3 features/step_definitions/metal_steps.rb
honeybadger-1.15.2 features/step_definitions/metal_steps.rb
honeybadger-1.15.1 features/step_definitions/metal_steps.rb
honeybadger-1.15.0 features/step_definitions/metal_steps.rb
honeybadger-1.14.0 features/step_definitions/metal_steps.rb
honeybadger-1.13.2 features/step_definitions/metal_steps.rb
honeybadger-1.13.1 features/step_definitions/metal_steps.rb
honeybadger-1.13.0 features/step_definitions/metal_steps.rb
honeybadger-1.12.0.beta3 features/step_definitions/metal_steps.rb
honeybadger-1.12.0.beta2 features/step_definitions/metal_steps.rb
honeybadger-1.11.2 features/step_definitions/metal_steps.rb
honeybadger-1.11.1 features/step_definitions/metal_steps.rb