diff options
author | icebaker <icebaker@proton.me> | 2024-01-10 21:31:42 -0300 |
---|---|---|
committer | icebaker <icebaker@proton.me> | 2024-01-10 21:31:42 -0300 |
commit | aabf3d9b711f66fe4195a8c850856826c7ad5580 (patch) | |
tree | 866218debc763547818de0099098bc5fe2ae29c7 /spec/logic | |
parent | 552c9c7321895d41f81e460b94182b7a00d2cb88 (diff) |
improving merging approach
Diffstat (limited to 'spec/logic')
-rw-r--r-- | spec/logic/cartridge/parser_spec.rb | 24 | ||||
-rw-r--r-- | spec/logic/helpers/hash_spec.rb | 9 |
2 files changed, 33 insertions, 0 deletions
diff --git a/spec/logic/cartridge/parser_spec.rb b/spec/logic/cartridge/parser_spec.rb index e8bac0b..8297baa 100644 --- a/spec/logic/cartridge/parser_spec.rb +++ b/spec/logic/cartridge/parser_spec.rb @@ -30,6 +30,30 @@ RSpec.describe NanoBot::Logic::Cartridge::Parser do end end + context 'meta' do + let(:raw) { File.read('spec/data/cartridges/meta.md') } + + it 'parses markdown cartridge' do + expect(described_class.parse(raw, format: 'md')).to eq( + { + meta: { + symbol: '🤖', + name: 'Nano Bot Name', + author: 'Your Name', + description: 'A helpful assistant.', + version: '1.0.0', + license: 'CC0-1.0' + }, + behaviors: { + interaction: { + directive: 'You are a helpful assistant.' + } + } + } + ) + end + end + context 'tools' do let(:raw) { File.read('spec/data/cartridges/tools.md') } diff --git a/spec/logic/helpers/hash_spec.rb b/spec/logic/helpers/hash_spec.rb index 7c8ff58..0da92fb 100644 --- a/spec/logic/helpers/hash_spec.rb +++ b/spec/logic/helpers/hash_spec.rb @@ -9,6 +9,15 @@ RSpec.describe NanoBot::Logic::Helpers::Hash do ) end + it 'deep merges' do + expect(described_class.deep_merge( + { a: { x: 1, y: 2 }, b: 3 }, + { a: { y: 99, z: 4 }, c: 5 } + )).to eq( + { a: { x: 1, y: 99, z: 4 }, b: 3, c: 5 } + ) + end + it 'stringify keys' do expect(described_class.stringify_keys({ a: 'b', c: { d: [:e] } })).to eq( { 'a' => 'b', 'c' => { 'd' => [:e] } } |