Sha256: a1642a8349bd4e68fe0529d611ce6c97d712d6008168570bd9bfe2fae6ecb039

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

require 'spec_helper'
require 'fixtures/components/foo-renderer/models/json'

describe Alephant::Renderer::Views::Json do
  let(:data) do
    {
      'foo' => 'a',
      'bar' => 'b',
      'baz' => 'c'
    }
  end

  describe '#content_type' do
    it 'sets the correct content type' do
      expect(MyApp::Json.new(data).content_type).to eq('application/json')
    end
  end

  describe '#to_h' do
    it 'generates a hash based on the white list' do
      expected_result = { 'item1' => 'a', 'item2' => 'b' }
      expect(MyApp::Json.new(data).to_h).to eq(expected_result)
    end
  end

  describe '#render' do
    it 'returns generated json' do
      expected_result = '{"item1":"a","item2":"b"}'
      expect(MyApp::Json.new(data).render).to eq(expected_result)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alephant-renderer-3.2.0 spec/views_json_spec.rb
alephant-renderer-3.1.0 spec/views_json_spec.rb