class TestController < AplicationController
#....
private
def some_method
unless @my_variable.nil?
#...
return true
end
end
end
Tôi muốn thử nghiệm some_method
trực tiếp trong điều khiển spec:RSpec: Làm thế nào để gán biến dụ trong bộ điều khiển đặc tả
require 'spec_helper'
describe TestController do
it "test some_method"
phone = Phone.new(...)
controller.assign(:my_variable,phone) #does not work
controller.send(:some_method).should be_true
end
end
Làm thế nào tôi có thể thiết lập TestController
dụ biến @my_variable
từ bộ điều khiển spec?
Cảm ơn bạn @ Paul cho một giải pháp tốt. – ole