加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 语法错误,意外的tIDENTIFIER,期待keyword_end

发布时间:2020-12-17 04:05:44 所属栏目:百科 来源:网络整理
导读:我究竟做错了什么?我认为我的所有目标都是正确的.我收到此错误 describe "visiting the edit page" dodescribe "submitting to the update action" dodescribe "visiting the user index" dodescribe "as wrong user" doFactoryGirl.create(:user,email: "w
我究竟做错了什么?我认为我的所有目标都是正确的.我收到此错误

describe "visiting the edit page" do

describe "submitting to the update action" do

describe "visiting the user index" do

describe "as wrong user" do

FactoryGirl.create(:user,email: "wrong@example.com")}

describe "visiting Users#edit page" do

这是我运行rspec时遇到的错误

syntax error,unexpected tIDENTIFIER,expecting keyword_end


describe "authorization" do

    describe "for non-signed-in users" do
      let(:user) {FactoryGirl.create(:user)}

      describe "when attempting to visit a protected page" do
        before do
          visit edit_user_path(user)
          fill_in "Email",with: user.email
          fill_in "Password",with: user.password
          click_button "Sign in"
        end

        describe "after signing in" do
          it "should render the desired protected page" do
            page.should have_selector('title',text: 'Edit user')
          end

          describe "when signing in again" do
            before do
              click_link "Sign out"
              click_link "Sign in"
              fill_in "Email",with: user.email
              fill_in "Password",with: user.password
              click_button "Sign in"
            end

            it "should render the default (profile) do
            page.should have_selector('title',text: user.name)
            end
          end
        end
      end

      describe "in the Users controller" do

        describe "visiting the edit page" do
          before {visit edit_user_path(user)}
          it { should have_selector('title',text: 'Sign in') }
          it {should have_selector('div.alert.alert-notice')}
        end

        describe "submitting to the update action" do
          before { put user_path(user)}
          specify {response.should redirect_to(signin_path)}
        end

        describe "visiting the user index" do
          before {visit users_path} 
          it {should have_selector{'title',text: 'Sign in'}}         
        end
      end
    end

    describe "as wrong user" do
      let(:user) {FactoryGirl.create(:user)}
      let(:wrong_user) {FactoryGirl.create(:user,email: "wrong@example.com")}
      before { sign_in user}

      describe "visiting Users#edit page" do
        before {visit edit_user_path(wrong_user)}
        it {should_not have_selector('title',text: 'Edit user')}
      end

      describe "submitting a PUT request to the Users#update action" do
        before {put user_path(wrong_user)}
        specify {response.should redirect_to(root_path)}
      end
    end
  end
end

解决方法

你错过了“在它的最后”应该渲染默认(配置文件).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读