次のテストがあります。
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:
ただし、名前の変更は役に立ちません。
'