2012-03-09 10 views
1

フォーム上のパスを確認するテストを作成するにはどうすればよいですか?フォームパスを確認するためのrspecテストの作成

私はこのしようとしている

it "has a proper form path given subdomains" do  
    @event = Factory :event 
    get events_path(@event), nil, {'HTTP_HOST' => 'staging.example.com' } 
    page.should have_selector "form", :action => "secure.staging.example.com" 
end 

をしかし、私のテストが動作しているように、それは見ていません:

Failure/Error: page.should have_selector "form", :action => "secure.staging.example.com" 
    expected css "form" to return something 
# ./spec/requests/events_spec.rb:18:in `block (3 levels) in <top (required)>' 

答えて

1

私はpage and response variables間の違いのようにこれを解決するには、テストについて多くのことを学びました。

私が本当に必要としたのは、私のurl_forヘルパーメソッドがサブドメインの前に適切に置かれていることをテストするためにa helper specと書くことでした。しかし、私はまた、ビュースペックコードを考え出しました:

it "has a proper form path given subdomains" do  
    assign :event, Factory(:event) 

    controller.request.host = "staging.example.com" 

    render 

    assert_select "form[action*=?]", "secure.staging.example.com" 
end 
関連する問題