You can start your own simple server. A quick example of using thin and rspec (these gems, as well as the rack) should be set here:
# spec/support/test_server.rb require 'rubygems' require 'rack' module MyApp module Test class Server def call(env) @root = File.expand_path(File.dirname(__FILE__)) path = Rack::Utils.unescape(env['PATH_INFO']) path += 'index.html' if path == '/' file = @root + "#{path}" params = Rack::Utils.parse_nested_query(env['QUERY_STRING']) if File.exists?(file) [ 200, {"Content-Type" => "text/html"}, File.read(file) ] else [ 404, {'Content-Type' => 'text/plain'}, 'file not found' ] end end end end end
Then in spec_helper :
# Include all files under spec/support Dir["./spec/support/**/*.rb"].each {|f| require f}
This will serve any file that you store in the spec/support directory. Including yourself. For all other requests, it will return 404.
This is basically what capybara does, as mentioned in the previous answer, minus a lot of complexity.
Thilo
source share