routes2spec 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: 79e4e2150811b3cc919d8db511042cc8a733e141f3c1d4e04891accbf364f922
4
- data.tar.gz: '07904d17f0923955560f427586158be17578697bbf75e45eac0dae7728ccec63'
3
+ metadata.gz: 197213dfc7438c267e64f2ad938f57d7e9a48454781e6aabeae8eebba7e6f79c
4
+ data.tar.gz: a963d77704bb92c2177ddd05b1d7fd2053b13df1c54a866597db16a300d72acd
5
5
  SHA512:
6
- metadata.gz: fe56ba68c66c4115fab4940447ac7641e439656f2ba7bd7819ba9f14324ef610a2be1df81efab02913bfe17854587718bc3557f4f47c0f081c5cf1a4f20864ac
7
- data.tar.gz: c4887452c2fdc0c26216ff590be8b4fa8c24eb5844fb03ae10000ef67fec8807882918147286cbd8998516bf0f1500da45e862bdc4510fa3018696e4cef379d0
6
+ metadata.gz: decf81e5b7aa98f01e6d48b7590f1e6bb6773c7e61f9f65071e303b12ead8f098ab179d627b82fe8c8512a765db0e931ab7366b2eede8675484f77a4666af5c7
7
+ data.tar.gz: cdff45fff6fc5f45cf8e13336e123a0b566fb239b88577afa4991a7a96f6b7e6b1075da88e79373de687ac67e44029d9f9705dc9582568ca7864aad14285776e
@@ -17,6 +17,7 @@ module Routes2spec
17
17
  desc: "Filter by a specific controller, e.g. PostsController or Admin::PostsController."
18
18
  class_option :grep, aliases: "-g", desc: "Grep routes by a specific pattern."
19
19
  class_option :symbol_status, banner: "", desc: "Use symbols for http status."
20
+ class_option :literal_path, banner: "", desc: "Use literal paths instead of path helper."
20
21
  class_option :overwrite, banner: "", desc: "Prompts for confirmation to overwrite each file if it already exists."
21
22
  class_option :force_overwrite, banner: "", desc: "Forcibly overwrites existing files without confirmation."
22
23
  class_option :pending, banner: "", desc: "Mark examples as pending."
@@ -115,7 +116,7 @@ module Routes2spec
115
116
  end
116
117
 
117
118
  def formatter_opts
118
- options.symbolize_keys.slice(:symbol_status, :pending, :verb)
119
+ options.symbolize_keys.slice(:symbol_status, :literal_path, :pending, :verb)
119
120
  end
120
121
  end
121
122
  end
@@ -76,14 +76,19 @@ module Routes2spec
76
76
  Routes2spec.log_debug "endpoint: #{endpoint}, constraints: #{constraints}"
77
77
  # TODO: insert constraints to routing spec
78
78
  status = @opts[:symbol_status] ? SYMBOL_STATUS[verb.to_sym] : STATUS[verb.to_sym]
79
+ use_literal_path = @opts[:literal_path] || false
80
+ path_helper_str = "#{path_name}_path#{params_str.empty? ? "" : "(#{params_str})"}"
81
+ literal_path_str = "\"#{path}\""
82
+ path_str = use_literal_path ? literal_path_str : path_helper_str
79
83
  r.merge(
80
84
  path: path,
85
+ path_str: path_str,
81
86
  path_name: path_name,
82
87
  params_str: params_str,
83
88
  reqs: r[:reqs],
84
89
  endpoint: endpoint,
85
90
  constraints: constraints || "",
86
- status: status
91
+ status: status,
87
92
  )
88
93
  end.compact
89
94
  if routes.empty?
@@ -4,7 +4,7 @@ RSpec.describe "<%= controller_name %>", type: :request do
4
4
  <% routes.each do |route| %>
5
5
  describe "<%= route[:verb].upcase %> <%= route[:path] %>" do
6
6
  it "works!" do
7
- <%= pending ? 'pending "now write some real specs. and remove pending mark."' + "\n " : "" %><%= route[:verb].downcase %> <%= route[:path_name] %>_path<%= route[:params_str].empty? ? "" : "(#{route[:params_str]})" %>
7
+ <%= pending ? 'pending "now write some real specs. and remove pending mark."' + "\n " : "" %><%= route[:verb].downcase %> <%= route[:path_str] %>
8
8
  expect(response).to have_http_status(<%= route[:status] %>)
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Routes2spec
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routes2spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shuuuuuny
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-01 00:00:00.000000000 Z
11
+ date: 2024-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails