测试驱动开发中的Rails错误

时间:2013-06-25 15:33:32

标签: ruby-on-rails-3 rspec

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

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

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

0 个答案:

没有答案