Am a beginner, learning Ruby on Rails and I have an issue getting my test to work. Am using rspec and capybara. The problem is Capybara is not rendering the page or its not getting to the right page. The page opens properly in the browser when I execute: $rails s. But when I test with save_and_open_page, the html is empty.
My Specs
The following is my first PagesController spec:
require 'spec_helper'
describe PagesController do
describe "GET 'home'" do
it "returns http success" do
visit pages_home_path
save_and_open_page #at this point it opens the a blank html page
end
end
end
My controller spec, this opens a blank page.
I tried an alternative syntax for the Pagescontroller spec:
require 'spec_helper'
describe PagesController do
describe "GET 'home'" do
it "returns http success" do
get :home
response.should render_template('home')
response.should have_content("home") #it fails here
end
end
end
This shows the following error in the console Failures:
1) PagesController GET 'home' returns http success Failure/Error: response.should have_content("home") expected there to be text "home" in "#" # ./spec/controllers/pages_controller_spec.rb:10:in `block (3 levels) in '
Finished in 1.91 seconds 1 example, 1 failure
Other Configurations:
In the spec_helper I have added the following line, the rest is untouched.
require 'capybara/rspec'
*Gem file: *
gem 'rails', '3.1.0'
group :development, :test do
gem 'autotest-rails'
gem 'sqlite3'
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'cucumber-rails', :require => false
gem 'cucumber-rails-training-wheels'
gem 'database_cleaner'
gem 'capybara'
gem 'launchy'
gem 'rspec-rails'
gem 'simplecov'
gem 'rspec-core', '2.8.0'
end
group :assets do
gem 'therubyracer'
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem 'jquery-rails'
gem 'haml'
I have not installed Webrat and verified its not in my Gem list. Thank you for your help.