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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d2f07dfce5408a70d68482d1c7d5536c0df2ffd
4
- data.tar.gz: 6e84af4c0c09e0397d692d5856df7f41935485ed
3
+ metadata.gz: 91d5e1ddddbbe1eac1b8981125536c00d2e9f889
4
+ data.tar.gz: 8e8dcbf40ed6ca39fc72e1ad159ec2d792907295
5
5
  SHA512:
6
- metadata.gz: fd0777076830ea962436a9cd96e1a76f1a684799dc55c10684dd3224b4b85f1c546cbecec497d10101effcb7f42bced2fcaf86d59f6b9ac642fcbe44d518b729
7
- data.tar.gz: 8bcc7db5f96d6480cb549b222b513d0c35a4e583a9fe64973a840528e6ec2ee1b18ea99082b7f3fd9b73f2a73fafb4d605088f52dc28c43d30e50b67ef8ed87d
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, :helpers_contexts, :modules
7
+ class_attribute :partial, :helpers, :modules
8
8
  self.modules = []
9
- self.helpers_contexts = []
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
- helpers_contexts << block
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
- @view = @_action_view_class.new(ApplicationController.view_paths, @_assigns)
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.helpers_contexts.each do |context|
59
- add_to_context(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 = @view.render(partial: partial_path, locals: options)
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module PartialTestcase
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.8'
4
4
  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.6
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-08-22 00:00:00.000000000 Z
11
+ date: 2017-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails