siringa 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56fef5bef124061ab3bac9a1beafbc3828ab62b2
4
- data.tar.gz: b796d80e4f3d83d0fa78d01e30582ef598589bb9
3
+ metadata.gz: c5650e083c7d2cf88d4556847def7c3002429a25
4
+ data.tar.gz: cd8b73b2bccdc1f0fd5a294d19a4e62d3f801006
5
5
  SHA512:
6
- metadata.gz: 1ab9793288d3af7d4fcae48224c7eb406bd7249b9722b1d0914a52597e2b5206707055491e9ccf597c0e0d1c9455f0b04a4d94163073dba3c7b3475ea85cda65
7
- data.tar.gz: 675a854c035f548366636724203e834ea781e8dfefd5b77789fe27ddef7214e75204c5bffc355573b636169a736bd2fc929f9799dc9031f5b4e175128d817210
6
+ metadata.gz: e342b5a35cba7e7d07222c444903bc45ccc87a7739a190f5f6f5d53d028a40ca59b3af7521193de00525465873c279c6d40f3ed787da3ef3ee822d7cd08de9ec
7
+ data.tar.gz: f38a3dbde4ec18a9efbed51e0200effd47a54f72782274b3869d0d8655233d94e28d43249fd448e3874e5dfb3e9329a454a34a225ef4a7f0f9ebd3e05571d89f
@@ -2,14 +2,12 @@ module Siringa
2
2
  class SiringaController < ApplicationController
3
3
 
4
4
  def load
5
- Siringa.load_definition(params['definition'].to_sym, options)
6
- resp = { :text => "Definition #{params['definition']} loaded.", :status => :created }
5
+ result = Siringa.load_definition(params['definition'].to_sym, options)
6
+ render json: result, status: :created
7
7
  rescue ArgumentError => exception
8
- resp = { :text => exception.to_s, :status => :method_not_allowed }
9
- rescue => exception
10
- resp = { :text => exception.to_s, :status => :internal_server_error }
11
- ensure
12
- render resp
8
+ render json: { error: exception.to_s }, status: :method_not_allowed
9
+ rescue StandardError => exception
10
+ render json: { error: exception.to_s }, status: :internal_server_error
13
11
  end
14
12
 
15
13
  def dump
@@ -1,3 +1,3 @@
1
1
  module Siringa
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -21,8 +21,22 @@ class SiringaControllerTest < ActionController::TestCase
21
21
  end
22
22
 
23
23
  test "load action passing arguments" do
24
- get :load, { definition: "definition_with_arguments", siringa_args: { name: 'Robb Stark' }, use_route: "siringa" }
24
+ get :load, {
25
+ definition: "definition_with_arguments",
26
+ siringa_args: { name: 'Robb Stark' },
27
+ use_route: "siringa"
28
+ }
25
29
  assert_response :success
26
30
  end
27
31
 
32
+ test "load action returning JSON response" do
33
+ get :load, {
34
+ definition: "definition_with_return",
35
+ siringa_args: { name: 'Ned' },
36
+ use_route: "siringa"
37
+ }
38
+ assert body['id']
39
+ assert_equal 'Ned', body['name']
40
+ assert_equal 'Stark', body['surname']
41
+ end
28
42
  end
@@ -8,3 +8,8 @@ end
8
8
  Siringa.add_definition :definition_with_arguments do |args|
9
9
  FactoryGirl.create :user, name: args[:name]
10
10
  end
11
+
12
+ Siringa.add_definition :definition_with_return do |args|
13
+ user = FactoryGirl.create :user, name: args[:name]
14
+ { id: user.id, name: user.name, surname: 'Stark' }
15
+ end
@@ -8,3 +8,8 @@ Rails.backtrace_cleaner.remove_silencers!
8
8
 
9
9
  # Load support files
10
10
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Parse JSON response body
13
+ def body
14
+ JSON.parse(@response.body)
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siringa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrico Stano
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-13 00:00:00.000000000 Z
12
+ date: 2015-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3