rspec_request_helpers 0.1.0 → 0.1.1
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 +4 -4
- data/Gemfile.lock +25 -25
- data/README.md +4 -1
- data/bin/console +4 -4
- data/lib/generators/rspec/endpoint/templates/action_request_spec.rb +4 -4
- data/lib/rspec_request_helpers/helpers.rb +25 -3
- data/lib/rspec_request_helpers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69e19b4a72e694e48266c3fd82963bdc49d29e1047afa3f9e8e58a20eb66ecca
|
|
4
|
+
data.tar.gz: 2c90b13de3ae5897644d4291639152ef439a808046f5b7119354939af37735b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c049a3267279fdd1b30f3356e3568615dd0f528d1ce546d32040c7246b49d37c26f625949644038451a21073f3fbcfcd3ea0b2606804938f77ca2f2cadb101e
|
|
7
|
+
data.tar.gz: 96ae41fccbd1bbce862512002e94d5d0db5edf9701d2844154be0babfb4c1eb3986d816d484bd1b9048fca891331cc6da73b8e5bdc646ea56c9074223ff52742
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rspec_request_helpers (0.1.
|
|
4
|
+
rspec_request_helpers (0.1.1)
|
|
5
5
|
actionpack (>= 3.0)
|
|
6
6
|
activesupport (>= 3.0)
|
|
7
7
|
rack (~> 2.0)
|
|
@@ -11,20 +11,20 @@ PATH
|
|
|
11
11
|
GEM
|
|
12
12
|
remote: https://rubygems.org/
|
|
13
13
|
specs:
|
|
14
|
-
actionpack (5.2.
|
|
15
|
-
actionview (= 5.2.
|
|
16
|
-
activesupport (= 5.2.
|
|
14
|
+
actionpack (5.2.1)
|
|
15
|
+
actionview (= 5.2.1)
|
|
16
|
+
activesupport (= 5.2.1)
|
|
17
17
|
rack (~> 2.0)
|
|
18
18
|
rack-test (>= 0.6.3)
|
|
19
19
|
rails-dom-testing (~> 2.0)
|
|
20
20
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
21
|
-
actionview (5.2.
|
|
22
|
-
activesupport (= 5.2.
|
|
21
|
+
actionview (5.2.1)
|
|
22
|
+
activesupport (= 5.2.1)
|
|
23
23
|
builder (~> 3.1)
|
|
24
24
|
erubi (~> 1.4)
|
|
25
25
|
rails-dom-testing (~> 2.0)
|
|
26
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
27
|
-
activesupport (5.2.
|
|
27
|
+
activesupport (5.2.1)
|
|
28
28
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
29
29
|
i18n (>= 0.7, < 2)
|
|
30
30
|
minitest (~> 5.1)
|
|
@@ -35,7 +35,7 @@ GEM
|
|
|
35
35
|
crass (1.0.4)
|
|
36
36
|
diff-lcs (1.3)
|
|
37
37
|
erubi (1.7.1)
|
|
38
|
-
i18n (1.
|
|
38
|
+
i18n (1.1.1)
|
|
39
39
|
concurrent-ruby (~> 1.0)
|
|
40
40
|
loofah (2.2.2)
|
|
41
41
|
crass (~> 1.0.2)
|
|
@@ -43,39 +43,39 @@ GEM
|
|
|
43
43
|
method_source (0.9.0)
|
|
44
44
|
mini_portile2 (2.3.0)
|
|
45
45
|
minitest (5.11.3)
|
|
46
|
-
nokogiri (1.8.
|
|
46
|
+
nokogiri (1.8.5)
|
|
47
47
|
mini_portile2 (~> 2.3.0)
|
|
48
48
|
pry (0.11.3)
|
|
49
49
|
coderay (~> 1.1.0)
|
|
50
50
|
method_source (~> 0.9.0)
|
|
51
51
|
rack (2.0.5)
|
|
52
|
-
rack-test (1.
|
|
52
|
+
rack-test (1.1.0)
|
|
53
53
|
rack (>= 1.0, < 3)
|
|
54
54
|
rails-dom-testing (2.0.3)
|
|
55
55
|
activesupport (>= 4.2.0)
|
|
56
56
|
nokogiri (>= 1.6)
|
|
57
57
|
rails-html-sanitizer (1.0.4)
|
|
58
58
|
loofah (~> 2.2, >= 2.2.2)
|
|
59
|
-
railties (5.2.
|
|
60
|
-
actionpack (= 5.2.
|
|
61
|
-
activesupport (= 5.2.
|
|
59
|
+
railties (5.2.1)
|
|
60
|
+
actionpack (= 5.2.1)
|
|
61
|
+
activesupport (= 5.2.1)
|
|
62
62
|
method_source
|
|
63
63
|
rake (>= 0.8.7)
|
|
64
|
-
thor (>= 0.
|
|
64
|
+
thor (>= 0.19.0, < 2.0)
|
|
65
65
|
rake (10.5.0)
|
|
66
|
-
rspec (3.
|
|
67
|
-
rspec-core (~> 3.
|
|
68
|
-
rspec-expectations (~> 3.
|
|
69
|
-
rspec-mocks (~> 3.
|
|
70
|
-
rspec-core (3.
|
|
71
|
-
rspec-support (~> 3.
|
|
72
|
-
rspec-expectations (3.
|
|
66
|
+
rspec (3.8.0)
|
|
67
|
+
rspec-core (~> 3.8.0)
|
|
68
|
+
rspec-expectations (~> 3.8.0)
|
|
69
|
+
rspec-mocks (~> 3.8.0)
|
|
70
|
+
rspec-core (3.8.0)
|
|
71
|
+
rspec-support (~> 3.8.0)
|
|
72
|
+
rspec-expectations (3.8.2)
|
|
73
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
74
|
-
rspec-support (~> 3.
|
|
75
|
-
rspec-mocks (3.
|
|
74
|
+
rspec-support (~> 3.8.0)
|
|
75
|
+
rspec-mocks (3.8.0)
|
|
76
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
|
-
rspec-support (~> 3.
|
|
78
|
-
rspec-support (3.
|
|
77
|
+
rspec-support (~> 3.8.0)
|
|
78
|
+
rspec-support (3.8.0)
|
|
79
79
|
thor (0.20.0)
|
|
80
80
|
thread_safe (0.3.6)
|
|
81
81
|
tzinfo (1.2.5)
|
data/README.md
CHANGED
|
@@ -4,7 +4,10 @@ This gem provides few tools to make testing of API endpoint in your Rails applic
|
|
|
4
4
|
This rules were influenced by real projects experience so
|
|
5
5
|
In order to use it in your `rspec/requests` specs you need to follow one rule:
|
|
6
6
|
|
|
7
|
-
For every test example you need to define `path`, `valid_headers`, `valid_params`, and `
|
|
7
|
+
For every test example you need to define `path`, `valid_headers`, `valid_params`, and `expected_response`.
|
|
8
|
+
|
|
9
|
+
NOTE: version 0.1.1 introduced the helpers which ensure naming conventions. They have identical names and in fact are
|
|
10
|
+
wrappers around RSpec `let` functionality.
|
|
8
11
|
|
|
9
12
|
So what you'll got for that? Few handy methods for the testing routine
|
|
10
13
|
|
data/bin/console
CHANGED
|
@@ -7,8 +7,8 @@ require "rspec_request_helpers"
|
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
8
8
|
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
require "pry"
|
|
11
|
+
Pry.start
|
|
12
12
|
|
|
13
|
-
require "irb"
|
|
14
|
-
IRB.start(__FILE__)
|
|
13
|
+
# require "irb"
|
|
14
|
+
# IRB.start(__FILE__)
|
|
@@ -2,10 +2,10 @@ RSpec.describe '', type: :request do
|
|
|
2
2
|
<% @path_params.each do |param| %>
|
|
3
3
|
<%= "let(#{param}) { #{rand(99..500)} }" %>
|
|
4
4
|
<% end %>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
path { "<%= @path %>" }
|
|
6
|
+
valid_headers { {} }
|
|
7
|
+
valid_params { {} }
|
|
8
|
+
expected_response { {} }
|
|
9
9
|
|
|
10
10
|
describe '<%= @http_verb.upcase %> <%= controller %>#<%= file_name %>' do
|
|
11
11
|
context '' do
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
module RspecRequestHelpers
|
|
2
2
|
module Helpers
|
|
3
|
+
module ClassMethods
|
|
4
|
+
def path(&block)
|
|
5
|
+
let(:path, &block)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def valid_params(&block)
|
|
9
|
+
let(:valid_params, &block)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def valid_headers(&block)
|
|
13
|
+
let(:valid_headers, &block)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def expected_response(&block)
|
|
17
|
+
let(:expected_response, &block)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.included(klass)
|
|
22
|
+
klass.extend ClassMethods
|
|
23
|
+
end
|
|
24
|
+
|
|
3
25
|
def object(hash)
|
|
4
26
|
OpenStruct.new(hash)
|
|
5
27
|
end
|
|
@@ -21,15 +43,15 @@ module RspecRequestHelpers
|
|
|
21
43
|
end
|
|
22
44
|
|
|
23
45
|
def assert_body
|
|
24
|
-
expect(response.body).to eq
|
|
46
|
+
expect(response.body).to eq expected_response
|
|
25
47
|
end
|
|
26
48
|
|
|
27
49
|
def assert_response_object
|
|
28
|
-
expect(response_object).to have_attributes(
|
|
50
|
+
expect(response_object).to have_attributes(expected_response)
|
|
29
51
|
end
|
|
30
52
|
|
|
31
53
|
def assert_response_body
|
|
32
|
-
expect(response_body).to eq(
|
|
54
|
+
expect(response_body).to eq(expected_response)
|
|
33
55
|
end
|
|
34
56
|
|
|
35
57
|
def self.generate_helpers
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec_request_helpers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrii Baran
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-10-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|