Add specs that this.memory(key, falsy) should work

This spots a bug in `getMemory()`.
This commit is contained in:
Akinori MUSHA 2016-06-16 19:57:33 +09:00
parent e4e2782ebe
commit 4edb6e0866

View file

@ -186,6 +186,30 @@ describe Agents::JavaScriptAgent do
@agent.save!
expect { @agent.reload.memory }.not_to raise_error
end
it "it stores null" do
@agent.options['code'] = 'Agent.check = function() {
this.memory("foo", "test");
this.memory("foo", null);
};'
@agent.save!
@agent.check
expect(@agent.memory['foo']).to eq(nil)
@agent.save!
expect { @agent.reload.memory }.not_to raise_error
end
it "it stores false" do
@agent.options['code'] = 'Agent.check = function() {
this.memory("foo", "test");
this.memory("foo", false);
};'
@agent.save!
@agent.check
expect(@agent.memory['foo']).to eq(false)
@agent.save!
expect { @agent.reload.memory }.not_to raise_error
end
end
describe "deleteKey" do