I found the solution. We can do this using stubs. 

it "should render sold by filter if sold by options returns true" do
    view.stub(:show_sold_by_options?).and_return(true)

    render partial: "reports/lead_report_search", handlers: [:haml], 
locals: { post_url: collection_summary_reports_path }

    expect(view).to have_received(:show_sold_by_options?)
    assert_select 
"input#search_resource_key[value='#{resource.id}@@#{resource.class.name}']", 
0
  end 

  Please correct me if I did anything wrong.


On Tuesday, 19 November 2013 11:35:17 UTC+5:30, siva wrote:
>
>
>
>   Hi 
>
>   First of all thanks everyone for helping.
>
>   I have view partial file 
>
>   # app/views/reports/_lead_report_search.html.haml
>
>   - if show_sold_by_options?
>        = f.input :resource_key, input_options({label: 'Sold By'})
>   - else
>       - value = 
> "#{current_resource.id<http://www.google.com/url?q=http%3A%2F%2Fcurrent_resource.id&sa=D&sntz=1&usg=AFQjCNHsW3hY2SpkogbPzmBHtkDEpWpg5Q>
> }@@#{current_resource.class.name<http://www.google.com/url?q=http%3A%2F%2Fcurrent_resource.class.name&sa=D&sntz=1&usg=AFQjCNHUDjuFnlH7mF1SUgkfJVHNnujqcw>
> }"
>       = f.input :resource_key, input_html: {value: value}, wrapper_html: 
> {class: :hidden}, selected: param[:resource_key]
>
>
>    # app/helpers/reports_helper.rb
>     def show_sold_by_options?
>         if is_lead_report
>            is_org_user?
>         end
>     end
>
>     I want to test whether method method has been called when view has 
> been rendered? How can I test?
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/3299411c-0469-4cf3-a715-3b16d60b9e5f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to