Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing view helper methods from Capybara rquest specs

I've got the view helper method in my application helper:

module ApplicationHelper
 def formatted_something(something)
   "Hello, #{something}"
 end
end

I want to access that method in my request spec:

require "spec_helper"

describe "something" do
  include RequestSpecHelper

  it "should display blogs list" do
    visit something_url
    page.should have_content formatted_something(@something.something)
  end
end

It couldn't find formatted_something method.

like image 328
alexs333 Avatar asked Dec 21 '22 13:12

alexs333


1 Answers

You just need to include the relevant helper module in your describe block, and it will be available in all nested specs:

describe "something" do
  include RequestSpecHelper
  include ApplicationHelper

  ...
end
like image 79
Chris Salzberg Avatar answered Dec 30 '22 06:12

Chris Salzberg