snapshot_ui 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db2e79495a612dd8f9e73f84537b5237c214faf5290915f40a451b27c517fb10
4
- data.tar.gz: 5f68e150a5439073be54508096b9a085277d1cfe03292a78e396c6f790c17a0d
3
+ metadata.gz: 63bfd50e7e9795cf6ea6ef899d84d07aa333fbfe309e79f3476e2686fceae58f
4
+ data.tar.gz: d524af4e1ef098840a7119685d8a60c27301cb5b6bf91064b0350011535e3d58
5
5
  SHA512:
6
- metadata.gz: e20faf53a0f05035d90e76e10d08a7a067728899df4bc6e5dc9c3dda944c7414579b334650c4b9a8edfc1ad2889bb7b65537d22120cb9cbc2a92b4b0378d2598
7
- data.tar.gz: c6fa887d47cfec6bf20f91146e37f0165655601b4d3a38bb43e74b735dcde65da4453a672d147cb305f0cc67dc4d5338ece722b7224f428527917e8f49b30370
6
+ metadata.gz: b5756f817fb9f6c7f73f0dcf61aa9436698826fc1ef6a0722cd9a53eb2ea201cb4aa30615a33a443170fc16874f83d52ee8dfd40017d9f59a258ff9c64af0cc9
7
+ data.tar.gz: 8cad2af17162a97a97bf84837b39063eef97d57ec2835675498d98507f425d07a01956645fb86b6f92592493ed08c76a2ac84eb476d9a79bb73c7fd0b3133137
data/README.md CHANGED
@@ -1,16 +1,8 @@
1
- # SnapshotUI
1
+ # Snapshot UI
2
2
 
3
- ## Things to do next
3
+ Take snapshots of responses in integration tests, and display them in a browser.
4
4
 
5
- - Live reloads after a test run and new snapshots become published
6
- - Accept not only "response" objects but also just plain strings for testing UI helpers (think buttons, etc.)
7
- - Make it easier to navigate between a list of snapshots and the code
8
- - Ability to disable or enable javascript of the rendered snapshots
9
-
10
- ## Things to do in the far future
11
-
12
- - Different representations of snapshot lists
13
- - Spatially display snapshots and how they connect to each other to demonstrate UI flows
14
- - Extract more information out of response snapshots - path, page title, how they connect to other snapshots
15
- - Possibility to add notes to snapshots from within tests (`take_snapshot response, note: "...")
5
+ Works with any kind of Rack application and minitest testing framework.
16
6
 
7
+ > ℹ️ The Snapshot UI is the next generation of a similar library, [Snapshot Inspector](https://github.com/tomazzlender/snapshot_inspector).
8
+ > It works with any kind of Rack application, not just Rails applications. Future development will take place here, and Snapshot Inspector will be eventually archived.
@@ -0,0 +1,28 @@
1
+ require "snapshot_ui"
2
+ require "minitest"
3
+
4
+ module Minitest
5
+ class << self
6
+ def plugin_snapshot_ui_options(opts, _options)
7
+ opts.on "--take-snapshots", "Take UI snapshots" do
8
+ ENV["TAKE_SNAPSHOTS"] = "true"
9
+ end
10
+ end
11
+
12
+ def plugin_snapshot_ui_init(_options)
13
+ return unless SnapshotUI.snapshot_taking_enabled?
14
+
15
+ reporter << SnapshotUIReporter.new
16
+
17
+ SnapshotUI.clear_snapshots_in_progress
18
+ end
19
+ end
20
+
21
+ class SnapshotUIReporter < Reporter
22
+ def report
23
+ SnapshotUI.publish_snapshots_in_progress
24
+
25
+ io.print "\n\nUI snapshots are ready for review at #{SnapshotUI.configuration.web_url}"
26
+ end
27
+ end
28
+ end
@@ -3,10 +3,12 @@
3
3
  module SnapshotUI
4
4
  class Configuration
5
5
  attr_writer :storage_directory, :project_root_directory
6
+ attr_accessor :web_url
6
7
 
7
- def initialize(project_root_directory:, storage_directory:)
8
+ def initialize(project_root_directory:, storage_directory:, web_url:)
8
9
  @project_root_directory = project_root_directory
9
10
  @storage_directory = storage_directory
11
+ @web_url = web_url
10
12
  end
11
13
 
12
14
  def storage_directory
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SnapshotUI
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/snapshot_ui.rb CHANGED
@@ -6,7 +6,8 @@ require_relative "snapshot_ui/configuration"
6
6
  module SnapshotUI
7
7
  DEFAULT_CONFIGURATION = {
8
8
  project_root_directory: ".",
9
- storage_directory: "tmp/snapshot_ui"
9
+ storage_directory: "tmp/snapshot_ui",
10
+ web_url: "http://localhost:3000/ui/snapshots"
10
11
  }.freeze
11
12
 
12
13
  def self.configure
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshot_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomaz Zlender
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-19 00:00:00.000000000 Z
11
+ date: 2024-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -92,6 +92,7 @@ files:
92
92
  - LICENSE.txt
93
93
  - README.md
94
94
  - bin/snapshot_ui
95
+ - lib/minitest/snapshot_ui_plugin.rb
95
96
  - lib/snapshot_ui.rb
96
97
  - lib/snapshot_ui/cli.rb
97
98
  - lib/snapshot_ui/cli/watcher.ru