В моем проекте Rails я использую rspec-mocks с использованием any_instance, но я хочу избежать этого сообщения об отказе:
 Using any_instance from rspec-mocks' old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should instead.
Вот мои спецификации:
describe (".create") do
  it 'should return error when...' do
    User.any_instance.stub(:save).and_return(false)
    post :create, user: {name: "foo", surname: "bar"}, format: :json
    expect(response.status).to eq(422)
  end
end
Вот мой контроллер:
def create
    @user = User.create(user_params)
    if @user.save
      render json: @user, status: :created, location: @user
    else
      render json: @user.errors, status: :unprocessable_entity
    end
end
Я бы хотел использовать синтаксис new: ожидать синтаксис, но я не могу найти, как правильно его использовать.
Я использую RSpec 3.0.2.