fson 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fcf0f1b392bdfd4ea2e8485eec01d46b5f088e0
4
- data.tar.gz: 8fa8d6725d8dc28e2e52fe9a6c3c3973c0f9207c
3
+ metadata.gz: 17bfd7f187015864d738f9b5a460bdefd845eb25
4
+ data.tar.gz: 843bc84ed8bbb0f326cc8e66a709dec22649d9fe
5
5
  SHA512:
6
- metadata.gz: 0f3f7ac0f5652189e286bc02891625cf41f44136e6b4249854065d5faf1c5bb08e827b26dd8e0181c4d522ab541672076f8fa7a9a01a1ef07337342c2f008e3e
7
- data.tar.gz: 1344fe823ac6814ea117677d502891d5302500dcdcc24ae72309223de1d28fac508578952011c81e9b499b57169bd1ea81229118f21b297143ae7bb3842d8afb
6
+ metadata.gz: d09d1d708e8b03065375ded5bdf6e7e5688710ccb05b699d35608e4361dd5fcc5160058f8353287601cdc6b34bd1f463a7594ab19d7bb74fc4f057122b57a79d
7
+ data.tar.gz: ab36d815a9db5df6923f49fe7bfa6f4389e7ad67f4609697e00c404775533057749c881392d550f341785441b47fa9fb935aee1651df6309ea2aee40be3adfd8
data/README.md CHANGED
@@ -1 +1 @@
1
- # fluent-json-response
1
+ # Fson - JSON API Response Fluent Builder
data/lib/fson/response.rb CHANGED
@@ -20,7 +20,7 @@ module Fson
20
20
  @_errors = []
21
21
  end
22
22
 
23
- def to_json
23
+ def as_json
24
24
  ::Oj.dump(build)
25
25
  end
26
26
 
data/lib/fson/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fson
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  describe ::Fson::Response do
4
4
 
5
5
  context 'when getting json representation of response' do
6
+
6
7
  it 'should return json response' do
7
8
  # given
8
9
  response = ::Fson::Response.error
@@ -10,7 +11,7 @@ describe ::Fson::Response do
10
11
  .data { |data| data[:author] = 'Mateusz Kluczny' }
11
12
 
12
13
  # when/then
13
- expect(response.to_json).to eq("{\":status\":\":error\",\":data\":{\":author\":\"Mateusz Kluczny\"},\":errors\":[{\":message\":\"invalid\",\":id\":\"text-set-1\"}]}")
14
+ expect(response.as_json).to eq("{\":status\":\":error\",\":data\":{\":author\":\"Mateusz Kluczny\"},\":errors\":[{\":message\":\"invalid\",\":id\":\"text-set-1\"}]}")
14
15
  end
15
16
  end
16
17
  end
@@ -2,11 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe ::Fson::Response do
4
4
 
5
- it 'should create error response' do
6
- # when
7
- response = Fson::Response.error
5
+ context 'when creating response' do
8
6
 
9
- # then
10
- expect(response.instance_eval {@_response[:status]}).to eq(:error)
7
+ it 'should create error response' do
8
+ # when
9
+ response = Fson::Response.error
10
+
11
+ # then
12
+ expect(response.instance_eval {@_response[:status]}).to eq(:error)
13
+ end
11
14
  end
12
15
  end
@@ -2,11 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe ::Fson::Response do
4
4
 
5
- it 'should create fail response' do
6
- # when
7
- response = Fson::Response.fail
5
+ context 'when creating response' do
8
6
 
9
- # then
10
- expect(response.instance_eval {@_response[:status]}).to eq(:fail)
7
+ it 'should create fail response' do
8
+ # when
9
+ response = Fson::Response.fail
10
+
11
+ # then
12
+ expect(response.instance_eval {@_response[:status]}).to eq(:fail)
13
+ end
11
14
  end
12
15
  end
@@ -2,11 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe ::Fson::Response do
4
4
 
5
- it 'should create response object with status assigned' do
6
- # when
7
- response = Fson::Response.new(:success)
5
+ context 'when creating response' do
8
6
 
9
- # then
10
- expect(response.instance_eval {@_response[:status]}).to eq(:success)
7
+ it 'should create response object with given status' do
8
+ # when
9
+ response = Fson::Response.new(:success)
10
+
11
+ # then
12
+ expect(response.instance_eval {@_response[:status]}).to eq(:success)
13
+ end
11
14
  end
12
15
  end
@@ -2,11 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe ::Fson::Response do
4
4
 
5
- it 'should create success response' do
6
- # when
7
- response = Fson::Response.success
5
+ context 'when creating response' do
8
6
 
9
- # then
10
- expect(response.instance_eval {@_response[:status]}).to eq(:success)
7
+ it 'should create success response' do
8
+ # when
9
+ response = Fson::Response.success
10
+
11
+ # then
12
+ expect(response.instance_eval {@_response[:status]}).to eq(:success)
13
+ end
11
14
  end
12
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Kluczny
@@ -69,11 +69,11 @@ files:
69
69
  - lib/fson/builder.rb
70
70
  - lib/fson/response.rb
71
71
  - lib/fson/version.rb
72
+ - spec/fson/response/as_json_spec.rb
72
73
  - spec/fson/response/error_spec.rb
73
74
  - spec/fson/response/fail_spec.rb
74
75
  - spec/fson/response/initialize_spec.rb
75
76
  - spec/fson/response/success_spec.rb
76
- - spec/fson/response/to_json_spec.rb
77
77
  - spec/spec_helper.rb
78
78
  homepage: https://github.com/mkluczny/fson
79
79
  licenses:
@@ -100,9 +100,9 @@ signing_key:
100
100
  specification_version: 4
101
101
  summary: Simple fluent builder for API JSON responses
102
102
  test_files:
103
+ - spec/fson/response/as_json_spec.rb
103
104
  - spec/fson/response/error_spec.rb
104
105
  - spec/fson/response/fail_spec.rb
105
106
  - spec/fson/response/initialize_spec.rb
106
107
  - spec/fson/response/success_spec.rb
107
- - spec/fson/response/to_json_spec.rb
108
108
  - spec/spec_helper.rb