spec/cream/view/role_area_spec.rb in cream-0.5.7 vs spec/cream/view/role_area_spec.rb in cream-0.5.8

- old
+ new

@@ -6,10 +6,11 @@ require 'cream/view/role_area' require 'cream/view/host_area' describe Cream::View::Role do extend_view_with Cream::View, :role, :host + extend_view_with Cream::Helper, :role describe '#area' do it "should display the div with hello" do with_engine do |e, view| @@ -79,46 +80,53 @@ end end # desc describe '#area_not_for_roles' do it "should not display an area for user :admin" do - with_action_view do |view| + with_engine do |e, view| view.stubs(:has_role?).with([:admin]).returns true - view.area_not_for_roles(:admin) { 'hello' }.should be_nil + res = e.run_template do + %{<%= area_not_for_roles(:admin) { 'hello' } %>} + end + res.should be_empty end end it "should display an area for user not :admin" do - with_action_view do |view| + with_engine do |e, view| # he is not admin view.stubs(:has_role?).with([:admin]).returns false - view.area_not_for_roles(:admin) { 'hello' }.should match /hello/ + + res = e.run_template do + %{<%= area_not_for_roles(:admin) { 'hello' } %>} + end + res.should match /hello/ end end end # desc - context 'method auto-generated when Rails initialize based on registered roles' - describe '#guest_area' do - it "should display an Admin area for :admin" do - with_engine do |e, view| - view.stubs(:has_role?).with([:admin]).returns true - - res = e.run_template do - %{<%= admin_area { 'hello' } %>} - end - res.should match /hello/ - end - end - - it "should not display a Admin area for user not :admin" do - with_engine do |e, view| - view.stubs(:has_role?).with([:admin]).returns false - - res = e.run_template do - %{<%= admin_area { 'hello' } %>} - end - res.should be_empty - end - end - end # desc - end # context + # context 'method auto-generated when Rails initialize based on registered roles' do + # describe '#guest_area' do + # it "should display an Admin area for :admin" do + # with_engine do |e, view| + # view.stubs(:has_role?).with([:admin]).returns true + # + # res = e.run_template do + # %{<%= admin_area { 'hello' } %>} + # end + # res.should match /hello/ + # end + # end + # + # it "should not display a Admin area for user not :admin" do + # with_engine do |e, view| + # view.stubs(:has_role?).with([:admin]).returns false + # + # res = e.run_template do + # %{<%= admin_area { 'hello' } %>} + # end + # res.should be_empty + # end + # end + # end # desc + # end # context end \ No newline at end of file