On May 25, 2011, at 5:56 PM, Meltemi wrote:

> group :development, :test do
>  gem 'rspec-rails'
>  gem 'webrat'
>  gem 'haml-rails'
>  gem 'sass'

I'd move haml and sass out of these groups - you need them in production.

>  gem 'spork', '~> 0.9.0.rc'
> end
> 
> group :test do
>  gem 'rspec'
> end

Don't need ^^ this because rspec-rails already depends on rspec (so it's 
already installed).

> 
> Generated some scaffolding and starting making and editing some
> specs... I was happy!
> 
> Now, after some stability and growing confidence I decided I'd try to
> swap out webrat and replace it with capybara (which I've heard good
> things about especially when dealing with javascript tests). So I
> commented out "# gem 'webrat'" and
> - added:
> 
>  gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git'

Strongly recommend sticking to releases while you're getting your feet wet.

gem 'capybara', '1.0.0.beta1'

Otherwise everytime you update the bundle you'll get a different revision.

>  gem 'launchy'
>  gem 'database_cleaner'
> 
> - added/modified what seems like alot of requires to spec_helper.rb
> (spork, rubygems, rspec/rails, capybara/rspec, capybara/rails,
> database_cleaner).
> 
> - changed some of my matchers from, what I think came from, webrat to,
> what I think works with, Capybara...but I'm getting failures in my
> controller & view specs. I'd really love to understand WHY and HOW/
> WHERE to look so in the future I can diagnose these errors myself.
> 
> VIEW SPEC:
> 
> # spec/view/pages/about.html.haml_spec.rb
> require 'spec_helper'
> 
> describe "pages/about.html.haml" do
> it "should have the right heading" do
>   # render                                    # <- worked with webrat
>   # rendered.should have_selector("h2", :content => "About Us")
>   visit pages_about_path
>   page.should have_selector('h2')

visit and page are not available in view specs. Stick with render and rendered. 
If you're using Capybara-1.0.0.beta1 you can use the have_selector method in 
the view spec.

> end
> end
> 
> Failures:
> 
> pages/about.html.haml should have the right heading
>    Failure/Error: visit pages_about_path
>    NoMethodError:
>      undefined method `visit' for
> #<RSpec::Core::ExampleGroup::Nested_7:0x0000010320a568>
> 
> CONTROLLER SPEC:
> 
> # spec/controllers/pages_controller_spec.rb
> require 'spec_helper'
> 
> describe PagesController do
> 
>  describe "GET 'about'" do
>    it "should be successful" do
>      # get 'about'                      # <- worked with webrat
>      # response.should be_success   #  <- webrat ok
>      visit pages_about_path
>      # visit '/pages/about.html'  #  <- also fails w/capybara
>      page.should have_content('About Us')
>      # page.html.should match(/About/i)  # no help
>      # page.should match(/About/i)   # no help
>    end
> end
> 
> 
> Failures:
> 
>  1) PagesController GET 'about' should be successful
>     Failure/Error: visit pages_about_path
>     LoadError:
>       no such file to load -- action_controller/integration
>     # ./spec/controllers/pages_controller_spec.rb:10:in `block (3
> levels) in <top (required)>'


Not sure about this part. Looks like it thinks its an integration test (which 
it is not - it's an ActionController::TestCase).

HTH,
David

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to