Re: [rspec-users] Rails View spec testing for content in

2010-08-23 Thread Kristian Mandrup
I am trying to test methods I have added to ActionView::Base through a Rails 3 plugin. Basically, I have been trying to test it "outside of Rails" if possible, that is, to only load the bare minimum functionality. Here is my Rails view with a custom method #area added, which uses #with_output_buff

[rspec-users] How do I write specs for Rails 3 view block helpers that use #with_output_buffer(&block) ?

2010-08-23 Thread Kristian Mandrup
I found this: http://stackoverflow.com/questions/197164/how-do-i-test-rails-block-helpers-with-rspec it 'should do something' do helper.some_block_helper { the_block_code }.should end but not sure how to use it I have a module which is extended on top of ActiveView::Base module My

Re: [rspec-users] Rails View spec testing for content in

2010-08-23 Thread Kristian Mandrup
I wonder if I can just "stub out" #with_output_buffer to yield the block immediately, and then assume it will work just as well in a Rails view template? class MyView < ActionView::Base attr_accessor :current_user def with_output_buffer yield end end

Re: [rspec-users] Rails View spec testing for content in

2010-08-23 Thread Kristian Mandrup
I found this at: http://github.com/rspec/rspec-rails describe EventsHelper do describe "#link_to_event" do it "displays the title, and formatted date" do event = Event.new("Ruby Kaigi", Date.new(2010, 8, 27)) # helper is an instance of ActionView::Base configured with the #

Re: [rspec-users] Rails View spec testing for content in

2010-08-23 Thread Michael Kintzer
Thank you David. Makes perfect sense. -Michael > The render method you see in a view spec delegates to the render method in > ActionView::TestCase, which, in turn, delegates to view.render. Within rails, > view.render is called usually by a controller, which provides all the > necessary conte

[rspec-users] Request specs flash

2010-08-23 Thread Toni Tuominen
Hey, Is there a way to test for flash content on a request spec (other than to check the request body). I was trying to test something that redirects so testing the content is not possible. - Toni ___ rspec-users mailing list rspec-users@rubyforge.org h

Re: [rspec-users] Request specs flash

2010-08-23 Thread David Chelimsky
On Aug 23, 2010, at 11:38 AM, Toni Tuominen wrote: > Hey, > > Is there a way to test for flash content on a request spec (other than > to check the request body). I was trying to test something that > redirects so testing the content is not possible. AFAIK, no. Request specs are built on rails'

Re: [rspec-users] How do I write specs for Rails 3 view block helpers that use #with_output_buffer(&block) ?

2010-08-23 Thread Kristian Mandrup
I have finally come up with a workable solution http://gist.github.com/545866 module MyViewHelper def tab_for(clazz, &block) content = with_output_buffer(&block) content_tag :li, content, :class => clazz end end module MyOtherViewHelper ... end describe "do it" do it "works" do

Re: [rspec-users] How do I write specs for Rails 3 view block helpers that use #with_output_buffer(&block) ?

2010-08-23 Thread Kristian Mandrup
I packed it up into a useful reusable gem ;) http://github.com/kristianmandrup/rspec-action_view Only these dependencies :) require 'rspec' require 'action_view' require 'active_support/railtie' require 'action_view/template/handlers/erb' Now allows for this DSL describe "My ViewHelpers" do

[rspec-users] JRuby Rcov and Rspec problem.

2010-08-23 Thread Benyi Wang
When I run Rcov using JRuby, the Rcov report always includes some libraries. JRuby 1.5.1 rcov 0.9.8 rspec 1.3.0 ci_reporter 1.6.2 Here is my Rake file. require 'rake' require 'spec/rake/spectask' require 'ci/reporter/rake/rspec' task :default => :test ENV["CI_REPORTS"]="spec-reports" task :te