Sha256: d647df355475d139d3c6d148a975db3c73c075eafbfba2382e69b1b4186b0386

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe ViewModels::View do
  subject do
    controller_class = double :controller_class, :view_paths => ActionView::PathSet.new
    controller       = double :controller, :class => controller_class, :_prefixes => nil

    ViewModels::View.new controller, Module.new
  end
  
  it "should be initializable" do
    lambda { subject }.should_not raise_error
  end
  
  it "should be renderable" do
    options = double('options', :to_render_options => {:hey => 'hey!'})
    subject.should_receive(:render).with(:hey => 'hey!').once
    subject.render_with(options)
  end
  
  describe "finding templates" do
    let(:lookup_context) { double('lookup_context') }
    let(:template) { double('template') }

    before(:each) do
      subject.stub :lookup_context => lookup_context
    end
    context "without ActionView Errors" do
      it "should find the template via lookup context" do
        lookup_context.should_receive(:find_template).with('PATH').once.and_return(template)
        subject.find_template('PATH').should == template
      end
    end
    context "with ActionView Errors" do
      it "should return nil" do
        lookup_context.should_receive(:find_template).with('PATH').once.and_raise(StandardError)
        subject.find_template('PATH').should be_nil
      end
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
view_models-4.0.1 spec/lib/view_models/view_spec.rb