showcase-rails 0.2.0 → 0.2.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: 38aa85b8e5c0a98ee2dbb45f0a184981de8a86371efbb2237e2a06f0d2f56eef
4
- data.tar.gz: b4e44e25c0b76afcd33a2dc155cae5bdebe1a5a9ca3cd670d4cc2bae94d7f38b
3
+ metadata.gz: a546309faa4499b63781df854aa283c3d3a382f91f0c9be8e00a37a5dcbd0b04
4
+ data.tar.gz: 1a7b269de49a2015c7ad9bc037de1e68aed4b33217771322f8345e859bdc5bc0
5
5
  SHA512:
6
- metadata.gz: 995f0b2b6f765c93936adb968c501218fccc592befe12df06e0aa19b9b092a0ea385cab086763f0b855e3e86eb784edf8365143b49e69dbda934bd8ce608016d
7
- data.tar.gz: 123c59c68801489dec09d40c144c64fbc09dc6c65925833cbeade7a4c8f479595b6d59274d3ab7e74cdd18495dd8276ef60fa714b3f87662c786d6c190d55c39
6
+ metadata.gz: 2779fe6f14b9a07db6a161dc4915a90aa2c1419f19dede0822d8009730b06a3b3006ec0eabcf8d008000d48a4997bdd4342b49dd59b35d4dfb205b520493ffcd
7
+ data.tar.gz: f1bd8f9effd8ee3af53ab9bddf3456c3bff072e4cfb75d4e6b110a0925f35d996b2dce12f6adeb9e236ae5d5aa8f93eb3c93900b2d53f17c0930b44117b5e043
data/README.md CHANGED
@@ -31,9 +31,9 @@ Which will then render the following:
31
31
 
32
32
  ## Automatic smokescreen testing
33
33
 
34
- Run `bin/rails showcase:install:integration_test` to automatic testing installed in `test/integration/showcase_test.rb`.
34
+ Showcase automatically runs integration tests for all your Showcases by rendering them and asserting they respond with `200 OK`. As long as `gem "showcase-rails"` is in the `:test` group you're set.
35
35
 
36
- This will render every Showcase you've defined and assert they respond with `200 OK`. You can add custom assertions by overriding `assert_showcase_preview`.
36
+ If you want to tweak this, run `bin/rails showcase:install:integration_test` and open `test/integration/showcase_test.rb`. You can then add your own `setup` and `teardown` hooks, as well as override the provided `assert_showcase_preview` to add custom assertions.
37
37
 
38
38
  ## View examples
39
39
 
@@ -86,16 +86,9 @@ partials, make sure to include `"showcase"` in your list of assets.
86
86
 
87
87
  ## Installation
88
88
 
89
- Add this line to your application's Gemfile. If you're utilizing the
90
- [Showcase::IntegrationTest](lib/showcase/integration_test.rb) class, make sure
91
- that the `showcase-rails` gems is available to your test environment:
92
-
89
+ Add this line to your application's Gemfile. To get the automatic integration testing make sure the `showcase-rails` gem is available to your test environment:
93
90
 
94
91
  ```ruby
95
- # nested in the default group
96
- gem "showcase-rails"
97
-
98
- # or nested in the :development and :test groups
99
92
  group :development, :test do
100
93
  gem "showcase-rails"
101
94
  end
@@ -108,7 +101,7 @@ $ bundle
108
101
 
109
102
  Or install it yourself as:
110
103
  ```bash
111
- $ gem install showcase
104
+ $ gem install showcase-rails
112
105
  ```
113
106
 
114
107
  ## Contributing
@@ -41,8 +41,13 @@ class Showcase::Path
41
41
 
42
42
  private
43
43
 
44
- def find(id) = children.find { _1.id == id }
45
- def insert(id) = self.class.new(id).tap { self << _1 }
44
+ def find(id)
45
+ children.find { _1.id == id }
46
+ end
47
+
48
+ def insert(id)
49
+ self.class.new(id).tap { self << _1 }
50
+ end
46
51
  end
47
52
 
48
53
  def self.tree
@@ -2,8 +2,12 @@ module Showcase
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace Showcase
4
4
 
5
- initializer "showcase.assets" do |app|
6
- app.config.assets.precompile += %w[showcase_manifest]
5
+ initializer "showcase.assets" do
6
+ config.assets.precompile += %w[showcase_manifest]
7
+ end
8
+
9
+ initializer "showcase.integration_test.autorun" do
10
+ Showcase::IntegrationTest.autorun if Rails.env.test?
7
11
  end
8
12
  end
9
13
  end
@@ -1,10 +1,17 @@
1
1
  class Showcase::IntegrationTest < ActionDispatch::IntegrationTest
2
2
  def self.inherited(test_class)
3
3
  super
4
+ test_class.prepare
5
+ end
6
+
7
+ def self.autorun
8
+ at_exit { prepare unless subclasses.any? }
9
+ end
4
10
 
11
+ def self.prepare
5
12
  tree = Showcase::Path.tree
6
13
  tree.flat_map(&:ordered_paths).each do |path|
7
- test_class.test "Showcase: GET showcase/previews/#{path.id} renders successfully" do
14
+ test "Showcase: GET showcase/previews/#{path.id} renders successfully" do
8
15
  get showcase.preview_path(path.id)
9
16
 
10
17
  assert_response :ok
@@ -12,7 +19,7 @@ class Showcase::IntegrationTest < ActionDispatch::IntegrationTest
12
19
  end
13
20
  end
14
21
 
15
- test_class.test "Showcase: isn't empty" do
22
+ test "Showcase: isn't empty" do
16
23
  assert_not_empty tree, "Showcase couldn't find any samples to generate tests for"
17
24
  end
18
25
  end
@@ -1,3 +1,3 @@
1
1
  module Showcase
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/showcase.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "zeitwerk"
2
- loader = Zeitwerk::Loader.for_gem
3
- loader.ignore("#{__dir__}/showcase-rails.rb")
4
- loader.setup
1
+ require_relative "showcase/version"
5
2
 
6
3
  module Showcase
4
+ autoload :IntegrationTest, "showcase/integration_test"
5
+ autoload :RouteHelper, "showcase/route_helper"
6
+
7
7
  singleton_class.attr_accessor :sample_renderer
8
8
  @sample_renderer = ->(lines) { tag.pre lines.join.strip_heredoc }
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: showcase-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pence
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-02-06 00:00:00.000000000 Z
12
+ date: 2023-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails