Ruby on rails 3.2 保存一个打开的页面无法工作-错误消息表明找不到方法-但为什么?
我在另一个标题下发布了这个请求,在我用信息更新请求后没有收到任何反馈 我正在一个私人项目中工作,我是一名学习Rails的开发人员,并尝试使用TDD/BDD做正确的事情,但我必须说的是,我的经历让我想放弃测试,因为我根本没有时间尝试解决环境问题 我花了24小时的大部分时间试图解决这个问题。以下是我尝试过的事情:Ruby on rails 3.2 保存一个打开的页面无法工作-错误消息表明找不到方法-但为什么?,ruby-on-rails-3.2,rspec-rails,guard,spork,Ruby On Rails 3.2,Rspec Rails,Guard,Spork,我在另一个标题下发布了这个请求,在我用信息更新请求后没有收到任何反馈 我正在一个私人项目中工作,我是一名学习Rails的开发人员,并尝试使用TDD/BDD做正确的事情,但我必须说的是,我的经历让我想放弃测试,因为我根本没有时间尝试解决环境问题 我花了24小时的大部分时间试图解决这个问题。以下是我尝试过的事情: 删除Gemfile.lock并重新安装捆绑包 删除了gemeset并从头开始 按照教程(M.Hartl的从头开始)重建我的部分环境 昨晚——当我从本地项目切换到开始为主机更新git版本的
open_and_save_page
]在本地项目中工作,但在开始下一阶段交付之前,当我运行我的规范来测试所有内容时,我遇到了与--drb相关的故障,所以我升级了,当我打开防护流程时,这似乎消失了
以下是当前的错误:
imac:Genie railsdev$ rspec spec/requests/authentication_pages_spec.rb --drb
No DRb server is running. Running in local process instead ...
/Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:47:in `block (3 levels) in <top (required)>': undefined local variable or method `save_and_open_page' for #<Class:0x007ff51d35a8a8> (NameError)
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe'
from /Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:39:in `block (2 levels) in <top (required)>'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe'
from /Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:24:in `block in <top (required)>'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/dsl.rb:18:in `describe'
from /Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:13:in `<top (required)>'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in `rescue in run'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:62:in `run'
from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'
imac:Genie railsdev$
.rvmrc文件
rvm use ruby-1.9.3-p125@genie-bb-v3-3 --create
which rvm => /Users/railsdev/.rvm/bin/rvm
rvm -v => rvm 1.16.8 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
spec_helper.rb文件:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end
end
Spork.each_run do
# This code will be run each time you run your specs.
end
调用[保存和打开页面
]的文件:
require 'spec_helper'
# describe "AuthenticationPages" do
# describe "GET /authentication_pages" do
# it "works! (now write some real specs)" do
# # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
# get authentication_pages_index_path
# response.status.should be(200)
# end
# end
# end
describe "Authentication" do
subject { page }
describe "login page" do
before { visit login_path }
it { should have_selector('h1', text: 'Login') }
it { should have_selector('title', text: 'Login') }
end
describe "login" do
before { visit login_path }
describe "with invalid information" do
before { click_button "Login" }
it { should have_selector('title', text: 'Login') }
it { should have_error_message('Invalid') }
describe "after visiting another page" do
before { click_link "Home" }
it { should_not have_selector('div.alert.alert-error') }
end
end
describe "with valid information" do
let(:user) { FactoryGirl.create(:user) }
before { valid_login(user) }
it { should have_selector('title', text: user.name) }
#it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Logout', href: logout_path) }
it { should_not have_link('Login', href: login_path) }
save_and_open_page
# it { should have_content("[#{current_user}]") }
describe "followed by logout" do
before { click_link "Logout" }
it { should have_link('Login') }
end
end
end
...
end
我不确定我是否以正确的方式发布了我的问题,因为在其他一些问题上,我没有得到任何回应。在所有这些方面仍然是新的,在这方面的帮助是巨大的。所以先谢谢你
我需要做什么才能让第二个项目顺利进行
我注意到的一件事是,自从我开始在.rvmrc文件中放入[use
]之后,当我将cd放入目录时,我得到了以下内容
Using /Users/railsdev/.rvm/gems/ruby-1.9.3-p125 with gemset genie-bb-v3-3
Running /Users/railsdev/.rvm/hooks/after_cd_bundler
[
打开和保存页面
]是一种水豚方法吗?launchy在这一切中的位置是什么?我认为这是一个黄瓜相关的宝石。我认为这是一个新的用户理解错误。我发现,如果我将[save\u and\u open\u页面
]放在it
块中,我就可以实现这一点
我在阅读的任何文档中都没有看到这一点,但我想这是有道理的。我认为这是一个新的用户理解错误。我发现,如果我将[
save\u and\u open\u页面
]放在it
块中,我就可以实现这一点
我在阅读的任何文档中都没有看到这一点,但我想这是有道理的。刚刚注意到,如果您之前没有访问…\u路径,则保存和打开页面甚至不存在,因此,像这样在块外调用它肯定是错误的。刚才注意到,如果您以前没有执行
访问…\u path
,则保存和打开页面甚至不存在,因此像这样在块外调用它肯定是错误的
require 'spec_helper'
# describe "AuthenticationPages" do
# describe "GET /authentication_pages" do
# it "works! (now write some real specs)" do
# # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
# get authentication_pages_index_path
# response.status.should be(200)
# end
# end
# end
describe "Authentication" do
subject { page }
describe "login page" do
before { visit login_path }
it { should have_selector('h1', text: 'Login') }
it { should have_selector('title', text: 'Login') }
end
describe "login" do
before { visit login_path }
describe "with invalid information" do
before { click_button "Login" }
it { should have_selector('title', text: 'Login') }
it { should have_error_message('Invalid') }
describe "after visiting another page" do
before { click_link "Home" }
it { should_not have_selector('div.alert.alert-error') }
end
end
describe "with valid information" do
let(:user) { FactoryGirl.create(:user) }
before { valid_login(user) }
it { should have_selector('title', text: user.name) }
#it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Logout', href: logout_path) }
it { should_not have_link('Login', href: login_path) }
save_and_open_page
# it { should have_content("[#{current_user}]") }
describe "followed by logout" do
before { click_link "Logout" }
it { should have_link('Login') }
end
end
end
...
end
Using /Users/railsdev/.rvm/gems/ruby-1.9.3-p125 with gemset genie-bb-v3-3
Running /Users/railsdev/.rvm/hooks/after_cd_bundler