rspec-action_view 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -18,7 +18,30 @@ RSpec 2 library to make it simple to spec Rails 3 ActionView extensions
18
18
  with_action_view do |view|
19
19
  view.tab_for('kristian') { 'hello' }.should match /kristian/
20
20
  view.hello('david') { 'hello' }.should match /david/
21
- end
21
+ end
22
+
23
+ with_action_view do |view|
24
+
25
+ view.set :posts => ['post 1', 'post 2'], :title => 'Blog posts index'
26
+ view.instance_variable_get('@posts').should have(2).items
27
+
28
+ res = view.with_template(%{
29
+ <%= @title %>
30
+ <%= tab_for('kristian') { 'hello' } %>
31
+ <%= @posts.join(',') %>
32
+ })
33
+ res.should match /hello/
34
+ res.should match /Blog posts index/
35
+ res.should match /post 1/
36
+
37
+ with_action_view do |view|
38
+ view.with_template do %{
39
+ <%= tab_for('kristian') { 'hello' } %>
40
+ }
41
+ end.should match /hello/
42
+ end
43
+ end
44
+
22
45
  end
23
46
  end
24
47
  </pre>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
@@ -1,4 +1,4 @@
1
- # require 'active_support'
1
+ require 'rspec'
2
2
  require 'action_view'
3
3
  require 'active_support/railtie'
4
4
  require 'action_view/template/handlers/erb'
@@ -13,9 +13,23 @@ class ActionViewTester
13
13
  end
14
14
  end
15
15
 
16
+ def set attributes={}
17
+ attributes.each do |key, value|
18
+ instance_var = "@#{key}"
19
+ instance_variable_set(instance_var, value)
20
+ end
21
+ end
22
+
16
23
  def with_output_buffer(buf = nil)
17
24
  yield
18
25
  end
26
+
27
+ def with_template content=nil, &block
28
+ require 'erb'
29
+ content ||= yield
30
+ template = ERB.new content
31
+ template.result(binding)
32
+ end
19
33
 
20
34
  def self.tests *helpers
21
35
  helpers.flatten.each do |name|
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-action_view}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
@@ -15,6 +15,7 @@ module MyOtherViewHelper
15
15
  end
16
16
 
17
17
 
18
+
18
19
  describe "My ViewHelpers" do
19
20
  it "should render content as expected" do
20
21
  setup_action_view do
@@ -24,6 +25,28 @@ describe "My ViewHelpers" do
24
25
  with_action_view do |view|
25
26
  view.tab_for('kristian') { 'hello' }.should match /kristian/
26
27
  view.hello('david') { 'hello' }.should match /david/
28
+
29
+ with_action_view do |view|
30
+ view.set :posts => ['post 1', 'post 2'], :title => 'Blog posts index'
31
+ view.instance_variable_get('@posts').should have(2).items
32
+
33
+ res = view.with_template do %{
34
+ <%= @title %>
35
+ <%= tab_for('kristian') { 'hello' } %>
36
+ <%= @posts.join(',') %>
37
+ }
38
+ end
39
+ res.should match /hello/
40
+ res.should match /Blog posts index/
41
+ res.should match /post 1/
42
+
43
+ with_action_view do |view|
44
+ view.with_template do %{
45
+ <%= tab_for('kristian') { 'hello' } %>
46
+ }
47
+ end.should match /hello/
48
+ end
49
+ end
27
50
  end
28
51
  end
29
52
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup