rspec_request_helpers 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 3eba98c737fc0c7dbc0130ec73ddd1deb055a48d397dc6ee4ae032b212e5ef54
4
- data.tar.gz: 90bd7b0a2381787c347a7f7801d3d938128d998f28ab0c93d719e0e953f5a1c0
3
+ metadata.gz: 69e19b4a72e694e48266c3fd82963bdc49d29e1047afa3f9e8e58a20eb66ecca
4
+ data.tar.gz: 2c90b13de3ae5897644d4291639152ef439a808046f5b7119354939af37735b5
5
5
  SHA512:
6
- metadata.gz: 6c34033fa3c65d19c0fda02c94b0d7f2a5c27fdd7354ddb98aefcba968a4118f3d9911ac1b14282c19071f45924408dcb22b706d961b8f62228f9e987731fe87
7
- data.tar.gz: 19c1496ee81d7d130de16fa7cf6a8c1b7588894d2259f00874570673c41045d024f976bafbc3d308c0d63168349d8a2ed0b0f92254d13bdd4c1cdc55d5eacb05
6
+ metadata.gz: 9c049a3267279fdd1b30f3356e3568615dd0f528d1ce546d32040c7246b49d37c26f625949644038451a21073f3fbcfcd3ea0b2606804938f77ca2f2cadb101e
7
+ data.tar.gz: 96ae41fccbd1bbce862512002e94d5d0db5edf9701d2844154be0babfb4c1eb3986d816d484bd1b9048fca891331cc6da73b8e5bdc646ea56c9074223ff52742
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec_request_helpers (0.1.0)
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.0)
15
- actionview (= 5.2.0)
16
- activesupport (= 5.2.0)
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.0)
22
- activesupport (= 5.2.0)
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.0)
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.0.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.3)
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.0.0)
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.0)
60
- actionpack (= 5.2.0)
61
- activesupport (= 5.2.0)
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.18.1, < 2.0)
64
+ thor (>= 0.19.0, < 2.0)
65
65
  rake (10.5.0)
66
- rspec (3.7.0)
67
- rspec-core (~> 3.7.0)
68
- rspec-expectations (~> 3.7.0)
69
- rspec-mocks (~> 3.7.0)
70
- rspec-core (3.7.1)
71
- rspec-support (~> 3.7.0)
72
- rspec-expectations (3.7.0)
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.7.0)
75
- rspec-mocks (3.7.0)
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.7.0)
78
- rspec-support (3.7.1)
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 `valid_response`.
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
 
@@ -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
- # require "pry"
11
- # Pry.start
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
- let(:path) { "<%= @path %>" }
6
- let(:valid_headers) { {} }
7
- let(:valid_params) { {} }
8
- let(:valid_response) { {} }
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 valid_response
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(valid_response)
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(valid_response)
54
+ expect(response_body).to eq(expected_response)
33
55
  end
34
56
 
35
57
  def self.generate_helpers
@@ -1,3 +1,3 @@
1
1
  module RspecRequestHelpers
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-06-27 00:00:00.000000000 Z
11
+ date: 2018-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport