restspec 0.0.2 → 0.0.3

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: fd6e20ff601f3ae8c3bb0390fbbcf8e86c359847
4
- data.tar.gz: 9f9f4edab9df0f8804ab34bc1d3c281649894680
3
+ metadata.gz: 41fd60364f28c70ec3418baccd6dc501fa314cdf
4
+ data.tar.gz: f9b8820e54a9e08485e2ee4e03125035a7d486d2
5
5
  SHA512:
6
- metadata.gz: e6196c805f031003909f60e2416d742ef8999393eb7d013378835ef2220f7e821743c8f057418390e5e9d6a9c419f2c65895ae1cfa80fb3c6c53e91d70b99b67
7
- data.tar.gz: 12c4be830e60f0d7aabd30f7cd860b622c1a19d2ce4bfe6db081f2d7c0a7eca5528e7eea1ae37469a81d0b84362649dac218cc9cdc0237c81ac557c116a92930
6
+ metadata.gz: 1e56776485136f22670aba96c871ae5ac5ee0b8705e42d59a94bf6884d5477ac59a7e18005b2513dd33a5fac48ab930ced03e3357309794f29ab6bd8fe4a133e
7
+ data.tar.gz: 8760e5c158fdeaac5079d5d5cbfb3562024c19b86be33ef331df2cd699cd076c598ad4dae1e7836b91a716d611083d2d5e4f074eadeb8447928a4d142768cc34
data/.gitignore CHANGED
@@ -15,6 +15,7 @@ mkmf.log
15
15
  *.DS_Store
16
16
  .tags
17
17
  .tags_sorted_by_file
18
+ .rbenv-vars
18
19
 
19
20
  examples/store-api/tmp/pids
20
21
  examples/store-api/tmp/
@@ -0,0 +1 @@
1
+ RESTSPEC_HOME=~/dev/projects/ruby/restspec
@@ -0,0 +1,5 @@
1
+ ---
2
+ language: ruby
3
+ script: bundle exec rspec spec
4
+ rvm:
5
+ - "2.0.0"
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Restspec
1
+ # Restspec [![Gem Version](https://badge.fury.io/rb/restspec.svg)](http://badge.fury.io/rb/restspec) [![Build Status](https://travis-ci.org/platanus/restspec.svg?branch=master)](https://travis-ci.org/platanus/restspec)
2
+
2
3
 
3
4
  Restspec is a REST api framework built in top of RSpec to help you write robust and mantainable tests to ensure that your api behaves exactly as you want.
4
5
 
data/ROADMAP.md CHANGED
@@ -1,13 +1,14 @@
1
- # For 0.1.x
1
+ # For 0.0.x
2
2
  - 100% Test coverage.
3
- - Include Travis.
4
- - Find a way to support a way of authentication based on cookies with an initial login.
5
3
  - Find a way to avoid example value clashes when using resource tests.
6
- - Schemas mixins or/and schemas inheritance.
7
4
 
8
- # For 0.2 (They require more thoughts)
5
+ # For 0.1 (They require more thoughts)
9
6
  - Research pagination strategies and integrating them with `schema_id`.
7
+ - Provide a method for cookie-based authentication.
10
8
  - Research some way to generate markdown from a mix of the schemas and endpoints. (Like Apiary and others)
11
9
  + Generate whatever kind of markdown.
12
10
  + Generate Apiary Apib type.
13
11
  + Add a way to add texts to some points of the documentation.
12
+ + TODO:
13
+ * Untie Schema for Schema Response Body. DELETEs don't return string, they usually returns NO CONTENT. Indeed: nothing.
14
+ * Allow using a TITLE.
@@ -7,9 +7,10 @@ require 'thor'
7
7
  require 'thor/group'
8
8
  require 'pathname'
9
9
  require 'restspec/runners/installer'
10
+ require 'restspec/runners/docs'
10
11
 
11
12
  class RestspecCLI < Thor
12
- register(RestspecInstaller, 'install', 'install [your tests]', 'Type foo install for more help.')
13
+ register(RestspecInstaller, 'install', 'install [your_test_folder]', 'Type restspec install for more help.')
13
14
  end
14
15
 
15
16
  RestspecCLI.start(ARGV)
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'pry'
4
- gem 'restspec', path: '~/dev/projects/ruby/restspec'
4
+ gem 'restspec', path: ENV['RESTSPEC_HOME']
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ~/dev/projects/ruby/restspec
3
3
  specs:
4
- restspec (0.0.1)
4
+ restspec (0.0.2)
5
5
  activesupport (~> 4.0)
6
6
  faker (~> 1.4)
7
7
  hashie (~> 3.3)
@@ -15,7 +15,7 @@ PATH
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- activesupport (4.1.7)
18
+ activesupport (4.1.8)
19
19
  i18n (~> 0.6, >= 0.6.9)
20
20
  json (~> 1.7, >= 1.7.7)
21
21
  minitest (~> 5.1)
@@ -25,25 +25,25 @@ GEM
25
25
  diff-lcs (1.2.5)
26
26
  faker (1.4.3)
27
27
  i18n (~> 0.5)
28
- hashie (3.3.1)
28
+ hashie (3.3.2)
29
29
  httparty (0.13.3)
30
30
  json (~> 1.8)
31
31
  multi_xml (>= 0.5.2)
32
- i18n (0.6.11)
32
+ i18n (0.7.0)
33
33
  json (1.8.1)
34
34
  method_source (0.8.2)
35
- minitest (5.4.3)
35
+ minitest (5.5.0)
36
36
  multi_xml (0.5.5)
37
37
  pry (0.10.1)
38
38
  coderay (~> 1.1.0)
39
39
  method_source (~> 0.8.1)
40
40
  slop (~> 3.4)
41
- rack (1.5.2)
41
+ rack (1.6.0)
42
42
  rspec (3.1.0)
43
43
  rspec-core (~> 3.1.0)
44
44
  rspec-expectations (~> 3.1.0)
45
45
  rspec-mocks (~> 3.1.0)
46
- rspec-collection_matchers (1.0.0)
46
+ rspec-collection_matchers (1.1.2)
47
47
  rspec-expectations (>= 2.99.0.beta1)
48
48
  rspec-core (3.1.7)
49
49
  rspec-support (~> 3.1.0)
@@ -0,0 +1,107 @@
1
+ # API
2
+
3
+ ## Products
4
+ ### Create [POST /products]
5
+ Returns schema **product**:
6
+
7
+ | Attribute | Type | Example |
8
+ |-----------|:-------------:|--------:|
9
+ | name | string | repellat |
10
+ | code | string | architecto |
11
+ | price | decimal | 94.76 |
12
+ | category_id | schema_id | 48 |
13
+ | category | embedded_schema | {:name=>"autem"} |
14
+
15
+ ### Index [GET /products]
16
+ Returns schema **product**:
17
+
18
+ | Attribute | Type | Example |
19
+ |-----------|:-------------:|--------:|
20
+ | name | string | alias |
21
+ | code | string | iste |
22
+ | price | decimal | 43.09 |
23
+ | category_id | schema_id | 48 |
24
+ | category | embedded_schema | {:name=>"et"} |
25
+
26
+ ### Show [GET /products/:id]
27
+ Returns schema **product**:
28
+
29
+ | Attribute | Type | Example |
30
+ |-----------|:-------------:|--------:|
31
+ | name | string | quia |
32
+ | code | string | sint |
33
+ | price | decimal | 40.96 |
34
+ | category_id | schema_id | 48 |
35
+ | category | embedded_schema | {:name=>"suscipit"} |
36
+
37
+ ### Update [PUT /products/:id]
38
+ Returns schema **product**:
39
+
40
+ | Attribute | Type | Example |
41
+ |-----------|:-------------:|--------:|
42
+ | name | string | debitis |
43
+ | code | string | voluptate |
44
+ | price | decimal | 56.88 |
45
+ | category_id | schema_id | 48 |
46
+ | category | embedded_schema | {:name=>"est"} |
47
+
48
+ ### Destroy [DELETE /products/:id]
49
+ Returns schema **product**:
50
+
51
+ | Attribute | Type | Example |
52
+ |-----------|:-------------:|--------:|
53
+ | name | string | facilis |
54
+ | code | string | voluptas |
55
+ | price | decimal | 36.15 |
56
+ | category_id | schema_id | 48 |
57
+ | category | embedded_schema | {:name=>"molestiae"} |
58
+
59
+
60
+ ## Categories
61
+ ### Create [POST /categories]
62
+ Returns schema **category**:
63
+
64
+ | Attribute | Type | Example |
65
+ |-----------|:-------------:|--------:|
66
+ | name | string | dolorum |
67
+
68
+ ### Index [GET /categories]
69
+ Returns schema **category**:
70
+
71
+ | Attribute | Type | Example |
72
+ |-----------|:-------------:|--------:|
73
+ | name | string | necessitatibus |
74
+
75
+ ### Show [GET /categories/:id]
76
+ Returns schema **category**:
77
+
78
+ | Attribute | Type | Example |
79
+ |-----------|:-------------:|--------:|
80
+ | name | string | repellat |
81
+
82
+ ### Update [PUT /categories/:id]
83
+ Returns schema **category**:
84
+
85
+ | Attribute | Type | Example |
86
+ |-----------|:-------------:|--------:|
87
+ | name | string | consequatur |
88
+
89
+ ### Destroy [DELETE /categories/:id]
90
+ Returns schema **category**:
91
+
92
+ | Attribute | Type | Example |
93
+ |-----------|:-------------:|--------:|
94
+ | name | string | porro |
95
+
96
+ ### Products [GET /categories/:id/products]
97
+ Returns schema **product**:
98
+
99
+ | Attribute | Type | Example |
100
+ |-----------|:-------------:|--------:|
101
+ | name | string | et |
102
+ | code | string | vero |
103
+ | price | decimal | 33.52 |
104
+ | category_id | schema_id | 48 |
105
+ | category | embedded_schema | {:name=>"autem"} |
106
+
107
+
@@ -1,9 +1,15 @@
1
+ mixin :timestamps do
2
+ attribute :created_at, datetime, :for => [:checks]
3
+ attribute :updated_at, datetime, :for => [:checks]
4
+ end
5
+
1
6
  schema :product do
2
7
  attribute :name, string
3
8
  attribute :code, string
4
9
  attribute :price, decimal | decimal_string
5
10
  attribute :category_id, schema_id(:category)
6
11
  attribute :category, embedded_schema(:category), :for => [:checks]
12
+ include_attributes :timestamps
7
13
  end
8
14
 
9
15
  schema :category do
@@ -1,4 +1,4 @@
1
1
  json.array!(@products) do |product|
2
- json.extract! product, :id, :name, :code, :price, :category_id
2
+ json.extract! product, :id, :name, :code, :price, :category_id, :created_at, :updated_at
3
3
  json.url product_url(product, format: :json)
4
4
  end
@@ -4,6 +4,7 @@ module Restspec
4
4
  end
5
5
 
6
6
  require 'active_support/core_ext/object'
7
+ require 'active_support/json'
7
8
 
8
9
  require "restspec/values/status_code"
9
10
  require "restspec/values/super_hash"
@@ -0,0 +1,65 @@
1
+ module Restspec
2
+ module DocGenerators
3
+ class Markdown
4
+ attr_reader :markdown_string
5
+
6
+ def initialize
7
+ self.markdown_string = ''
8
+ end
9
+
10
+ def generate
11
+ generate_app_header
12
+
13
+ ns_store.each do |ns|
14
+ markdown_string << "## #{ns.name.capitalize}\n"
15
+ generate_endpoints(ns)
16
+ markdown_string << "\n"
17
+ end
18
+
19
+ markdown_string
20
+ end
21
+
22
+ private
23
+
24
+ attr_writer :markdown_string
25
+
26
+ def generate_app_header
27
+ markdown_string << "# API\n\n"
28
+ end
29
+
30
+ def generate_endpoints(ns)
31
+ ns.all_endpoints.each do |endpoint|
32
+ markdown_string << "### #{endpoint.name.capitalize} [#{endpoint.method.upcase} #{endpoint.full_path}]\n"
33
+ markdown_string << "Returns schema **#{endpoint.schema_name}**:\n"
34
+
35
+ generate_schema_table(endpoint.schema_name)
36
+ end
37
+ end
38
+
39
+ def generate_schema_table(schema_name)
40
+ schema = schema_store.get(schema_name)
41
+
42
+ markdown_string << "
43
+ | Attribute | Type | Example |
44
+ |-----------|:-------------:|--------:|
45
+ #{
46
+ schema.attributes.map do |name, attribute|
47
+ "| #{name} | #{attribute.type.to_s} | #{attribute.type.example_for(attribute)} |"
48
+ end.join("\n")
49
+ }\n\n"
50
+ end
51
+
52
+ def ns_store
53
+ Restspec::NamespaceStore.uniq { |ns| ns.name }
54
+ end
55
+
56
+ def endpoints_store
57
+ Restspec::EndpointStore
58
+ end
59
+
60
+ def schema_store
61
+ Restspec::SchemaStore
62
+ end
63
+ end
64
+ end
65
+ end
@@ -34,6 +34,10 @@ module Restspec
34
34
  search_internal_endpoint(endpoint_name) || search_child_endpoint(endpoint_name)
35
35
  end
36
36
 
37
+ def all_endpoints
38
+ endpoints + children_namespaces.map { |ns| ns.all_endpoints }.flatten
39
+ end
40
+
37
41
  def top_level_namespace?
38
42
  parent_namespace.nil?
39
43
  end
@@ -15,7 +15,7 @@ module Restspec
15
15
  end
16
16
 
17
17
  def network_adapter_lambda
18
- Restspec.config.request.network_adapter
18
+ Restspec.config.request.try(:network_adapter)
19
19
  end
20
20
 
21
21
  def default_network_adapter
@@ -0,0 +1,20 @@
1
+ class RestspecDocs < Thor::Group
2
+ include Thor::Actions
3
+
4
+ argument :file
5
+
6
+ def generate_docs
7
+ require 'restspec'
8
+ require config_file
9
+ require 'restspec/doc_generators/markdown'
10
+
11
+ generator = Restspec::DocGenerators::Markdown.new
12
+ File.write(file, generator.generate)
13
+ end
14
+
15
+ private
16
+
17
+ def config_file
18
+ Pathname.new(Dir.pwd).join('spec/api/restspec/restspec_config.rb')
19
+ end
20
+ end
@@ -2,19 +2,29 @@ module Restspec
2
2
  module Schema
3
3
  class DSL
4
4
  attr_reader :schemas
5
+ attr_accessor :mixins
6
+
7
+ def initialize
8
+ self.mixins = {}
9
+ end
5
10
 
6
11
  def schema(name, &definition)
7
- dsl = SingleSchemaDSL.new(name)
12
+ dsl = SingleSchemaDSL.new(name, mixins)
8
13
  dsl.instance_eval(&definition)
9
14
  Restspec::SchemaStore.store(dsl.schema)
10
15
  end
16
+
17
+ def mixin(name, &definition)
18
+ mixins[name] = definition
19
+ end
11
20
  end
12
21
 
13
22
  class SingleSchemaDSL
14
- attr_reader :schema
23
+ attr_reader :schema, :mixins
15
24
 
16
- def initialize(name)
25
+ def initialize(name, mixins = {})
17
26
  self.schema = Schema.new(name)
27
+ self.mixins = mixins
18
28
  end
19
29
 
20
30
  def attribute(name, type, options = {})
@@ -22,6 +32,10 @@ module Restspec
22
32
  schema.attributes[name.to_s] = new_attribute
23
33
  end
24
34
 
35
+ def include_attributes(name)
36
+ self.instance_eval &mixins.fetch(name)
37
+ end
38
+
25
39
  Types::ALL.each do |type_name, type_class|
26
40
  define_method(type_name) do |options = {}|
27
41
  type_class.new(options)
@@ -30,7 +44,7 @@ module Restspec
30
44
 
31
45
  private
32
46
 
33
- attr_writer :schema
47
+ attr_writer :schema, :mixins
34
48
  end
35
49
  end
36
50
  end
@@ -17,6 +17,8 @@ require_relative './types/one_of_type'
17
17
  require_relative './types/hash_type'
18
18
  require_relative './types/null_type'
19
19
  require_relative './types/embedded_schema_type'
20
+ require_relative './types/date_type'
21
+ require_relative './types/datetime_type'
20
22
 
21
23
  module Restspec::Schema::Types
22
24
  ALL = {
@@ -30,6 +32,8 @@ module Restspec::Schema::Types
30
32
  one_of: OneOfType,
31
33
  hash: HashType,
32
34
  null: NullType,
33
- embedded_schema: EmbeddedSchemaType
35
+ embedded_schema: EmbeddedSchemaType,
36
+ date: DateType,
37
+ datetime: DateTimeType
34
38
  }
35
39
  end
@@ -21,6 +21,10 @@ class Restspec::Schema::Types::BasicType
21
21
  end
22
22
  end
23
23
 
24
+ def to_s
25
+ self.class.name.demodulize.gsub(/Type$/, "").underscore
26
+ end
27
+
24
28
  private
25
29
 
26
30
  attr_accessor :options, :disjuction, :parameterized_type
@@ -0,0 +1,16 @@
1
+ module Restspec::Schema::Types
2
+ class DateType < BasicType
3
+ DATE_FORMAT = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
4
+
5
+ def example_for(attribute)
6
+ Faker::Date.between(1.month.ago, Date.today).to_s
7
+ end
8
+
9
+ def valid?(attribute, value)
10
+ return false unless value.present?
11
+ return false unless value.match(DATE_FORMAT).present?
12
+ year, month, day = value.split('-').map &:to_i
13
+ Date.valid_date?(year, month, day)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ module Restspec::Schema::Types
2
+ class DateTimeType < BasicType
3
+ def example_for(attribute)
4
+ Faker::Time.between(initial_example_interval, final_example_interval).iso8601
5
+ end
6
+
7
+ def valid?(attribute, value)
8
+ return false unless value.present?
9
+ allowed_date_time_formats.any? do |format|
10
+ DateTime.parse(value).strftime(format) == value
11
+ end
12
+ rescue ArgumentError
13
+ false
14
+ end
15
+
16
+ private
17
+
18
+ def allowed_date_time_formats
19
+ ['%Y-%m-%dT%H:%M:%S.%LZ', '%Y-%m-%dT%H:%M:%S%Z']
20
+ end
21
+
22
+ def initial_example_interval
23
+ example_options.fetch(:initial_interval, 1.month.ago)
24
+ end
25
+
26
+ def final_example_interval
27
+ example_options.fetch(:final_interval, Time.now)
28
+ end
29
+ end
30
+ end
@@ -21,6 +21,9 @@ module Restspec::Schema::Types
21
21
  raise "We couldn't fetch any information for this example"
22
22
  }
23
23
  end
24
+ rescue URI::InvalidURIError, Errno::ECONNREFUSED => e
25
+ puts "WARNING: Error calling api #{e}. Falling back to use a number."
26
+ Faker::Number.digit
24
27
  end
25
28
 
26
29
  def valid?(attribute, value)
@@ -1,3 +1,3 @@
1
1
  module Restspec
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+ require 'restspec'
3
+ require 'restspec/doc_generators/markdown'
4
+
5
+ def clear_stores
6
+ Restspec::NamespaceStore.clear
7
+ Restspec::EndpointStore.clear
8
+ Restspec::SchemaStore.clear
9
+ end
10
+
11
+ def populate_endpoints
12
+ Restspec::Endpoints::DSL.new.instance_eval do
13
+ resource :products do
14
+ schema :product
15
+
16
+ collection do
17
+ post :create
18
+ get :index do
19
+ schema :product, without: [:category]
20
+ end
21
+ end
22
+
23
+ member do
24
+ url_param(:id) { schema_id(:product) }
25
+
26
+ get :show
27
+ put :update
28
+ delete :destroy
29
+ end
30
+ end
31
+
32
+ resource :categories do
33
+ schema :category
34
+
35
+ collection do
36
+ post :create
37
+ get :index
38
+ end
39
+
40
+ member do
41
+ url_param(:id) { schema_id(:category) }
42
+
43
+ get :show
44
+ put :update
45
+ delete :destroy
46
+
47
+ get :products, '/products' do
48
+ schema :product
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def populate_schemas
56
+ Restspec::Schema::DSL.new.instance_eval do
57
+ schema :product do
58
+ attribute :name, string
59
+ attribute :code, string
60
+ attribute :price, decimal | decimal_string
61
+ attribute :category_id, schema_id(:category)
62
+ attribute :category, embedded_schema(:category), :for => [:checks]
63
+ end
64
+
65
+ schema :category do
66
+ attribute :name, string
67
+ end
68
+ end
69
+ end
70
+
71
+ describe Restspec::DocGenerators::Markdown do
72
+ before do
73
+ clear_stores
74
+ populate_schemas
75
+ populate_endpoints
76
+ end
77
+
78
+ let(:generator) { Restspec::DocGenerators::Markdown.new }
79
+
80
+ describe '#generate' do
81
+ it 'only happens for exploration' do
82
+ # require 'pry'; binding.pry
83
+ puts "\n" * 3
84
+ puts generator.generate
85
+ puts "\n" * 3
86
+ end
87
+ end
88
+ end
@@ -75,4 +75,20 @@ describe SingleSchemaDSL do
75
75
  end
76
76
  end
77
77
  end
78
+
79
+ describe '#include_attributes' do
80
+ let(:main_dsl) { DSL.new }
81
+ let(:schema_dsl) { SingleSchemaDSL.new(:name, main_dsl.mixins) }
82
+
83
+ before do
84
+ main_dsl.mixin :test_mixin do
85
+ attribute :test_attribute, string
86
+ end
87
+ end
88
+
89
+ it 'includes the attributes to the schema' do
90
+ schema_dsl.include_attributes(:test_mixin)
91
+ expect(schema_dsl.schema.attributes).to have_key('test_attribute')
92
+ end
93
+ end
78
94
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ include Restspec::Schema::Types
4
+
5
+ describe DateType do
6
+ let(:type) { DateType.new }
7
+ let(:attribute) { double }
8
+
9
+ describe '#example_for' do
10
+ it 'returns a valid date' do
11
+ expect(type.example_for(attribute).match(DateType::DATE_FORMAT)).to be_present
12
+ end
13
+ end
14
+
15
+ describe '#valid?' do
16
+ it 'validates dates in the ISO 8601 format' do
17
+ expect(type.valid?(attribute, '2014-12-19')).to eq(true)
18
+ expect(type.valid?(attribute, '2014/12/19')).to eq(false)
19
+ expect(type.valid?(attribute, '2014-12-19 01:31:10')).to eq(false)
20
+ expect(type.valid?(attribute, '20141219')).to eq(false)
21
+ expect(type.valid?(attribute, '2014-19-12')).to eq(false)
22
+ expect(type.valid?(attribute, '19-12-2014')).to eq(false)
23
+ expect(type.valid?(attribute, '12-19-2014')).to eq(false)
24
+ expect(type.valid?(attribute, '19/12/2014')).to eq(false)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ include Restspec::Schema::Types
4
+
5
+ describe DateTimeType do
6
+ let(:type) { DateTimeType.new }
7
+ let(:attribute) { double }
8
+
9
+ describe '#example_for' do
10
+ it 'returns a valid date' do
11
+ value = type.example_for(attribute)
12
+ expect(DateTime.parse(value).iso8601).to eq(value)
13
+ end
14
+ end
15
+
16
+ describe '#valid?' do
17
+ it 'validates dates in the ISO 8601 format' do
18
+ expect(type.valid?(attribute, '2014-12-18T00:00:00+00:00')).to eq(true)
19
+ expect(type.valid?(attribute, '2014-12-18 T00:00:00+00:00')).to eq(false)
20
+ expect(type.valid?(attribute, '2014-12-19')).to eq(false)
21
+ expect(type.valid?(attribute, '20141219')).to eq(false)
22
+ expect(type.valid?(attribute, '2014-19-12')).to eq(false)
23
+ expect(type.valid?(attribute, '19-12-2014')).to eq(false)
24
+ expect(type.valid?(attribute, '12-19-2014')).to eq(false)
25
+ expect(type.valid?(attribute, '2014-12-19 013110')).to eq(false)
26
+ expect(type.valid?(attribute, '2014-12-19 01-31-10')).to eq(false)
27
+ expect(type.valid?(attribute, '2014/12/19 01-31-10')).to eq(false)
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,237 +1,237 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2014-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.8'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '4.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '4.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-nc
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.2'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.9.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.9.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: activesupport
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: '4.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: '4.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: faker
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: '1.4'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.4'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: hashie
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
145
  version: '3.3'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
152
  version: '3.3'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rack
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - "~>"
157
+ - - ~>
158
158
  - !ruby/object:Gem::Version
159
159
  version: '1.0'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - "~>"
164
+ - - ~>
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1.0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - "~>"
171
+ - - ~>
172
172
  - !ruby/object:Gem::Version
173
173
  version: '3.0'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - "~>"
178
+ - - ~>
179
179
  - !ruby/object:Gem::Version
180
180
  version: '3.0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: httparty
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - "~>"
185
+ - - ~>
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0.13'
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - "~>"
192
+ - - ~>
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.13'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rspec-its
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - "~>"
199
+ - - ~>
200
200
  - !ruby/object:Gem::Version
201
201
  version: '1.0'
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - "~>"
206
+ - - ~>
207
207
  - !ruby/object:Gem::Version
208
208
  version: '1.0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rspec-collection_matchers
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - "~>"
213
+ - - ~>
214
214
  - !ruby/object:Gem::Version
215
215
  version: '1.0'
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - "~>"
220
+ - - ~>
221
221
  - !ruby/object:Gem::Version
222
222
  version: '1.0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: thor
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - "~>"
227
+ - - ~>
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0.19'
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - "~>"
234
+ - - ~>
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0.19'
237
237
  description: RSpec macros, helpers and matchers to work with APIs
@@ -242,9 +242,11 @@ executables:
242
242
  extensions: []
243
243
  extra_rdoc_files: []
244
244
  files:
245
- - ".editorconfig"
246
- - ".gitignore"
247
- - ".rspec"
245
+ - .editorconfig
246
+ - .gitignore
247
+ - .rbenv-vars.example
248
+ - .rspec
249
+ - .travis.yml
248
250
  - Gemfile
249
251
  - Guardfile
250
252
  - LICENSE.txt
@@ -266,6 +268,7 @@ files:
266
268
  - examples/store-api-tests/.rspec
267
269
  - examples/store-api-tests/Gemfile
268
270
  - examples/store-api-tests/Gemfile.lock
271
+ - examples/store-api-tests/api.md
269
272
  - examples/store-api-tests/spec/api/category_spec.rb
270
273
  - examples/store-api-tests/spec/api/product_spec.rb
271
274
  - examples/store-api-tests/spec/api/restspec/endpoints.rb
@@ -278,7 +281,6 @@ files:
278
281
  - examples/store-api/.editorconfig
279
282
  - examples/store-api/.rbenv-vars.example
280
283
  - examples/store-api/.rspec
281
- - examples/store-api/.ruby-version
282
284
  - examples/store-api/Gemfile
283
285
  - examples/store-api/Gemfile.lock
284
286
  - examples/store-api/Guardfile
@@ -382,6 +384,7 @@ files:
382
384
  - examples/store-api/vendor/assets/stylesheets/.keep
383
385
  - lib/restspec.rb
384
386
  - lib/restspec/configuration.rb
387
+ - lib/restspec/doc_generators/markdown.rb
385
388
  - lib/restspec/endpoints/dsl.rb
386
389
  - lib/restspec/endpoints/endpoint.rb
387
390
  - lib/restspec/endpoints/namespace.rb
@@ -400,6 +403,7 @@ files:
400
403
  - lib/restspec/rspec/matchers/have_status.rb
401
404
  - lib/restspec/rspec/matchers/include_where.rb
402
405
  - lib/restspec/rspec/shared_examples.rb
406
+ - lib/restspec/runners/docs.rb
403
407
  - lib/restspec/runners/installer.rb
404
408
  - lib/restspec/schema/attribute.rb
405
409
  - lib/restspec/schema/attribute_example.rb
@@ -411,6 +415,8 @@ files:
411
415
  - lib/restspec/schema/types/array_type.rb
412
416
  - lib/restspec/schema/types/basic_type.rb
413
417
  - lib/restspec/schema/types/boolean_type.rb
418
+ - lib/restspec/schema/types/date_type.rb
419
+ - lib/restspec/schema/types/datetime_type.rb
414
420
  - lib/restspec/schema/types/decimal_string_type.rb
415
421
  - lib/restspec/schema/types/decimal_type.rb
416
422
  - lib/restspec/schema/types/embedded_schema_type.rb
@@ -428,6 +434,7 @@ files:
428
434
  - lib/restspec/values/super_hash.rb
429
435
  - lib/restspec/version.rb
430
436
  - restspec.gemspec
437
+ - spec/restspec/doc_generators/markdown_spec.rb
431
438
  - spec/restspec/endpoints/dsl_spec.rb
432
439
  - spec/restspec/endpoints/endpoint_spec.rb
433
440
  - spec/restspec/endpoints/namespace_spec.rb
@@ -439,6 +446,8 @@ files:
439
446
  - spec/restspec/schema/types/array_type_spec.rb
440
447
  - spec/restspec/schema/types/basic_type_spec.rb
441
448
  - spec/restspec/schema/types/boolean_type_spec.rb
449
+ - spec/restspec/schema/types/date_type_spec.rb
450
+ - spec/restspec/schema/types/datetime_type_spec.rb
442
451
  - spec/restspec/schema/types/null_type_spec.rb
443
452
  - spec/restspec/schema/types/string_type_spec.rb
444
453
  - spec/restspec/values/status_code_spec.rb
@@ -453,21 +462,22 @@ require_paths:
453
462
  - lib
454
463
  required_ruby_version: !ruby/object:Gem::Requirement
455
464
  requirements:
456
- - - ">="
465
+ - - '>='
457
466
  - !ruby/object:Gem::Version
458
467
  version: '0'
459
468
  required_rubygems_version: !ruby/object:Gem::Requirement
460
469
  requirements:
461
- - - ">="
470
+ - - '>='
462
471
  - !ruby/object:Gem::Version
463
472
  version: '0'
464
473
  requirements: []
465
474
  rubyforge_project:
466
- rubygems_version: 2.2.2
475
+ rubygems_version: 2.0.14
467
476
  signing_key:
468
477
  specification_version: 4
469
478
  summary: RSpec macros, helpers and matchers to work with APIs
470
479
  test_files:
480
+ - spec/restspec/doc_generators/markdown_spec.rb
471
481
  - spec/restspec/endpoints/dsl_spec.rb
472
482
  - spec/restspec/endpoints/endpoint_spec.rb
473
483
  - spec/restspec/endpoints/namespace_spec.rb
@@ -479,6 +489,8 @@ test_files:
479
489
  - spec/restspec/schema/types/array_type_spec.rb
480
490
  - spec/restspec/schema/types/basic_type_spec.rb
481
491
  - spec/restspec/schema/types/boolean_type_spec.rb
492
+ - spec/restspec/schema/types/date_type_spec.rb
493
+ - spec/restspec/schema/types/datetime_type_spec.rb
482
494
  - spec/restspec/schema/types/null_type_spec.rb
483
495
  - spec/restspec/schema/types/string_type_spec.rb
484
496
  - spec/restspec/values/status_code_spec.rb
@@ -1 +0,0 @@
1
- 2.0.0-p353