stimulus_reflex_testing 0.1.0 → 0.2.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: 78135e70cab771486197a65392f65fbc585450aaf8bd58095c2777ced12834ca
4
- data.tar.gz: f12fe3d40d1be2f3b90368d3ca2350f41b5b41543550cdccfcb668810975143f
3
+ metadata.gz: aded655e92f21ce9ec1f85cb2311f74b6fd02e06d41344ce9db9fb9fca537c87
4
+ data.tar.gz: 1bc016eda544a5cd803ddca20b117f51bc9dbf6b7985a950a1818be30483e1e4
5
5
  SHA512:
6
- metadata.gz: 1d1d25e8419746630001c914421c2e8428f1ef3752af48ef4d02fa3aa3971acb74ec055f3e0fa0ee3a2826d096495474390cdff3bcd1511c18c204f23a40d02e
7
- data.tar.gz: 04e79184baa0b5bc3c0f643b3d314143c77161bb0d42cdb54c67f965542e7535fe25831db30743bb767928c47829e4dc19c53c3243f7b59db0503df3e8510747
6
+ metadata.gz: b859e93f0477236c2f91bb7628803dd9691f980fbc3db9ccfd2f4a4f5d4589d3e0a64422c38f9fbcc9179163ed25421af15eec609659d89045a06ce738273bf8
7
+ data.tar.gz: 5b213edaa6a0ca6274535ee2f756e59a17225fd509428c4e32b046c277a57b4a09d9bc4f5c5f4940bd8e8d92eb70c87b1ed82adc78cb351ebf528469c027e438
data/README.md CHANGED
@@ -18,7 +18,7 @@ Things we'd like to add/improve on:
18
18
  Add this line to your application's Gemfile:
19
19
 
20
20
  ```ruby
21
- gem 'stimulus_reflex_testing'
21
+ gem 'stimulus_reflex_testing', require: false
22
22
  ```
23
23
 
24
24
  ### Using 5.2 or below? Or using a version of RSpec Rails lower than 4?
@@ -26,7 +26,7 @@ gem 'stimulus_reflex_testing'
26
26
  Both Rails 6 and RSpec Rails 4 introduce the `action-cable-testing` library. If you're using Rails 5.2 and a version of RSpec Rails lower than 4, include the `action-cable-testing` gem in your Gemfile.
27
27
 
28
28
  ```ruby
29
- gem 'stimulus_reflex_testing'
29
+ gem 'stimulus_reflex_testing', require: false
30
30
  gem 'action-cable-testing'
31
31
  ```
32
32
 
@@ -110,6 +110,8 @@ class PostReflex < ApplicationReflex
110
110
  end
111
111
 
112
112
  # spec/reflexes/post_reflex_spec.rb
113
+ require 'rails_helper'
114
+
113
115
  RSpec.describe PostReflex, type: :reflex do
114
116
  let(:post) { create(:post) }
115
117
  let(:reflex) { build_reflex(url: edit_post_url(post)) }
@@ -3,12 +3,20 @@ require "active_support/test_case"
3
3
 
4
4
  class StimulusReflex::TestCase < ActiveSupport::TestCase
5
5
  class TestChannel < ActionCable::Channel::TestCase
6
- _channel_class = StimulusReflex::Channel
6
+ delegate :env, to: :connection
7
7
 
8
8
  def initialize(connection_opts = {})
9
9
  super("StimulusReflex::Channel")
10
10
  @connection = stub_connection(connection_opts.merge(env: {}))
11
11
  end
12
+
13
+ def stream_name
14
+ ids = connection.identifiers.map { |identifier| connection.send(identifier).try(:id) || connection.send(identifier) }
15
+ [
16
+ "StimulusReflex::Channel",
17
+ ids.select(&:present?).join(";")
18
+ ].select(&:present?).join(":")
19
+ end
12
20
  end
13
21
 
14
22
  module Behavior
@@ -24,7 +32,7 @@ class StimulusReflex::TestCase < ActiveSupport::TestCase
24
32
  element = opts.fetch(:element, StimulusReflex::Element.new)
25
33
 
26
34
  self.class.reflex_class.new(
27
- channel, element: element, url: opts.dig(:url), params: opts.fetch(:params, {})
35
+ channel, element: element, url: opts.dig(:url), method_name: opts.dig(:method_name), params: opts.fetch(:params, {})
28
36
  )
29
37
  end
30
38
  end
@@ -6,6 +6,24 @@ module StimulusReflex::TestReflexPatches
6
6
  def run(method_name, *args)
7
7
  process(method_name, *args)
8
8
  end
9
+
10
+ def cable_ready
11
+ @cable_ready ||= FableReady.new
12
+ end
13
+
14
+ class FableReady
15
+ def [](key)
16
+ self
17
+ end
18
+
19
+ def method_missing(*)
20
+ true || super
21
+ end
22
+
23
+ def respond_to_missing?(*)
24
+ true
25
+ end
26
+ end
9
27
  end
10
28
 
11
29
  StimulusReflex::Reflex.include(StimulusReflex::TestReflexPatches)
@@ -1,3 +1,3 @@
1
1
  module StimulusReflexTesting
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -3,14 +3,17 @@ require_relative "lib/stimulus_reflex_testing/version"
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "stimulus_reflex_testing"
5
5
  spec.version = StimulusReflexTesting::VERSION
6
- spec.authors = ["Jason Charnes", "Jamie Lawrence", "Basil Khan"]
7
- spec.email = ["jason@thecharnes.com", "jamie@ideasasylum.com", "basil@podia.com"]
6
+ spec.authors = ["Jason Charnes"]
7
+ spec.email = ["jason@thecharnes.com"]
8
8
 
9
- spec.summary = "An environment and set of helpers for testing StimulusReflex."
9
+ spec.summary = "Write a short summary, because RubyGems requires one."
10
+ spec.description = "Write a longer description or delete this line."
10
11
  spec.homepage = "https://github.com/podia/stimulus_reflex_testing"
11
12
  spec.license = "MIT"
12
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
14
 
15
+ # spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
16
+
14
17
  spec.metadata["homepage_uri"] = spec.homepage
15
18
  spec.metadata["source_code_uri"] = spec.homepage
16
19
  # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
@@ -23,4 +26,6 @@ Gem::Specification.new do |spec|
23
26
  spec.bindir = "exe"
24
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
28
  spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "stimulus_reflex"
26
31
  end
metadata CHANGED
@@ -1,22 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus_reflex_testing
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
  - Jason Charnes
8
- - Jamie Lawrence
9
- - Basil Khan
10
- autorequire:
8
+ autorequire:
11
9
  bindir: exe
12
10
  cert_chain: []
13
- date: 2020-06-11 00:00:00.000000000 Z
14
- dependencies: []
15
- description:
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: stimulus_reflex
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Write a longer description or delete this line.
16
28
  email:
17
29
  - jason@thecharnes.com
18
- - jamie@ideasasylum.com
19
- - basil@podia.com
20
30
  executables: []
21
31
  extensions: []
22
32
  extra_rdoc_files: []
@@ -46,7 +56,7 @@ licenses:
46
56
  metadata:
47
57
  homepage_uri: https://github.com/podia/stimulus_reflex_testing
48
58
  source_code_uri: https://github.com/podia/stimulus_reflex_testing
49
- post_install_message:
59
+ post_install_message:
50
60
  rdoc_options: []
51
61
  require_paths:
52
62
  - lib
@@ -62,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
72
  version: '0'
63
73
  requirements: []
64
74
  rubygems_version: 3.0.3
65
- signing_key:
75
+ signing_key:
66
76
  specification_version: 4
67
- summary: An environment and set of helpers for testing StimulusReflex.
77
+ summary: Write a short summary, because RubyGems requires one.
68
78
  test_files: []