我有以下测试:
let(:client) { Descat::Client.new }
describe 'poblacio' do
it 'should set format correctly' do
client.poblacio('v1','json','dades')
expect (client.instance_variable_get(:format)).to eq('json')
end
end
我有以下正在测试的代码:
module Descat
class Client
BASE_URL = 'http://api.idescat.cat/'
def initialize(attributes = {})
attributes.each do |attr, value|
self.send("#{attr}=", value)
end
end
def poblacio(version, format, operation, *args)
@format = format
end
end
end
运行测试时,我不断得到'
Failure/Error: expect (client.instance_variable_get(:format)).to eq('json')
NameError:
但是,更改名称并没有帮助。
'