1
我有如下的配置,同時:如何測試頁面的標題與西納特拉+ MINITEST工作
Rake文件
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = 'spec/*_spec.rb'
end
的Gemfile
source 'https://rubygems.org'
gem 'sinatra'
gem 'thin'
gem 'rack-test'
spec_helper.rb
ENV['RACK_ENV'] = 'test'
require 'minitest/autorun'
require 'rack/test'
require_relative '../app'
include Rack::Test::Methods
def app
MyApp
end
app_spec.rb
require_relative 'spec_helper'
describe 'Hello World' do
it 'should have hello world' do
get '/'
last_response.must_be :ok?
# I want to do something like below
last_response.title must_match /home page/i
end
end
如何測試使用MINITEST和西納特拉視圖的頁面標題。
感謝您的回答.. –
@ArupRakshit你能接受解決這個問題的答案嗎? – Roman
@羅曼爲什麼不。完成。 –