Re: [rspec-users] view_context in specs

2012-01-09 Thread Benito S.
If you put this on your spec_helper.rb //If you have your spec in the directory "spec/presenters" config.include ActionView::TestCase::Behavior, example_group: {file_path: %r{spec/presenters}} Then you can use a method, :view, that you can use as the view context like this let(:profile) { Profil

Re: [rspec-users] view_context in specs

2011-11-02 Thread Patrick J. Collins
> > Is the best way to get a real-world view context in there to do something > > like: > > > > Blah.new(ActionView::Base.new) ? > > > > Or does RSpec have something magical already setup for this sort of thing? > > Nope. rspec-rails doesn't know that you want to write presenters :) > > I'd sa

Re: [rspec-users] view_context in specs

2011-11-02 Thread David Chelimsky
On Nov 2, 2011, at 9:46 PM, Patrick J. Collins wrote: > I have a presenter class which is instantiated like this: > > class Blah > > def initialize(context) >@context = context > end > > def do_something_view_related >@context.render :partial => "/...somewhere" > end > > def do_so

Re: [rspec-users] view_context in specs

2011-11-02 Thread David Chelimsky
On Nov 2, 2011, at 9:52 PM, David Chelimsky wrote: > On Nov 2, 2011, at 9:46 PM, Patrick J. Collins wrote: > >> I have a presenter class which is instantiated like this: >> >> class Blah >> >> def initialize(context) >> @context = context >> end >> >> def do_something_view_related >> @cont

[rspec-users] view_context in specs

2011-11-02 Thread Patrick J. Collins
I have a presenter class which is instantiated like this: class Blah def initialize(context) @context = context end def do_something_view_related @context.render :partial => "/...somewhere" end def do_something_else_view_related @context.content_tag :p, "fancy paragraph"