How @user output in console?

please help solve the problem. i use gem ‘devise’, gem ‘rspec’ and this
tutorial:
http://stackoverflow.com/questions/11002721/authentication-with-devise-in-rspec-tests
.i need @user output in console. emails_controller_spec.rb:

RSpec.describe EmailsController, type: :controller do
let(:valid_attributes) {
{
email: Faker::Internet.email,
description: Faker::Lorem.paragraph(7),
user_id: 1
}
}

describe “GET #index” do
login_user

it "assigns all emails as @emails" do
  email = Email.create! valid_attributes
  get :index
  binding.pry
  expect(assigns(:emails)).to eq([email])
  #expect(assigns(@user)).to eq(@user)
end

end
end

spec/factories/users.rb:

FactoryGirl.define do
factory :user do
sequence(:email){ |i| “us#{i}@ad.ad” }
password ‘qwertyui’
password_confirmation{ |u| u.password }
role :none
end
end
spec/support/controller_macros.rb:

module ControllerMacros
def login_user
before(:each) do
@request.env[“devise.mapping”] = Devise.mappings[:user]
user = FactoryGirl.create(:user)
sign_in user
end
end
end

i user gem ‘pry’ for see on variables from console after run the test.
but i see follow:

[email protected] ~/rails/mailer $ rspec spec/controllers

From:
/home/kalinin/rails/mailer/spec/controllers/emails_controller_spec.rb @
line 56 :
[1] pry(#RSpec::ExampleGroups::EmailsController::GETIndex)> @user
=> nil
[2] pry(#RSpec::ExampleGroups::EmailsController::GETIndex)> user
NameError: undefined local variable or method user' for #<RSpec::ExampleGroups::EmailsController::GETIndex:0x00000007c4e670> from /home/kalinin/.rvm/gems/ruby-2.0.0-p598/gems/rspec-expectations-3.3.1/lib/rspec/matchers.rb:966:inmethod_missing’
[3] pry(#RSpec::ExampleGroups::EmailsController::GETIndex)> puts
page.html

=> nil

i need displays user-object or displays html-code of page. please help

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs