alexs333
alexs333

Reputation: 12553

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.

Upvotes: 4

Views: 1816

Answers (1)

Chris Salzberg
Chris Salzberg

Reputation: 27374

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

Upvotes: 12

Related Questions