viu 0.0.1 → 0.0.2

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: 7fcf443dc32a50462eb147063436581b225a066e1368a51132eb485379bd4891
4
- data.tar.gz: 18ba17c3be19f4562447374e2b65c2dba7bba3acf3acb6d91c1f6412a3a4b5bc
3
+ metadata.gz: 2f24b77a5e5a5ada196406705ac4ff02102f7915321f0b22cc946f8a9fc27040
4
+ data.tar.gz: 2648be1eec444b862d8c7c40f4ccf557011be42784a9ab29b0944f8251d8fff7
5
5
  SHA512:
6
- metadata.gz: 7e4f28c552311fa43527a3cc0c59e18f22f172848f0c28b7eb05fe0dea8fa3bd8c3ab943f14018bfae347877632071b71c12a916645ec222ae22b74ac096ee78
7
- data.tar.gz: 0b00071e7a91eb93f75c933f6ed0c5e56178afae13ad66027911a20bf582b715c59d061b98b639ce83c730242ebd5ea37ac2dd4c4fc2d37b44726ab1a62e8a67
6
+ metadata.gz: fb6709c1bf1b41bf7cd451fc20683fcb6e98e7aa4bfe107a21bea21e8a0d0ece7277f6de65e75c385eb545498306bd75a148e497ce5e3799d6d8f875238ed6ce
7
+ data.tar.gz: 6b75da7d7c59928851d230ed0b1f4dcb527cf3f0d8b3bbef93c6c87d1ecd8f023155d1ab5026b75b64223c45301c6e7b8fbc70c415401ecfb4ab2984401a323f
@@ -0,0 +1,13 @@
1
+ ## 0.0.2 2020-08-16
2
+
3
+ ### Added
4
+
5
+ - Improve test helpers
6
+
7
+ ### Fixed
8
+
9
+ - Viu::Html#controller should be public
10
+
11
+ ## 0.0.1 2020-08-10
12
+
13
+ First public release
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- viu (0.0.1)
4
+ viu (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -21,9 +21,11 @@ module Viu
21
21
  end
22
22
  end
23
23
 
24
+ attr_reader :controller
25
+
24
26
  private
25
27
 
26
- attr_reader :controller, :request
28
+ attr_reader :request
27
29
 
28
30
  delegate :protect_against_forgery?, :form_authenticity_token, :content_security_policy?, to: :helpers
29
31
 
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/test_case"
3
+ require "action_view/test_case"
4
4
  require "rails/dom/testing/assertions"
5
5
  require "viu/test_helpers"
6
6
 
7
7
  module Viu
8
- class TestCase < ActiveSupport::TestCase
8
+ class TestCase < ActionView::TestCase
9
9
  include Rails::Dom::Testing::Assertions
10
10
  include Viu::TestHelpers
11
11
  end
@@ -1,19 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/concern'
4
+ require 'active_support/inflector'
5
+ require 'active_support/core_ext/class/attribute'
6
+
3
7
  module Viu
4
8
  module TestHelpers
9
+ extend ActiveSupport::Concern
10
+
11
+ private
5
12
 
6
- attr_reader :rendered_view
13
+ attr_reader :view_instance, :raw_rendered_view, :rendered_view
7
14
 
8
15
  def render_view(view, **args)
9
- @rendered_view = Nokogiri::HTML::Document.parse(
10
- view.render_in(controller.view_context, args)
11
- )
16
+ @rendered ||= []
17
+ @view_instance = view
18
+ @raw_rendered_view = @view_instance.render_in(__controller.view_context, **args)
19
+ @rendered << @raw_rendered_view
20
+ @rendered_view = Nokogiri::HTML::Document.parse(@raw_rendered_view)
12
21
  end
13
22
 
14
- def controller
15
- # TODO: make ApplicationController usage here configurable
16
- @controller ||= ApplicationController.new.tap { |c| c.request = request }
23
+ def __controller
24
+ @__controller ||= __constantize(self.class.__controller_class).new.tap do |c|
25
+ c.request = request
26
+ c.action_name = 'show'
27
+ end
17
28
  .extend(Rails.application.routes.url_helpers)
18
29
  end
19
30
 
@@ -21,10 +32,22 @@ module Viu
21
32
  @request ||= ActionDispatch::TestRequest.create
22
33
  end
23
34
 
24
- private
35
+ def __constantize(value)
36
+ return value if value.is_a?(Class)
37
+
38
+ ActiveSupport::Inflector.constantize(value)
39
+ end
40
+
41
+ included do
42
+ class_attribute :__controller_class, instance_accessor: false, instance_predicate: false,
43
+ default: 'ApplicationController'
44
+ end
45
+
46
+ class_methods do
25
47
 
26
- def document_root_element
27
- @rendered_view.root
48
+ def controller_class(klass)
49
+ self.__controller_class = klass
50
+ end
28
51
  end
29
52
  end
30
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Viu
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralf Schmitz Bongiolo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-10 00:00:00.000000000 Z
11
+ date: 2020-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
105
  - ".travis.yml"
106
+ - CHANGELOG.md
106
107
  - CODE_OF_CONDUCT.md
107
108
  - Gemfile
108
109
  - Gemfile.lock