我正在尝试使用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'。必须在测试中以某种方式初始化会话哈希?我正在使用rails 3.2.12。