spec_views 0.1.1 → 1.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: d044e56e8a631ad9236607bac60068c0f16cf2dedb4b50d0e620cdb791f41d47
4
- data.tar.gz: e105a711a300354b0aa8e5fdb994a54b749e29133da40e07b7f6cc1546565d52
3
+ metadata.gz: 0c7f8a52383504378eddee951cba9a8fc6a47f255da78ed1a130eee0fa814ada
4
+ data.tar.gz: c8fabfb166786ccb35a9ecb3b195851b04c73bea7b6fe3a0a823a3e72b963469
5
5
  SHA512:
6
- metadata.gz: 8c0f148c34253684f1a4ab2a4e4f879ffd89dc3a06fc1a050d3efd2b8462fd245da8060adc181dfa18d31ae6f7239d7a54a9615424fad570a6b2fb1b761ad271
7
- data.tar.gz: aa83215d00e20dec8871b1a718dd2e5061c1c8675ef9a741ebad8108fa34d9ba24e0c5e598f4c62e37e19e54ebd72dab68d0353e7025241843f263c1fae49f51
6
+ metadata.gz: 838f2fc2cb3002b3e8b3d8274ba1f1e14ea0d3fcea5d54a6ff6bdf8e9919ab37f1c3f3b8a90594ff1911bb588230d513d78a444b838452f9115120eaf71d8dc8
7
+ data.tar.gz: f3fb138e0899c4a448fe2b8c3121420b6b86162a6ef3f4b5b9a81fed764e6ca3aad89c311f66381aff4d4b4a5024f87fa5c01010fb92e8621007f80fc2cb1c37
data/README.md CHANGED
@@ -1,18 +1,5 @@
1
1
  # SpecViews
2
- Render views from controller specs for comparision
3
-
4
- ## Usage
5
- Replace selected RSpec `it` methods with `render`:
6
-
7
- ```ruby
8
- RSpec.describe HomeController, type: :controller do
9
- describe 'GET #show' do
10
- render 'homepage' do
11
- get :show
12
- end
13
- end
14
- end
15
- ```
2
+ Render views from controller specs for comparision.
16
3
 
17
4
  ## Installation
18
5
  Add this line to your application's Gemfile:
@@ -21,15 +8,36 @@ Add this line to your application's Gemfile:
21
8
  gem 'spec_views'
22
9
  ```
23
10
 
11
+ And this to RSpec's rails_helper.rb:
12
+ ```ruby
13
+ require 'spec_views/support'
14
+ ```
15
+
24
16
  And then execute:
25
17
  ```bash
26
18
  $ bundle
27
19
  ```
28
20
 
29
- Or install it yourself as:
21
+ Ignore some generated files in your .gitignore:
30
22
  ```bash
31
- $ gem install spec_views
23
+ /spec/fixtures/views/*/challenger.*
24
+ /spec/fixtures/views/*/last_run.txt
32
25
  ```
33
26
 
27
+ ## Usage
28
+ Replace selected RSpec `it` methods with `render`:
29
+
30
+ ```ruby
31
+ RSpec.describe HomeController, type: :controller do
32
+ describe 'GET #show' do
33
+ render 'homepage' do
34
+ get :show
35
+ end
36
+ end
37
+ end
38
+ ```
39
+
40
+ Run this spec to see it failing. Open SpecView UI [http://localhost:3000/spec_views](http://localhost:3000/spec_views) on Rails development server to accept the new view. When rerunning the spec it compares its rendering with the reference view. Use SpecView UI to review, accept or reject changed views.
41
+
34
42
  ## License
35
43
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -96,15 +96,15 @@ module SpecViews
96
96
  end
97
97
 
98
98
  def controller_name
99
- splitted_name.first.gsub(/Controller(_.*)$/, 'Controller').gsub('_', '::')
99
+ splitted_name.first.gsub(/Controller(_.*)$/, 'Controller').gsub(/Controller$/, '').gsub('_', '::')
100
100
  end
101
101
 
102
102
  def method
103
- splitted_name.second
103
+ splitted_name.second[0, 3]
104
104
  end
105
105
 
106
106
  def description
107
- splitted_name.third.humanize
107
+ splitted_name.third.gsub(/__pdf$/, '').humanize
108
108
  end
109
109
 
110
110
  def last_run
@@ -141,6 +141,7 @@
141
141
  margin: 5rem auto 0
142
142
  list-style-type: none
143
143
  padding: 0
144
+ padding-bottom: 2rem
144
145
 
145
146
  > div
146
147
  margin-top: 1rem
@@ -149,6 +150,7 @@
149
150
  display: flex
150
151
  flex: 1 0 auto
151
152
  align-items: stretch
153
+ line-height: 1.5
152
154
 
153
155
  &:hover, &:focus
154
156
  background-color: $dark-bg-light
@@ -1,23 +1,24 @@
1
1
  .iframes
2
- .directories.w-100
3
- - @directories.each do |dir|
4
- - body = capture do
5
- %div
6
- %div= dir.controller_name
7
- %div= dir.method
8
- %div= dir.description
9
- - if dir.challenger?
10
- = link_to({ action: :compare, id: dir }, class: 'challenger') do
11
- %div CHALLENGER
12
- = body
13
- - elsif dir.last_run < @latest_run
14
- = link_to({ action: :preview, id: dir }, class: 'outdated') do
15
- %div OUTDATED
16
- = body
17
- - else
18
- = link_to(action: :preview, id: dir) do
2
+ %div.w-100
3
+ .directories
4
+ - @directories.each do |dir|
5
+ - body = capture do
19
6
  %div
20
- = body
7
+ %div= dir.controller_name
8
+ %div= dir.method
9
+ %div= dir.description
10
+ - if dir.challenger?
11
+ = link_to({ action: :compare, id: dir }, class: 'challenger') do
12
+ %div CHALLENGER
13
+ = body
14
+ - elsif dir.last_run < @latest_run
15
+ = link_to({ action: :preview, id: dir }, class: 'outdated') do
16
+ %div OUTDATED
17
+ = body
18
+ - else
19
+ = link_to(action: :preview, id: dir) do
20
+ %div
21
+ = body
21
22
 
22
23
  .footer
23
24
  .info
@@ -3,15 +3,5 @@ require 'spec_views/configuration'
3
3
  module SpecViews
4
4
  class Engine < ::Rails::Engine
5
5
  config.spec_views = Configuration.default
6
-
7
- initializer 'configure.rspec' do |app|
8
- if Rails.env.test? && Object.const_defined?('RSpec')
9
- require 'spec_views/support'
10
-
11
- RSpec.configure do |config|
12
- config.include Support
13
- end
14
- end
15
- end
16
6
  end
17
7
  end
@@ -104,7 +104,7 @@ module SpecViews
104
104
  end
105
105
 
106
106
  def sanitized_body
107
- return body if pdf?
107
+ return remove_headers_from_pdf(body) if pdf?
108
108
 
109
109
  remove_pack_digests_from_body(
110
110
  remove_digests_from_body(body),
@@ -112,13 +112,21 @@ module SpecViews
112
112
  end
113
113
 
114
114
  def remove_digests_from_body(body)
115
- body.gsub(/(-[a-z0-9]{64})(\.css|\.js|\.png|\.jpg|\.jpeg|\.svg|\.gif)/, '\2')
115
+ body.gsub(/(-[a-z0-9]{64})(\.css|\.js|\.ico|\.png|\.jpg|\.jpeg|\.svg|\.gif)/, '\2')
116
116
  end
117
117
 
118
118
  def remove_pack_digests_from_body(body)
119
119
  body.gsub(%r{(packs.*/js/[a-z0-9_]+)(-[a-z0-9]{20})(\.js)}, '\1\3')
120
120
  end
121
121
 
122
+ def remove_headers_from_pdf(pdf)
123
+ pdf
124
+ .force_encoding("BINARY")
125
+ .gsub(/^\/CreationDate \(.*\)$/, '')
126
+ .gsub(/^\/ModDate \(.*\)$/, '')
127
+ .gsub(/^\/ID \[<.+><.+>\]$/, '')
128
+ end
129
+
122
130
  def put_write_instructions
123
131
  puts
124
132
  puts "\e[33mWarning:\e[0m Writing view fixture to #{champion_path.to_s.gsub(Rails.root.to_s, '')}"
@@ -179,4 +187,8 @@ module SpecViews
179
187
  end
180
188
  end
181
189
  end
182
- end
190
+ end
191
+
192
+ RSpec.configure do |rspec|
193
+ rspec.include SpecViews::Support, type: :controller
194
+ end
@@ -1,3 +1,3 @@
1
1
  module SpecViews
2
- VERSION = '0.1.1'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spec_views
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Gaul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: timecop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.0'
55
69
  description: Render views from controller specs for comparision
56
70
  email:
57
71
  - sebastian.gaul@lichtbit.com