&tag(WebMock);
group :test do gem 'webmock' end
$ bundle install --path vendor/bundle
# -*- coding: utf-8 -*-
require 'spec_helper'
require 'webmock/rspec'
require 'open-uri'
# 全てのリクエストを行わない
WebMock.disable_net_connect!
describe 'サンプル' do
before do
html = <<EOS
<html>
<head>
<title>テストです</title>
</head>
<body>
</body>
</html>
EOS
url = 'http://www.example.org/'
stub_request(:get, url).to_return({:body => html,:status => 200})
body = open(url).read
@title = nil
if body =~ /<title>([^<]+)</
@title = $1
end
end
it {@title.should == 'テストです'}
end