Welcome to mirror list, hosted at ThFree Co, Russian Federation.

environment_serializer_spec.rb « serializers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3470863681cab1ac8eb28417bb901a6775c27fa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'spec_helper'

describe EnvironmentSerializer do
  let(:serializer) do
    described_class.new(path: 'some path').represent(resource)
  end

  context 'when there is a single object provided' do
    let(:resource) { create(:environment) }

    it 'shows json' do
      puts serializer.to_json
    end

    it 'it generates payload for single object' do
      expect(parsed_json).to be_an_instance_of Hash
    end
  end

  context 'when there is a collection of objects provided' do
    let(:resource) { create_list(:environment, 2) }

    it 'shows json' do
      puts serializer.to_json
    end

    it 'generates payload for collection' do
      expect(parsed_json).to be_an_instance_of Array
    end
  end

  def parsed_json
    JSON.parse(serializer.to_json)
  end
end