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 +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +1 -1
- data/lib/viu/html.rb +3 -1
- data/lib/viu/test_case.rb +2 -2
- data/lib/viu/test_helpers.rb +33 -10
- data/lib/viu/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f24b77a5e5a5ada196406705ac4ff02102f7915321f0b22cc946f8a9fc27040
|
4
|
+
data.tar.gz: 2648be1eec444b862d8c7c40f4ccf557011be42784a9ab29b0944f8251d8fff7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb6709c1bf1b41bf7cd451fc20683fcb6e98e7aa4bfe107a21bea21e8a0d0ece7277f6de65e75c385eb545498306bd75a148e497ce5e3799d6d8f875238ed6ce
|
7
|
+
data.tar.gz: 6b75da7d7c59928851d230ed0b1f4dcb527cf3f0d8b3bbef93c6c87d1ecd8f023155d1ab5026b75b64223c45301c6e7b8fbc70c415401ecfb4ab2984401a323f
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/lib/viu/html.rb
CHANGED
data/lib/viu/test_case.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
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 <
|
8
|
+
class TestCase < ActionView::TestCase
|
9
9
|
include Rails::Dom::Testing::Assertions
|
10
10
|
include Viu::TestHelpers
|
11
11
|
end
|
data/lib/viu/test_helpers.rb
CHANGED
@@ -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
|
-
@
|
10
|
-
|
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
|
15
|
-
|
16
|
-
|
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
|
-
|
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
|
-
|
27
|
-
|
48
|
+
def controller_class(klass)
|
49
|
+
self.__controller_class = klass
|
50
|
+
end
|
28
51
|
end
|
29
52
|
end
|
30
53
|
end
|
data/lib/viu/version.rb
CHANGED
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.
|
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-
|
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
|