Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Created August 5, 2016 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/a92e69010fae15aa05b03a67d8d7a8ef to your computer and use it in GitHub Desktop.
Save JoshCheek/a92e69010fae15aa05b03a67d8d7a8ef to your computer and use it in GitHub Desktop.
require 'webmock/rspec'
require 'rack'
require 'robots'
require 'webrick/httpstatus' # picked this one b/c it's in the stdlib
rack_response_filename = $LOADED_FEATURES.find { |filename| filename =~ /rack_response/ }
eval File.read(rack_response_filename).sub(/status$/, "[status, WEBrick::HTTPStatus.reason_phrase(status)]")
RSpec.describe Robots do
specify "StringIO#status contains the reason phrase" do
app = lambda { |env| [200, {'Conten-Type' => 'text/plain'}, ["User-Agent: *#$/Disallow: /"]] }
stub_request(:get, "http://example.com/robots.txt").to_rack(app)
response = described_class.get_robots_txt("http://example.com/", 'Ruby')
expect(response.status).to eq ['200', 'OK']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment