Pergunta

Im pretty new to ruby on rails. I just finished this tutorial and i am trying to make my own ruby website from scratch As soon as i switched my sin-tax to the less verbose one i am getting errors:

the errors I get are:

 1) Pages Home page
Failure/Error: it { should have_content('Home') }
NoMethodError:
  undefined method `has_content?' for "Home page":String
# ./spec/requests/pages_spec.rb:7:in `block (3 levels) in <top (required)>'

2) Pages Home page Failure/Error: it { should have_title('Home') } NoMethodError: undefined method has_title?' for "Home page":String # ./spec/requests/pages_spec.rb:8:inblock (3 levels) in '

this is my rspec file

require 'spec_helper'

describe "Pages" do
  describe "Home page" do
    before { visit root_path }

    it { should have_content('Home') }
    it { should have_title('Home') }    
  end

end

I have no idea what is going on did i forget to include something in my gemfile? If you want any more info comment and ill include it here

Foi útil?

Solução

Try

it 'has home title' do
  expect(page).to have_title('Home')
end

it 'has home content' do
  expect(page).to have_content('Home')
end

Or

subject { page }

it { should have_title('Home') }
it { should have_content('Home') }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top