Shouldn't I be able to see instance variables which are created in a controller action from within my rspect tests?
# /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
...
Here is the output I get when I run that spec:
controller: #<Widget:0x007f9d02aff090>
in spec:
Am I wrong in thinking that I should have access to @widget in my controller spec?