Я пытаюсь проверить действие update из модели приложения в моем приложении.положить: обновить в rspec не обновлять атрибуты
Мой factories.rb файл:
FactoryGirl.define do
factory :student do
first_name "John"
last_name "Doe"
sequence(:email) { |n| "#{first_name}.#{last_name}#{n}@example.com".downcase }
city "Dhaka"
area "Mirpur"
zip 1216
full_address "Mirpur, Dhaka"
password "password"
password_confirmation "password"
confirmed_at Date.today
end
end
RSpec файл:
require 'rails_helper'
RSpec.describe Students::RegistrationsController do
context "Student logged in" do
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:student]
@student = FactoryGirl.create(:student)
@updated_attributes = { :first_name => "New", :last_name => "Name" }
sign_in @student
put :update, :id => @student.id, :student => @updated_attributes
@student.reload
end
it { expect(@student.first_name).to eql "New" }
it { expect(@student.last_name).to eql "Name" }
end
end
Я ожидал, что тесты, чтобы пройти. Но они терпят неудачу. Сообщения об ошибках выглядят так:
Failure/Error: it { expect(@student.first_name).to eql "New" }
expected: "New" got: "John" (compared using eql?)
Failure/Error: it { expect(@student.last_name).to eql "Name" }
expected: "Name" got: "Doe" (compared using eql?)
Так что, в основном, атрибуты не обновляются. Что мне нужно сделать, чтобы rspec обновлял атрибуты и делал тесты зелеными?