0

我正在测试一些服务

require 'spec_helper'

feature 'MyAPIService' do
  before do
    stub_request(:get, "http://my_app.com/persisted_session").
      with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
      to_return(status: 200, body: 's', headers: {})
  end

  it 'checks if session persist' do
    uri = URI('http://my_app.com/persisted_session')

    response = Net::HTTP.get(uri)

    expect(response.status).to be_success
  end
end

我想测试状态并解析 xml 正文。但我有一个错误

  1) MyAPIService checks if session persist
     Failure/Error: expect(response).to be_success
     NoMethodError:
       undefined method `success?' for "s":String
4

1 回答 1

0

你想要expect(response).to be_success而不是expect(response.status).to be_success

于 2013-12-09T14:00:19.317 回答