[rspec-users] response.should have_text leads to undefined method `has_text?'

Kai Schlamp schlamp at gmx.de
Sat Oct 2 15:27:22 EDT 2010


A big hello.

I would like to test a controller that directly renders some JSON output (by using "render :json => @entity_names"). For that task I tried in my spec file "response.should have_text('["enim", "enita"]')". Unfortunately I always get that error: 
Failure/Error: response.should have_text('["enim", "enita"]') 
undefined method `has_text?' for " ":String

(Also a "response.body.should have_text('["enim", "enita"]')as someone suggested on Stackoverflow did not solve the problem.)

Do I miss some gem that provides that method? Here my Gemfile:

source 'http://rubygems.org'

gem 'rails', '>= 3.0.0'
gem 'mysql2'
gem 'mongrel'
gem 'devise'
gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :branch =>    'rails3'
gem 'thinking-sphinx', :git     => 'git://github.com/freelancing-god/thinking-sphinx.git', :branch  => 'rails3', :require => 'thinking_sphinx'

group :test, :development do
  gem 'rspec-rails', '>= 2.0.0.beta.19'
  gem 'steak', :git => 'git://github.com/cavalle/steak.git'
  gem 'webrat'
  gem 'capybara'
  gem 'capybara-envjs'
  gem 'shoulda'
  gem 'launchy'
  gem 'autotest'
  gem 'autotest-rails'
  gem 'test_notifier'
  gem 'rails3-generators'
  gem 'factory_girl_rails'
  gem 'populator'
  gem 'faker'
  gem 'random_data'
  gem 'database_cleaner', :git => 'git://github.com/bmabey/database_cleaner.git'
  gem 'delorean'
end

Best regards,
Kai
-- 
GMX DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit 
gratis Notebook-Flat! http://portal.gmx.net/de/go/dsl


More information about the rspec-users mailing list