# How to test with RSpec a Rails plugin using â€œlink\_toâ€ and â€œcurrent\_page?â€

**URL:** <https://www.ruby-forum.com/t/how-to-test-with-rspec-a-rails-plugin-using-a-oelink-toa-and-a-oecurrent-page-a/150746>\
**Category:** Rails\
**Created:** [October 12, 2008, 3:29pm UTC](https://www.ruby-forum.com/t/how-to-test-with-rspec-a-rails-plugin-using-a-oelink-toa-and-a-oecurrent-page-a/150746 "2008-10-12T15:29:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![clauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@clauer](https://www.ruby-forum.com/u/clauer)\
**Post date:** [October 12, 2008, 3:29pm UTC](https://www.ruby-forum.com/t/how-to-test-with-rspec-a-rails-plugin-using-a-oelink-toa-and-a-oecurrent-page-a/150746/1 "2008-10-12T15:29:56Z")

</div>

I’m writing a Rails plugin that builds up a menu in a view. I’m using  
_link`_`to_ to build the link and _current\_page?_ to set  
class=“active” on the current page.

I’ve _include_d _ActionView::Helpers::UrlHelper_ so I can use  
_link`_`to_.

To get _current`_`page?_ working in the view, I’ve had to inherit the  
current class (apparently ActionView::Base) and it works perfectly  
well. Unfortunately, this totally breaks the tests with RSpec.

I’m calling _link`_`to_ and _current`_`page?_ like this:

```
def menu(options = {}, &block)
  carte = my_menu.new(self)
  yield carte
  carte.to_s unless carte.empty?
end

class my_menu
  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::UrlHelper

  def initialize(base)
    @base = base
  end

  def link
    @base.link_to(name, url_options, html_options)
    @base.current_page?(url_options)
  end
end

```

And I get this error with RSpec:  
Undefined method `link\_to’ for #\<  
Spec::Rails::Example::RailsExampleGroup::Subclass\_1:0x24afa90\>

Any clue?
