Sha256: ed00de03d8e85e9c8ab053b9072b89395b59cb1f03f0412791b0d7af065a128b
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'spec_helper' describe Locomotive::Steam::Liquid::Filters::Json do include Locomotive::Steam::Liquid::Filters::Json let(:input) { nil } subject { json(*input) } describe 'adds quotes to a string' do let(:input) { 'foo' } it { expect(subject).to eq %("foo") } end context 'drop' do describe 'includes only the fields specified' do let(:input) { [Liquid::TestDrop.new(title: 'Acme', body: 'Lorem ipsum'), 'title'] } it { expect(subject).to eq %("title":"Acme") } end end context 'collections' do describe 'adds brackets and quotes to a collection' do let(:input) { [['foo', 'bar']] } it { expect(subject).to eq %(["foo","bar"]) } end describe 'includes the first field' do let(:input) { [[Liquid::TestDrop.new(title: 'Acme', body: 'Lorem ipsum'), Liquid::TestDrop.new(title: 'Hello world', body: 'Lorem ipsum')], 'title'] } it { expect(subject).to eq %("Acme","Hello world") } end describe 'includes the specified fields' do let(:input) { [[Liquid::TestDrop.new(title: 'Acme', body: 'Lorem ipsum', date: '2013-12-13'), Liquid::TestDrop.new(title: 'Hello world', body: 'Lorem ipsum', date: '2013-12-12')], 'title, body'] } it { expect(subject).to eq %({"title":"Acme","body":"Lorem ipsum"},{"title":"Hello world","body":"Lorem ipsum"}) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms_steam-1.0.0.pre.beta.3 | spec/unit/liquid/filters/json_spec.rb |