मेरे पास एक दृश्य सहायक विधि है जो request.domain और request.port_string को देखकर एक यूआरएल उत्पन्न करती है।rspec सहायक परीक्षण के लिए अनुरोध ऑब्जेक्ट का नकल कैसे करें?
module ApplicationHelper
def root_with_subdomain(subdomain)
subdomain += "." unless subdomain.empty?
[subdomain, request.domain, request.port_string].join
end
end
मैं इस विधि का परीक्षण rspec का उपयोग करना चाहता हूं।
describe ApplicationHelper do
it "should prepend subdomain to host" do
root_with_subdomain("test").should = "test.xxxx:xxxx"
end
end
लेकिन जब मैं rspec के साथ इस चलाने के लिए, मैं इस मिल:
Failure/Error: root_with_subdomain("test").should = "test.xxxx:xxxx" `undefined local variable or method `request' for #<RSpec::Core::ExampleGroup::Nested_3:0x98b668c>`
किसी को भी कृपया मुझे यह पता लगाने की क्या मैं इसे ठीक करने के लिए क्या करना चाहिए मदद कर सकते हैं? मैं इस उदाहरण के लिए 'अनुरोध' ऑब्जेक्ट का नकल कैसे कर सकता हूं?
क्या यूआरएल उत्पन्न करने के कोई बेहतर तरीके हैं जहां सबडोमेन का उपयोग किया जाता है?
अग्रिम धन्यवाद।
यह त्रुटि दे रहा है: अपवाद का सामना करना पड़ा: #
shailesh