textualize 0.1.6 → 0.2.0

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: 14e96ab2b1196616608ba3e7cd7a39a4cfd85079
4
- data.tar.gz: 8f118d44db8daf03d644c37715282c658ad52fa2
3
+ metadata.gz: 0004fe0730f678c98c0b08e94bd3bece7a42bf6e
4
+ data.tar.gz: 60c9fd0ddbac322e698b77067bd5476dd42dbab3
5
5
  SHA512:
6
- metadata.gz: 52168151bff04d9727de7d9e854e0c930c1fe873696652de35bb49b35df79fe1952b8569b0200d19181560cdc3eac8e78d1b8790a016288b871784a5edec10b5
7
- data.tar.gz: 16a9e9f345519712b1c403de5bce5565828393bb06b2318e9e5f6139847354efeded06d9711b780c6c3369128347be3a1a88ed150c727d53e3398f817f40cd46
6
+ metadata.gz: c0ecaa24c69b83455a92a2a54e4d41a8240061a53f234c014d5759d761a484cf215c549b6dcc4b6ff4f128fbded452bf6c6d9b2fbe5f3ab3cbbcb5a0ab285504
7
+ data.tar.gz: 98e0b6d410a04a5d7b51e8be91a454ffb5b673badda5fdf60d6a886d80f451abaa6c1e6b72c560611966d73ab718639802dccfbb267868ffca382122ea354a5a
@@ -24,7 +24,15 @@ module Textualize
24
24
  method_hashes = []
25
25
  method_hashes += resource.fetch('methods').map do |method|
26
26
  method_hash = Hashie::Mash.new
27
+
27
28
  method_hash.verb = method.fetch('method')
29
+
30
+ if method_hash.verb == 'post'
31
+ method_hash.schema = method.fetch('body').
32
+ fetch('application/json').
33
+ fetch('schema')
34
+ end
35
+
28
36
  method_hash.url = base_path + relative_path
29
37
  method_hash.relative_path = relative_path
30
38
  method_hash.type = resource.fetch('type').keys.first
@@ -20,10 +20,17 @@ module Textualize
20
20
 
21
21
  def add_airborne_specs
22
22
  RouteHashes.hashes.each do |route_hash|
23
+
24
+ # replace sample ids with interpolated ruby
25
+ modified_hash = route_hash
26
+
27
+ modified_hash.relative_path.gsub!(/({|_id)/, '{' => '#{', '_id' => '.id')
28
+ modified_hash.url.gsub!(/({|_id)/, '{' => '#{', '_id' => '.id')
29
+
23
30
  File.open(
24
31
  "#{RS_DIRECTORY}#{route_hash.verb}_#{route_hash.name}_spec.rb", 'w'
25
32
  ) do |file|
26
- file.write(request_spec_template(route_hash))
33
+ file.write(request_spec_template(modified_hash))
27
34
  end
28
35
  end
29
36
  end
@@ -13,8 +13,8 @@ securitySchemes:
13
13
  - oauth_2_0: !include ./documentation/authentication.yaml
14
14
 
15
15
  schemas:
16
- - items: !include ./base/schemas/item.json
17
- - orders: !include ./base/schemas/order.json
16
+ - item: !include ./base/schemas/item.json
17
+ - order: !include ./base/schemas/order.json
18
18
 
19
19
  resourceTypes:
20
20
  - !include ./resourceTypes/collection.yaml
@@ -0,0 +1,15 @@
1
+ require 'airborne'
2
+
3
+ describe 'DELETE <%= url %>' do
4
+ let!(:<%= name %>) { create(:<%= name %>) }
5
+
6
+ before do
7
+ add_header_tokens(<%= secured_by %>)
8
+ end
9
+
10
+ it 'returns expected json' do
11
+ delete "<%= url %>"
12
+ expect_status <%= response_code %>
13
+ end
14
+ end
15
+
@@ -0,0 +1,14 @@
1
+ require 'airborne'
2
+
3
+ describe 'PATCH <%= url %>' do
4
+ let!(:<%= name %>) { create(:<%= name %>) }
5
+
6
+ before do
7
+ add_header_tokens(<%= secured_by %>)
8
+ end
9
+
10
+ it 'returns expected json' do
11
+ patch "<%= url %>"
12
+ expect_status <%= response_code %>
13
+ end
14
+
@@ -6,7 +6,13 @@ describe 'POST <%= url %>' do
6
6
  end
7
7
 
8
8
  it 'returns the saved record' do
9
- post "<%= url %>"
9
+ post "<%= url %>", {
10
+ <%= properties = JSON.parse(schema).fetch('properties');
11
+ properties.fetch('required').map { |required_param|
12
+ "\"#{required_param}\" => "\
13
+ "\"#{properties.fetch(required_param).fetch('type')}\""
14
+ }.join("\n") %>
15
+ }
10
16
  expect_status <%= response_code %>
11
17
  end
12
18
  end
@@ -1,3 +1,3 @@
1
1
  module Textualize
2
- VERSION = '0.1.6'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
27
27
  end
28
28
  spec.require_paths = ['lib']
29
29
 
30
- spec.add_runtime_dependency 'thor', '~> 0'
31
- spec.add_runtime_dependency 'attr_extras', '~> 4'
32
- spec.add_runtime_dependency 'hashie', '~> 3'
33
- spec.add_runtime_dependency 'uglifier', '~> 2'
30
+ spec.add_runtime_dependency 'thor', '~> 0'
31
+ spec.add_runtime_dependency 'attr_extras', '~> 4'
32
+ spec.add_runtime_dependency 'hashie', '~> 3'
33
+ spec.add_runtime_dependency 'uglifier', '~> 2'
34
34
 
35
35
  spec.add_development_dependency 'aruba', '~> 0'
36
36
  spec.add_development_dependency 'byebug', '~> 3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textualize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Q-Centrix Dev Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor