ruby-on-rails-3.2 – save_and_open_page(capybara / launchy)停止在项目中工作 – 错误

前端之家收集整理的这篇文章主要介绍了ruby-on-rails-3.2 – save_and_open_page(capybara / launchy)停止在项目中工作 – 错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
试图在合并Rails两个项目时调试一些我无法工作的规范.

我已经删除了我的Gemfile.lock并从头开始重新安装,我已经对特定的宝石进行了捆绑更新,而且整个很多但是当我尝试在我的请求规范中使用时出现错误

save_and_open_page

  1. railsdev$bin/rspec spec/requests/authentication_pages_spec.rb
  2. No DRb server is running. Running in local process instead ...
  3. /Users/rb/Repos/Genie/spec/requests/authentication_pages_spec.rb:33:in `block (3 levels) in <top (required)>': undefined local variable or method `save_and_open_page' for #<Class:0x007f981d139608> (NameError)
  4. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:201:in `module_eval'
  5. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:201:in `subclass'
  6. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:187:in `describe'
  7. from /Users/rb/Repos/Genie/spec/requests/authentication_pages_spec.rb:27:in `block (2 levels) in <top (required)>'
  8. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:201:in `module_eval'
  9. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:201:in `subclass'
  10. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:187:in `describe'
  11. from /Users/rb/Repos/Genie/spec/requests/authentication_pages_spec.rb:24:in `block in <top (required)>'
  12. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:201:in `module_eval'
  13. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:201:in `subclass'
  14. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/example_group.rb:187:in `describe'
  15. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/dsl.rb:18:in `describe'
  16. from /Users/rb/Repos/Genie/spec/requests/authentication_pages_spec.rb:13:in `<top (required)>'
  17. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load'
  18. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
  19. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `map'
  20. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load_spec_files'
  21. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/command_line.rb:22:in `run'
  22. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:66:in `rescue in run'
  23. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:62:in `run'
  24. from /Users/rb/.rvm/gems/ruby-1.9.3-p125@genie/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:10:in `block in autorun'

任何人都可以建议为什么失败以及我需要做些什么来纠正这个问题?

我让它在一个测试项目中运行,但在核心项目的主副本中,我不想将其搞砸.

编辑#1

所要求的代码

  1. require 'spec_helper'
  2.  
  3. # describe "AuthenticationPages" do
  4. # describe "GET /authentication_pages" do
  5. # it "works! (now write some real specs)" do
  6. # # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
  7. # get authentication_pages_index_path
  8. # response.status.should be(200)
  9. # end
  10. # end
  11. # end
  12.  
  13. describe "Authentication" do
  14.  
  15. subject { page }
  16.  
  17. describe "login page" do
  18. before { visit login_path }
  19.  
  20. it { should have_selector('h1',text: 'Login') }
  21. it { should have_selector('title',text: 'Login') }
  22. end
  23.  
  24. describe "login" do
  25. before { visit login_path }
  26.  
  27. describe "with invalid information" do
  28. before { click_button "Login" }
  29.  
  30. it { should have_selector('title',text: 'Login') }
  31. it { should have_error_message('Invalid') }
  32.  
  33. save_and_open_page
  34.  
  35. describe "after visiting another page" do
  36. before { click_link "Home" }
  37. it { should_not have_selector('div.alert.alert-error') }
  38. end
  39. end
  40.  
  41. describe "with valid information" do
  42. let(:user) { FactoryGirl.create(:user) }
  43. before { valid_login(user) }
  44.  
  45. it { should have_selector('title',text: user.name) }
  46. #it { should have_link('Profile',href: user_path(user)) }
  47. it { should have_link('logout',href: logout_path) }
  48. it { should_not have_link('Login',href: login_path) }
  49.  
  50. describe "followed by logout" do
  51. before { click_link "logout" }
  52. it { should have_link('Login') }
  53. end
  54. end
  55. end
  56.  
  57. describe "authorization" do
  58.  
  59. describe "for non-logged-in users" do
  60. let(:user) { FactoryGirl.create(:user) }
  61.  
  62. describe "when attempting to visit a protected page" do
  63. before do
  64. visit edit_user_path(user)
  65. fill_in "Name",with: user.name
  66. fill_in "Password",with: user.password
  67. click_button "Login"
  68. end
  69.  
  70. describe "after logging in" do
  71.  
  72. it "should render the desired protected page" do
  73. page.should have_selector('title',text: 'Edit user')
  74. end
  75. end
  76. end
  77.  
  78. describe "in the Users controller" do
  79.  
  80. describe "visting the user index" do
  81. before { visit users_path }
  82. it { should have_selector('title',text: 'Login') }
  83. end
  84.  
  85. describe "visiting the edit page" do
  86. before { visit edit_user_path(user) }
  87. it { should have_selector('title',text: 'Login') }
  88. end
  89.  
  90. describe "submitting to the update action" do
  91. before { put user_path(user) }
  92. specify { response.should redirect_to(login_path) }
  93. end
  94. end
  95. end
  96.  
  97. describe "as wrong user" do
  98. let(:user) { FactoryGirl.create(:user) }
  99. let(:wrong_user) { FactoryGirl.create(:user,name: "WrongName") }
  100. before { login user }
  101.  
  102. describe "visiting Users#edit page" do
  103. before { visit edit_user_path(wrong_user) }
  104. it { should_not have_selector('title',text: full_title('Edit user')) }
  105. end
  106.  
  107. describe "submitting a PUT request to the Users#update action" do
  108. before { put user_path(wrong_user) }
  109. specify { response.should redirect_to(root_path) }
  110. end
  111. end
  112. end
  113. end

的Gemfile:

  1. source 'https://rubygems.org'
  2.  
  3. gem 'rails','3.2.5'
  4.  
  5. # Bundle edge Rails instead:
  6. # gem 'rails',:git => 'git://github.com/rails/rails.git'
  7.  
  8. group :development,:test do
  9. gem 'sqlite3','1.3.5'
  10. gem "rspec-rails","~> 2.10.1"
  11. gem 'guard-rspec','0.5.5'
  12. gem 'annotate','~> 2.4.1.beta'
  13. gem 'pickle'
  14. gem 'simplecov'
  15. gem 'pg','0.12.2'
  16. gem 'capybara','1.1.2'
  17. gem 'launchy'
  18. end
  19.  
  20. # Gems used only for assets and not required
  21. # in production environments by default.
  22. group :assets do
  23. gem 'sass-rails','~> 3.2.4'
  24. gem 'coffee-rails','~> 3.2.2'
  25. gem 'uglifier','>= 1.2.3'
  26. gem 'bootstrap-sass','~> 2.0.3.1'
  27. # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  28. # gem 'therubyracer',:platform => :ruby
  29. end
  30.  
  31. gem 'jquery-rails','2.0.2'
  32. gem 'bootstrap-will_paginate','0.0.5'
  33. gem 'bootstrap-datepicker-rails'
  34. gem 'will_paginate','3.0.3'
  35. gem 'faker','1.0.1'
  36. gem 'wicked_pdf'
  37.  
  38. # To use ActiveModel has_secure_password
  39. gem 'bcrypt-ruby','3.0.1'
  40.  
  41. #gem 'ransack'
  42. gem 'cancan'
  43.  
  44. # Test gems on Macintosh OS X
  45. group :test do
  46. gem 'rb-fsevent',:git => 'git://github.com/ttilley/rb-fsevent.git',:branch => 'pre-compiled-gem-one-off'
  47. gem 'growl','1.0.3'
  48. gem 'guard-spork','0.3.2'
  49. gem 'spork','0.9.0'
  50. gem 'factory_girl_rails','4.1.0'
  51. gem 'cucumber-rails','1.2.1',:require => false
  52. gem 'database_cleaner','0.7.0'
  53. end
  54.  
  55. group :production do
  56. gem 'pg','0.12.2'
  57. end

解决方法

尝试从it块中调用save_and_open_page:

所以代替:

  1. it { should have_error_message('Invalid') }
  2.  
  3. save_and_open_page

尝试这个:

  1. it { should have_error_message('Invalid'); save_and_open_page }

今晚为我修好了

猜你在找的Ruby相关文章