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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 635dffd60e128b0e6d0aff1fa43ca4b796bcab64
4
- data.tar.gz: e5ac59a8114b559f1c55be13040f130cbaa7dc8a
3
+ metadata.gz: dd04d6b67b1beecdd49900563e12f702af15b8fa
4
+ data.tar.gz: 94e175806972868258a5a8fc8dcd3a08d2177b3c
5
5
  SHA512:
6
- metadata.gz: 19d89f2f02b1f757689b94700cdb2fc68dd73b0d8438e9729f0895fc82220ed5d142c4a2c1f2dfcd0459520afac1d218d2ccb6c77f0de994d0e449e3ebe4e17f
7
- data.tar.gz: 667de2408b432bc7b47598d0b458428d297b2c2a50eb151caa732529006fcb5400ba267687a0af443bb0524e5fbd733a30594c88f239285f925c1320bb688fdf
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
@@ -1,3 +1,3 @@
1
1
  module RenderWithView
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -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
- tmpl = args.length == 2 ? args.shift : action_name
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.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-06-07 00:00:00.000000000 Z
11
+ date: 2016-10-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: