I’m upgrading an old site of mine and decided to use HighVoltage for the static pages on the site. This is what I started with, and it fails at the “to have_content” because response.body is empty…
describe PagesController do
it "links to FAQ page" do
http_login_with_credentials
get :show, id: 'FAQ'
expect(response.status).to eq 200
puts "#{response.inspect}"
expect(response.body).to have_content('Frequently Asked Questions') # Fail
expect(response.body).to have_css 'a[href="/secrets"]', :text => 'mylist'
end
end
Why is that? I’d like to understand so that I don’t waste a bunch more time with a flawed test.
I did get a different set of tests running which work and cover what I need, I think:
describe PagesController, '#show' do
%w{about FAQ changes}.each do |page|
context 'on GET to /pages/#{page}' do
before do
get :show, :id => page
end
it { should respond_with :success }
it { should render_template(page) }
end
end
end
What do you think of this test… adequate/sufficient?
Thanks mcuh…