0
私は私の出発点テスト駆動型開発:テストの上で自分自身を繰り返さない方法はありますか?
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
it "should be successful" do
@request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
get 'home'
response.should be_success
end
it "Should have the proper title" do
@request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
get 'home'
response.should have_selector("title",
:content => "Slacklog")
end
end
describe "GET 'contact'" do
it "should be successful" do
@request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
get 'contact'
response.should be_success
end
end
describe "GET 'about'" do
it "should be successful" do
@request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
get 'about'
response.should be_success
end
end
end
としてこのファイルを持っているしかし、あなたはこれが私の基本的なHTTP認証で、そこに持っているように私はすべての私のテストではなく、料金、私これを必要と
@request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
ラインに気付きます私のすべてのテストの前にこれを追加するより良い方法です。すべてのテストの上にコピーして貼り付けます。