2014-01-08 39 views

回答

3

可以使用可變current_path,如

expect(current_path).to eq '/users' 
+0

只有當您使用水豚纔有此功能嗎? – Jerry

+0

不是,它的內置 – kddeisz

+1

它不起作用了 – Extazystas

3

根據您在控制器或視圖中,您有幾個選項。您可以使用current_page? helper

current_page?(action: 'process') 
# => false 

current_page?(controller: 'shop', action: 'checkout') 
# => true 

current_page?(controller: 'shop', action: 'checkout', order: 'asc') 
# => false 

current_page?(action: 'checkout') 
# => true 

current_page?(controller: 'library', action: 'checkout') 
# => false 

current_page?('http://www.example.com/shop/checkout') 
# => true 

current_page?('/shop/checkout') 
# => true 

在控制器中,您通常會針對request.path字符串進行檢查。

+3

這不是在rspec的工作對我來說。 – Julia