Skip to content

Commit

Permalink
Add specs that this.memory(key, falsy) should work
Browse files Browse the repository at this point in the history
This spots a bug in `getMemory()`.
  • Loading branch information
knu committed Jun 16, 2016
1 parent e4e2782 commit 4edb6e0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/models/agents/java_script_agent_spec.rb
Expand Up @@ -186,6 +186,30 @@
@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
Expand Down

0 comments on commit 4edb6e0

Please sign in to comment.