Sha256: b14043c50cf372eb66017b2017cc715cb362f5160aadaed130efa14dd79cae7e

Contents?: true

Size: 1.63 KB

Versions: 19

Compression:

Stored size: 1.63 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'spec/mocks/errors'

describe ActionView::Base, "with RSpec extensions:", :type => :view do 
  
  describe "should_receive(:render)" do
    it "should not raise when render has been received" do
      template.should_receive(:render).with(:partial => "name")
      template.render :partial => "name"
    end
  
    it "should raise when render has NOT been received" do
      template.should_receive(:render).with(:partial => "name")
      lambda {
        template.verify_rendered
      }.should raise_error
    end
    
    it "should return something (like a normal mock)" do
      template.should_receive(:render).with(:partial => "name").and_return("Little Johnny")
      result = template.render :partial => "name"
      result.should == "Little Johnny"
    end
  end
  
  describe "stub!(:render)" do
    it "should not raise when stubbing and render has been received" do
      template.stub!(:render).with(:partial => "name")
      template.render :partial => "name"
    end
  
    it "should not raise when stubbing and render has NOT been received" do
      template.stub!(:render).with(:partial => "name")
    end
  
    it "should not raise when stubbing and render has been received with different options" do
      template.stub!(:render).with(:partial => "name")
      template.render :partial => "view_spec/spacer"
    end

    it "should not raise when stubbing and expecting and render has been received" do
      template.stub!(:render).with(:partial => "name")
      template.should_receive(:render).with(:partial => "name")
      template.render(:partial => "name")
    end
  end

end

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
dchelimsky-rspec-rails-1.1.10 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.11.1 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.11.2 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.11.3 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.11 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.6 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.7 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.8 spec/rails/extensions/action_view_base_spec.rb
dchelimsky-rspec-rails-1.1.9 spec/rails/extensions/action_view_base_spec.rb
pictrails-0.5.0 vendor/plugins/rspec-rails/spec/rails/extensions/action_view_base_spec.rb
rspec-rails-1.1.11 spec/rails/extensions/action_view_base_spec.rb
rspec-rails-1.1.10 spec/rails/extensions/action_view_base_spec.rb
rspec-rails-1.1.9 spec/rails/extensions/action_view_base_spec.rb
rspec-rails-1.1.5 spec/rails/extensions/action_view_base_spec.rb
rspec-rails-1.1.8 spec/rails/extensions/action_view_base_spec.rb
rspec-rails-1.1.6 spec/rails/extensions/action_view_base_spec.rb
rspec-rails-1.1.7 spec/rails/extensions/action_view_base_spec.rb
typo-5.1.98 vendor/plugins/rspec-rails/spec/rails/extensions/action_view_base_spec.rb
typo-5.2 vendor/plugins/rspec-rails/spec/rails/extensions/action_view_base_spec.rb