nice_partials 0.1.6 → 0.9.0
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/CHANGELOG.md +213 -1
- data/Gemfile +10 -0
- data/README.md +208 -77
- data/Rakefile +2 -9
- data/lib/nice_partials/helper.rb +5 -18
- data/lib/nice_partials/monkey_patch.rb +106 -44
- data/lib/nice_partials/partial/content.rb +54 -0
- data/lib/nice_partials/partial/section.rb +48 -0
- data/lib/nice_partials/partial/stack.rb +19 -0
- data/lib/nice_partials/partial.rb +91 -19
- data/lib/nice_partials/version.rb +1 -1
- data/lib/nice_partials.rb +8 -10
- data/nice_partials.gemspec +10 -3
- metadata +22 -17
- data/.gitignore +0 -3
- data/.travis.yml +0 -18
- data/test/fixtures/_basic.html.erb +0 -2
- data/test/fixtures/_card.html.erb +0 -13
- data/test/fixtures/card_test.html.erb +0 -9
- data/test/renderer_test.rb +0 -57
- data/test/test_helper.rb +0 -7
data/test/renderer_test.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require_relative "./test_helper"
|
2
|
-
|
3
|
-
class RendererTest < ActiveSupport::TestCase
|
4
|
-
# from actionview/render_test
|
5
|
-
class TestController < ActionController::Base
|
6
|
-
end
|
7
|
-
|
8
|
-
def setup_view(paths)
|
9
|
-
ActionView::Base.include(NicePartials::Helper)
|
10
|
-
|
11
|
-
@assigns = { secret: "in the sauce" }
|
12
|
-
|
13
|
-
@view = Class.new(ActionView::Base.with_empty_template_cache) do
|
14
|
-
def view_cache_dependencies; []; end
|
15
|
-
|
16
|
-
def combined_fragment_cache_key(key)
|
17
|
-
[:views, key]
|
18
|
-
end
|
19
|
-
end.with_view_paths(paths, @assigns)
|
20
|
-
|
21
|
-
controller = TestController.new
|
22
|
-
controller.perform_caching = true
|
23
|
-
controller.cache_store = :memory_store
|
24
|
-
@view.controller = controller
|
25
|
-
|
26
|
-
@controller_view = controller.view_context_class.with_empty_template_cache.new(
|
27
|
-
controller.lookup_context,
|
28
|
-
controller.view_assigns,
|
29
|
-
controller)
|
30
|
-
end
|
31
|
-
|
32
|
-
def setup
|
33
|
-
ActionView::LookupContext::DetailsKey.clear
|
34
|
-
path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH)
|
35
|
-
view_paths = ActionView::PathSet.new([path])
|
36
|
-
assert_equal ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH), view_paths.first
|
37
|
-
setup_view(view_paths)
|
38
|
-
end
|
39
|
-
|
40
|
-
def teardown
|
41
|
-
ActionController::Base.view_paths.map(&:clear_cache)
|
42
|
-
end
|
43
|
-
|
44
|
-
test "render basic nice partial" do
|
45
|
-
rendered = @view.render("basic") { |p| p.content_for :message, "hello from nice partials" }.squish
|
46
|
-
|
47
|
-
assert_equal "hello from nice partials", rendered
|
48
|
-
end
|
49
|
-
|
50
|
-
test "render nice partial in card template" do
|
51
|
-
rendered = @view.render(template: "card_test").squish
|
52
|
-
|
53
|
-
assert_match "Some Title", rendered
|
54
|
-
assert_match "Lorem Ipsum", rendered
|
55
|
-
assert_match "https://example.com/image.jpg", rendered
|
56
|
-
end
|
57
|
-
end
|