partial_testcase 0.1.6 → 0.1.8
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 +4 -4
- data/lib/partial_testcase/base.rb +18 -7
- data/lib/partial_testcase/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91d5e1ddddbbe1eac1b8981125536c00d2e9f889
|
4
|
+
data.tar.gz: 8e8dcbf40ed6ca39fc72e1ad159ec2d792907295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20325ee44141e1006ef89e8f7e0d7b85e84fd4d648fb141dc2bcd9e9761a951b0d2b66b1396fb26b62a28f51811a0fdf625d7591ed6facfb8e1313751e30776a
|
7
|
+
data.tar.gz: a328d40c11e4c68eb066a2d93e8876d4ced66c9f011bedba1d6a5fb1ac3b8c72b09e8a2e224199b82a6bda8c073ee86118772a0d5e9b6bffd8e7f7667d2de101
|
@@ -4,9 +4,9 @@ module PartialTestcase
|
|
4
4
|
include Rails::Dom::Testing::Assertions
|
5
5
|
|
6
6
|
attr_reader :html_body
|
7
|
-
class_attribute :partial, :
|
7
|
+
class_attribute :partial, :helpers, :modules
|
8
8
|
self.modules = []
|
9
|
-
self.
|
9
|
+
self.helpers = []
|
10
10
|
|
11
11
|
def before_setup
|
12
12
|
setup_view
|
@@ -18,7 +18,7 @@ module PartialTestcase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.with_helpers(&block)
|
21
|
-
|
21
|
+
helpers << block
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.with_module(mod)
|
@@ -50,15 +50,16 @@ module PartialTestcase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def render_partial(*args, &block)
|
53
|
-
|
53
|
+
view = @_action_view_class.new(ApplicationController.view_paths, @_assigns)
|
54
54
|
|
55
55
|
self.class.modules.each do |mod|
|
56
56
|
@_action_view_class.include(mod)
|
57
57
|
end
|
58
|
-
self.class.
|
59
|
-
add_to_context(
|
58
|
+
self.class.helpers.each do |helper|
|
59
|
+
add_to_context(helper)
|
60
60
|
end
|
61
61
|
add_to_context(block)
|
62
|
+
add_test_context_inheritence(view)
|
62
63
|
|
63
64
|
options = args.extract_options!
|
64
65
|
partial_path = args[0] || self.class.partial
|
@@ -67,7 +68,7 @@ module PartialTestcase
|
|
67
68
|
raise "You must specify the path of the partial you are testing. Call the class method 'partial_path'"
|
68
69
|
end
|
69
70
|
|
70
|
-
@html_body =
|
71
|
+
@html_body = view.render(partial: partial_path, locals: options)
|
71
72
|
end
|
72
73
|
|
73
74
|
def add_to_context(block)
|
@@ -76,5 +77,15 @@ module PartialTestcase
|
|
76
77
|
mod.class_eval(&block)
|
77
78
|
@_action_view_class.include(mod)
|
78
79
|
end
|
80
|
+
|
81
|
+
def add_test_context_inheritence(view)
|
82
|
+
add_to_context(Proc.new {
|
83
|
+
attr_accessor :test_instance
|
84
|
+
def method_missing(method, *args, &block)
|
85
|
+
test_instance.send method, *args, &block
|
86
|
+
end
|
87
|
+
})
|
88
|
+
view.test_instance = self
|
89
|
+
end
|
79
90
|
end
|
80
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partial_testcase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Meichelbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|