[rspec-users] spec'ing theme views

David Chelimsky dchelimsky at gmail.com
Tue Apr 7 00:23:54 EDT 2009


On Mon, Apr 6, 2009 at 7:06 PM, jared <jared at yourelevation.com> wrote:
> I'm using the theme support plugin on one of my apps, and I would like
> to spec the views for each of my themes, but having a little trouble
> and hoping someone can point me in the right direction.
>
> Themed views are located at /themes/my_theme/views that override the
> views in app/views when that theme is active. I created a themes/
> my_theme/spec directory, and to spec the file at /themes/my_theme/
> views/default/index.html.erb I created the following file at themes/
> my_theme/spec/default/index.html.erb_spec.rb
>
> require File.expand_path(File.dirname(__FILE__) + '/../../../../spec/
> spec_helper')
>
> describe "/default/index.html.erb" do
>  include DefaultHelper
>
>  it "should render" do
>    render
>  end
>
> end
>
> Two major questions here:
>
> 1) I'm not sure what to put for the describe parameter since I'm
> assuming "/default/index.html.erb" is referencing the app/views
> directory

Try this:

describe "/default/index.html.erb", :type => :view do
 include DefaultHelper

 it "should render" do
   template.view_paths=(File.join(File.dirname(__FILE__),
"/../../../themes/my_theme/"))
   render
 end

end

Cheers,
David

>
> 2) Running this spec gives:
>
> NameError in '/default/index.html.erb should render'
> undefined local variable or method `render' for
> #<ActiveSupport::TestCase::Subclass_1:0x351dc24>
> themes/my_theme/spec/default/index.html.erb_spec.rb:11:
>
> any suggestions on how to approach this?
>
> Thanks!
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list