语法错误“语法错误,意外的输入结束,需要keyword_end(SyntaxError)”

迪斯科舞厅

由于语法错误,我无法运行Rspec user_spec.rb测试。在2个不同的文件中可能有太多的“结尾”?我在某些地方添加和删除了“结束”,但没有成功。

语法错误“语法错误,意外的输入结束,期望keyword_end(SyntaxError)”需要'spec_helper'

user_spec.rb

describe User do

  before do
    @user = User.new(name: "Example User", email: "[email protected]",
                     password: "foobar", password_confirmation: "foobar")
  end

  subject { @user }

  it { should respond_to(:name) }
  it { should respond_to(:email) }
  it { should respond_to(:password_digest) }
  it { should respond_to(:password) }
  it { should respond_to(:password_confirmation) }

  it { should be_valid }

    before do
    @user = User.new(name: "Example User", email: "[email protected]")
  end

  subject { @user }

  it { should respond_to(:name) }
  it { should respond_to(:email) }
  it { should respond_to(:password_digest) }

  before do
    @user = User.new(name: "Example User", email: "[email protected]")
  end

  subject { @user }

  it { should respond_to(:name) }
  it { should respond_to(:email) }

  it { should be_valid }

  describe "when name is too long" do
    before { @user.name = "a" * 51 }
    it { should_not be_valid }
  end
end

describe "when email format is invalid" do
    it "should be invalid" do
      addresses = %w[[email protected],com user_at_foo.org [email protected].
                     [email protected]_baz.com [email protected]+baz.com]
      addresses.each do |invalid_address|
        @user.email = invalid_address
        expect(@user).not_to be_valid
      end
    end

  describe "when email format is valid" do
    it "should be valid" do
      addresses = %w[[email protected] [email protected] [email protected] [email protected]]
      addresses.each do |valid_address|
        @user.email = valid_address
        expect(@user).to be_valid
      end
    end


describe "when email address is already taken" do
    before do
      user_with_same_email = @user.dup
      user_with_same_email.save
    end
describe "when password is not present" do
    before do
      @user = User.new(name: "Example User", email: "[email protected]",
                       password: " ", password_confirmation: " ")
    end
    it { should_not be_valid }
  end

  describe "when password doesn't match confirmation" do
    before { @user.password_confirmation = "mismatch" }
    it { should_not be_valid }
  end

user_pages_spec.rb

   require 'spec_helper'

describe "User pages" do

  subject { page }

  describe "signup" do
    before { visit signup_path }


    it { should have_content('Sign up') }
    it { should have_title(full_title('Sign up')) }
  end
end

    let(:submit) { "Create my account" }

    describe "with invalid information" do
      it "should not create a user" do
        expect { click_button submit }.not_to change(User, :count)
      end
    end

    describe "with valid information" do
      before do
        fill_in "Name",         with: "Example User"
        fill_in "Email",        with: "[email protected]"
        fill_in "Password",     with: "foobar"
        fill_in "Confirmation", with: "foobar"
      end
    end

      it "should create a user" do
        expect { click_button submit }.to change(User, :count).by(1)
      end
    end

终端输出

/usr/local/rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load': /Users/Abraham/code/sample_app/spec/models/user_spec.rb:85: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)
    from /usr/local/rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /usr/local/rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /usr/local/rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /usr/local/rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /usr/local/rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /usr/local/rvm/gems/[email protected]_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
米格格拉兹(Miguelgraz)

似乎您有一堆describe从未有ends关键字的s,从开始describe "when email format is invalid" do直到describe "when email address is already taken" do

结束这些家伙,您可能就完成了=)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

语法错误“语法错误,意外的输入结束,需要keyword_end(SyntaxError)”

来自分类Dev

红宝石语法错误,意外的keyword_end,期望输入结束(SyntaxError)

来自分类Dev

Ruby语法错误-意外的输入结束,需要keyword_end

来自分类Dev

语法错误,意外的输入结束,需要keyword_end(帮助我)!

来自分类Dev

Rails的Heroku错误:语法错误,意外的keyword_end,期望输入结束

来自分类Dev

Rails Controller错误:语法错误,意外的keyword_end,预期输入结束

来自分类Dev

Ruby代码具有语法错误,意外的keyword_end,期望输入结束

来自分类Dev

Ruby语法错误-意外的输入结束,期望使用keyword_end

来自分类Dev

语法错误,意外的输入结束,期望使用keyword_end红宝石

来自分类Dev

rspec:失败/错误:_send_(方法,文件)。语法错误:104:语法错误,意外的keyword_end,预期输入结束

来自分类Dev

语法错误,意外的keyword_when,预期的keyword_end(SyntaxError)

来自分类Dev

语法错误,意外的tIDENTIFIER,重构IF / ELSE后需要keyword_end

来自分类Dev

Chef 模板变量语法错误,意外的“}”,需要keyword_end

来自分类Dev

Ruby语法错误,输入意外终止,应使用keyword_end

来自分类Dev

语法错误:意外的keyword_ensure,预期输入结束

来自分类Dev

语法错误,意外的':',期望输入结束

来自分类Dev

语法错误:意外的输入结束

来自分类Dev

语法错误,意外的keyword_else,预期的keyword_end

来自分类Dev

语法错误,意外的keyword_do_block,期望keyword_end ...关闭

来自分类Dev

语法错误,意外的keyword_ensure,在我的应用程序中期望keyword_end

来自分类Dev

语法错误,非预期的'{',期望使用keyword_end

来自分类Dev

语法错误,意外的一元+,期望keyword_end

来自分类Dev

语法错误,启动Sidekiq后出现意外的keyword_end

来自分类Dev

json解析错误语法错误输入意外结束

来自分类Dev

错误:语法错误:JSON输入意外结束

来自分类Dev

rails格式错误:语法错误,意外的keyword_ensure,预期输入结束

来自分类Dev

找不到错误...语法错误,意外的keyword_ensure,预期输入结束

来自分类Dev

Ruby On Rails收到错误:语法错误,意外的keyword_ensure,预期输入结束

来自分类Dev

未捕获的语法错误:JSON 输入意外结束 [}

Related 相关文章

  1. 1

    语法错误“语法错误,意外的输入结束,需要keyword_end(SyntaxError)”

  2. 2

    红宝石语法错误,意外的keyword_end,期望输入结束(SyntaxError)

  3. 3

    Ruby语法错误-意外的输入结束,需要keyword_end

  4. 4

    语法错误,意外的输入结束,需要keyword_end(帮助我)!

  5. 5

    Rails的Heroku错误:语法错误,意外的keyword_end,期望输入结束

  6. 6

    Rails Controller错误:语法错误,意外的keyword_end,预期输入结束

  7. 7

    Ruby代码具有语法错误,意外的keyword_end,期望输入结束

  8. 8

    Ruby语法错误-意外的输入结束,期望使用keyword_end

  9. 9

    语法错误,意外的输入结束,期望使用keyword_end红宝石

  10. 10

    rspec:失败/错误:_send_(方法,文件)。语法错误:104:语法错误,意外的keyword_end,预期输入结束

  11. 11

    语法错误,意外的keyword_when,预期的keyword_end(SyntaxError)

  12. 12

    语法错误,意外的tIDENTIFIER,重构IF / ELSE后需要keyword_end

  13. 13

    Chef 模板变量语法错误,意外的“}”,需要keyword_end

  14. 14

    Ruby语法错误,输入意外终止,应使用keyword_end

  15. 15

    语法错误:意外的keyword_ensure,预期输入结束

  16. 16

    语法错误,意外的':',期望输入结束

  17. 17

    语法错误:意外的输入结束

  18. 18

    语法错误,意外的keyword_else,预期的keyword_end

  19. 19

    语法错误,意外的keyword_do_block,期望keyword_end ...关闭

  20. 20

    语法错误,意外的keyword_ensure,在我的应用程序中期望keyword_end

  21. 21

    语法错误,非预期的'{',期望使用keyword_end

  22. 22

    语法错误,意外的一元+,期望keyword_end

  23. 23

    语法错误,启动Sidekiq后出现意外的keyword_end

  24. 24

    json解析错误语法错误输入意外结束

  25. 25

    错误:语法错误:JSON输入意外结束

  26. 26

    rails格式错误:语法错误,意外的keyword_ensure,预期输入结束

  27. 27

    找不到错误...语法错误,意外的keyword_ensure,预期输入结束

  28. 28

    Ruby On Rails收到错误:语法错误,意外的keyword_ensure,预期输入结束

  29. 29

    未捕获的语法错误:JSON 输入意外结束 [}

热门标签

归档