render_with_view 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/render_with_view/version.rb +1 -1
- data/lib/render_with_view.rb +7 -2
- data/spec/render_with_view_spec.rb +11 -0
- 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: dd04d6b67b1beecdd49900563e12f702af15b8fa
|
4
|
+
data.tar.gz: 94e175806972868258a5a8fc8dcd3a08d2177b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 406d125e96f6caf8b639d00a4747a2d05e24ba89e008d37ed10e238051d320da22ff62cd36983beaee1ed968b6b64dec0d911a0becea67381f320072f8bedce8
|
7
|
+
data.tar.gz: ed81fe1fd2d8431bf4013fdb782acc3c69cf35e05686b2e78bd66cd51226f302e43605a4aa2a5a5439f4a649223bfb7e0f837f5cce9ab6684dfc04a48b397bf3
|
data/README.md
CHANGED
@@ -56,6 +56,17 @@ class ApplicationController
|
|
56
56
|
end
|
57
57
|
```
|
58
58
|
|
59
|
+
## Bonus RSpec matcher
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
require 'render_with_view/rspec_matcher'
|
63
|
+
|
64
|
+
describe ThingController do
|
65
|
+
subject { get :index }
|
66
|
+
it { should set_view_local :key, optional_value }
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
59
70
|
# License
|
60
71
|
|
61
72
|
MIT
|
data/lib/render_with_view.rb
CHANGED
@@ -7,13 +7,18 @@ module RenderWithView
|
|
7
7
|
def self.included kls
|
8
8
|
kls.class_eval do
|
9
9
|
def render_with_view *args
|
10
|
-
|
10
|
+
if !args.first.is_a?(Hash)
|
11
|
+
tmpl = args.shift
|
12
|
+
else
|
13
|
+
tmpl = action_name
|
14
|
+
end
|
11
15
|
locals = args.shift
|
16
|
+
opts = args.shift || {}
|
12
17
|
|
13
18
|
# save to ivar for testing purposes
|
14
19
|
@__view__ = View.new(locals)
|
15
20
|
|
16
|
-
render tmpl, locals: { view: @__view__ }
|
21
|
+
render tmpl, opts.merge(locals: { view: @__view__ })
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -34,6 +34,17 @@ RSpec.describe RenderWithView do
|
|
34
34
|
expect(ivar).to be_a RenderWithView::View
|
35
35
|
expect(ivar.user).to eq user
|
36
36
|
end
|
37
|
+
|
38
|
+
it "includes options" do
|
39
|
+
user = { id: 1 }
|
40
|
+
opts = { flash: {notice: "YAS!"} }
|
41
|
+
ctrl = FakeController.new
|
42
|
+
|
43
|
+
ctrl.render_with_view(:edit, {user: user}, opts)
|
44
|
+
tmpl, opts = ctrl.calls.last
|
45
|
+
expect(tmpl).to eq :edit
|
46
|
+
expect(opts[:flash]).to eq({notice: "YAS!"})
|
47
|
+
end
|
37
48
|
end
|
38
49
|
|
39
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_with_view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Malmberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|