Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Commit

Permalink
Mount the metal endpoint in Rails 3 tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Oct 27, 2010
1 parent 43dfbbd commit 876e4e9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions features/step_definitions/metal_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,18 @@
file.puts definition
file.puts "end"
end
When %{the metal endpoint "#{class_name}" is mounted in the Rails 3 routes.rb} if rails3?
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 = "match '/test(/*other)' => #{class_name}"
routes = routes[0..-2] + [rack_route, routes[-1]]
File.open(routesrb, "w") do |f|
f.puts "require 'app/metal/#{class_name.underscore}'"
routes.each do |route_line|
f.puts route_line
end
end
end

0 comments on commit 876e4e9

Please sign in to comment.