Rsepc-rails output Capybarra best practice for learning

42 views Asked by At

When I run a model create rspec is creating a lot of empty tests. I have been trying to learn and have been creating my own Features/.specs. It leaves me getting output like the below. Should I just be writing tests in these files instead? What are the helper_specs for? or can you suppress the warning on helpers? I have tried to add require 'capybara/rspec' into one of the view/.specs and it doesn't seem to work their.

D:\Workspace\FrogDB>rspec
DL is deprecated, please use Fiddle
......*****

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) HomepageHelper add some examples to (or delete) D:/Workspace/FrogDB/spec/helpers/homepage_helper_spec.rb
     # Not yet implemented
     # ./spec/helpers/homepage_helper_spec.rb:14

  2) StaticPagesHelper add some examples to (or delete) D:/Workspace/FrogDB/spec/helpers/static_pages_helper_spec.rb
     # Not yet implemented
     # ./spec/helpers/static_pages_helper_spec.rb:14

  3) homepage/index.html.erb add some examples to (or delete) D:/Workspace/FrogDB/spec/views/homepage/index.html.erb_spec.rb
     # Not yet implemented
     # ./spec/views/homepage/index.html.erb_spec.rb:4

  4) static_pages/about.html.erb add some examples to (or delete) D:/Workspace/FrogDB/spec/views/static_pages/about.html.erb_spec.rb
     # Not yet implemented
     # ./spec/views/static_pages/about.html.erb_spec.rb:4

  5) static_pages/contact.html.erb add some examples to (or delete) D:/Workspace/FrogDB/spec/views/static_pages/contact.html.erb_spec.rb
     # Not yet implemented
     # ./spec/views/static_pages/contact.html.erb_spec.rb:4


Finished in 0.18501 seconds (files took 9 seconds to load)
11 examples, 0 failures, 5 pending

My first simple test. spec/features/static_pages_spec.rb

require 'spec_helper'
require 'capybara/rspec'

describe "the static_Pages should have the correct content" do
  describe "check on ABOUT page" do
    before { visit static_pages_about_path}
    it "should have the correct About content" do
      expect(page).to have_text("StaticPages#about")
    end
  end
  describe "check on Contact" do
    before { visit static_pages_contact_path}
    it "should have the correct CONTACT content" do
      expect(page).to have_text("StaticPages#contact")
    end
  end
end

If I rewrite for views/static_pages/about.html.erb_spec.rb it doesn't recognize the capybara command expect(page).to

 require 'spec_helper'
    require 'capybara/rspec'

    describe "the static_Pages should have the correct content" do
      describe "check on ABOUT page" do
     #   before { visit static_pages_about_path}
        it "should have the correct About content" do
          expect(page).to have_text("StaticPages#about")
        end
      end
end
0

There are 0 answers