Created
August 5, 2016 07:42
-
-
Save JoshCheek/a92e69010fae15aa05b03a67d8d7a8ef to your computer and use it in GitHub Desktop.
Solution to https://github.com/bblimke/webmock/issues/642
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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