rspec-grape 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: 344cd46b986acfa1c98f7df3419a1a51864c78c3
4
- data.tar.gz: 2afd9b00e7aca8e40e585ec4ed8f91ba699107f7
3
+ metadata.gz: 53dffc4ee324581222ce3f71be6f754d018c3519
4
+ data.tar.gz: c6fabdd0c1867136da1069423e60b1df239bd0bf
5
5
  SHA512:
6
- metadata.gz: fd7def411a10fc6144d71b73e3bdd4f5e8dcac2dfd06870504a576c6b4a0a7ada075de768dd4c0fa4719310abb64bfb8cda02d80cebbab7b33f944d6ab09ae24
7
- data.tar.gz: 2d85a9763c394be30c67320ea9e3ed10a0db18cc17c52624f0f28108bb29c29721eb03091e890c681e0659952c83c2e3f5fcfd649051d57550f703206edbd239
6
+ metadata.gz: 2355940cfd8573aeca126bfda5f4fc321f488572dca3bb5ef4dee96b08e018cf70062e21a998ca621e477c3d7b1213b678baf89bbb70b7e20706984a6b7dba05
7
+ data.tar.gz: 09fe14fde234836a83a7e874972f3e2ea943f301a1abcc5341288975d22fb344de85d97505dbcfc375395bc352219b681404488a0ab065d274bd9f924d600027
data/README.md CHANGED
@@ -62,20 +62,12 @@ end
62
62
 
63
63
  ### Passing request params
64
64
 
65
- Params can be either passed to `call_api` method:
65
+ Params can be passed to `call_api` method:
66
66
 
67
67
  ```ruby
68
68
  call_api({foo: :bar})
69
69
  ```
70
70
 
71
- or set via `let`:
72
-
73
- ```ruby
74
- let(:api_params) { { foo: :bar } }
75
- ```
76
-
77
- Note, that params, explicitly passed to `call_api`, have precendence over thoose set in `api_params`.
78
-
79
71
  ### Stubbing API helpers
80
72
 
81
73
  rspec-grape provides two methods to stub API helpers: `expect_endpoint_to` and `expect_endpoint_not_to`. You can easily write:
@@ -93,7 +85,7 @@ When you define some parameters in url like
93
85
  ```ruby
94
86
  get '/url/with/:param'
95
87
  ```
96
- you can use `parameterized_api_url` helper. You can set parameter values via `:api_params` or expliciltly pass them to helper. The result will be url with parameter names substituted with actual values:
88
+ you can use `parameterized_api_url` helper to generate full url. Pass parameters as hash. The result will be url with parameter names substituted with actual values:
97
89
  ```ruby
98
90
  parameterized_api_url(param: 'defined') # '/url/with/defined'
99
91
  ```
@@ -101,6 +93,23 @@ parameterized_api_url(param: 'defined') # '/url/with/defined'
101
93
  If some parameters are not set, method will raise `RSpec::Grape::UrlNotSetException`.
102
94
  Note that `call_api` helper will use parameterized_url to generate url to be called.
103
95
 
96
+ ### Nested descriptions
97
+
98
+ You may need to define nested descriptions of endpoint when you are using inline url parameters:
99
+ ```ruby
100
+ describe 'GET /inline/:param' do
101
+ describe 'GET /inline/false' do
102
+ ...
103
+ end
104
+
105
+ describe 'GET /inline/true' do
106
+ ...
107
+ end
108
+ end
109
+ ```
110
+
111
+ In this case `api_url` will point to inner description, `/inline/false` and `/inline/true` consequently. If you set all inline parameters in description, there is no need to pass parameters to `call_api`.
112
+
104
113
  ### Additional spec helpers
105
114
 
106
115
  It is also possible to use two methods in your specs: `api_url` and `api_method`. The former returns url from spec description, while the latter returns http method.
@@ -18,7 +18,7 @@ module RSpec
18
18
  def parameterized_api_url(params = nil)
19
19
  raise RSpec::Grape::UrlIsNotParameterized unless parameterized_url?
20
20
 
21
- params ||= resolve_params(params)
21
+ params ||= {}
22
22
 
23
23
  url = api_url.dup
24
24
  names = RSpec::Grape::Utils.url_param_names(api_url)
@@ -32,7 +32,7 @@ module RSpec
32
32
  end
33
33
 
34
34
  def call_api(params = nil)
35
- params ||= resolve_params(params)
35
+ params ||= {}
36
36
 
37
37
  if parameterized_url?
38
38
  url = parameterized_api_url(params)
@@ -61,10 +61,6 @@ module RSpec
61
61
  def parameterized_url?
62
62
  api_url =~ /\/:/
63
63
  end
64
-
65
- def resolve_params(params = nil)
66
- params || self.respond_to?(:api_params) ? api_params : {}
67
- end
68
64
  end
69
65
  end
70
66
  end
@@ -17,7 +17,7 @@ module RSpec
17
17
 
18
18
  raise RSpec::Grape::NoEndpointDescription unless ancestors.any?
19
19
 
20
- ancestors.last.description
20
+ ancestors.first.description
21
21
  end
22
22
 
23
23
  def self.url_param_names(url)
@@ -1,5 +1,5 @@
1
1
  module Rspec
2
2
  module Grape
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-grape
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
  - Timothy Kovalev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-18 00:00:00.000000000 Z
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-test