1

我正在关注Michael Harlt的教程。我是 Web 开发的新手。

所以我在编写测试时遇到了很多错误。我正在共享错误日志,并且我在互联网上搜索了一个并查看了很多我的代码,但没有得到错误是什么所以请帮助我,我正在共享代码和错误日志。
规范文件的代码。`

require 'spec_helper'


 describe "Static pages" do
        subject{ page }



  describe "Home page" do
        before {visit root_path}

        it { should have_selector('h1',  text: 'Sample App')}
        it {should have_selector ('title',  text: full_title(''))}
       it { should_not have_selector 'title',  text: '|Home'}
   end


describe "Help page" do
         before {visit help_path}

         it { should have_selector('h1',        text:'Help')}
         it { should have_selector('title',     text: full_title('Help'))}

end
    describe "About page"do
          before {visit about_path}

          it {should have_selector('h1',       text:'About')}
          it {should have_selector('title',     text: full_title('About US'))}
    end

  describe "Contact page" do
           before { visit contact_path}

           it {should have_selector('h1',       text:'Contact')}
           it{should have_selector('title',     text: full_title('Contact'))}
  end
end

方法代码full_title()

   module ApplicationHelper
         def full_title(page_title)
        base_title="Ruby on Rails Tutorial Sample App"
         if page_title.empty?
         base_title
         else
        "#{base_title} | #{page_title} "
         end
         end

   end

错误日志是

执行命令 bundle exec rspec spec/requests/static_pages_spec.rb 后

it {should have_selector('title',title: full_title(''))} ^

C:/sample_app/spec/request/static_pages_spec.rb:15 语法错误,意外keyword_end,预期'}'
**C:/sample_app/spec/request/static_pages_spec.rb:15 语法错误,意外keyword_end,预期'}' **


@spullen 的 spec_helper 文件

require 'spec_helper'
  describe StaticPagesHelper do
      pending "add some examples to (or delete) #{__FILE__}"
  end
4

0 回答 0