我正在尝试使用 minitest 两种控制器方法进行测试:
class CurrenciesController < InheritedResources::Base
def mark_refresh
session[:refreshable] = true
redirect_to currencies_url
end
def unmark_refresh
session[:refreshable] = false
redirect_to currencies_url
end
end
我的测试:
require "minitest_helper"
describe "Currencies integration" do
it "should auto refresh" do
visit currencies_path
click_on "Auto refresh"
session[:refreshable].must_equal true
end
it "should turn off auto refresh" do
session[:refreshable] = true
visit currencies_path
click_on "Auto refresh"
session[:refreshable].must_equal false
end
但我得到未定义的局部变量或方法 `session'。会话哈希必须在测试中以某种方式初始化?我正在使用导轨 3.2.12。