के भीतर से नियंत्रक आवृत्ति चर का उपयोग करना क्या मुझे अपने आरएसईटी परीक्षणों के भीतर से नियंत्रक कार्रवाई में बनाए गए इंस्टेंस वेरिएबल्स को देखने में सक्षम नहीं होना चाहिए? -एक rspec नियंत्रक spec
# /app/controllers/widget_controller.rb
...
def show
@widget = ...
puts "in controller: #{@widget}"
end
...
# /spec/controllers/widget_controller_spec.rb
RSpec.describe WidgetController, type: :controller do
...
describe "GET #show" do
it "assigns the requested widget as @widget" do
get :show, { :id => 1 } # this is just an example - I'm not hardcoding the id
puts "in spec: #{@widget}"
end
end
...
यहाँ जब मुझे लगता है कि कल्पना चलाने के उत्पादन मैं मिलता है:
controller: #<Widget:0x007f9d02aff090>
in spec:
मैं सोच रहा था कि मैं में @widget तक पहुंच होनी चाहिए में गलत हूँ मेरी नियंत्रक कल्पना?