summaryrefslogtreecommitdiff
path: root/spec/serializers/environment_serializer_spec.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-10-28 14:32:07 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-02 14:26:57 +0100
commitacfe394018df50bfc08aa9e41265231747675646 (patch)
tree776b34a9f27c149d8863775f760036b2484ed866 /spec/serializers/environment_serializer_spec.rb
parent2023511753d75545aa76968a2991dc962f7a99db (diff)
downloadgitlab-ce-acfe394018df50bfc08aa9e41265231747675646.tar.gz
Add PoC for resource serializers
Diffstat (limited to 'spec/serializers/environment_serializer_spec.rb')
-rw-r--r--spec/serializers/environment_serializer_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/serializers/environment_serializer_spec.rb b/spec/serializers/environment_serializer_spec.rb
new file mode 100644
index 00000000000..3470863681c
--- /dev/null
+++ b/spec/serializers/environment_serializer_spec.rb
@@ -0,0 +1,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