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

ruby-on-rails – 黄瓜未定义的方法

发布时间:2020-12-17 03:54:06 所属栏目:百科 来源:网络整理
导读:我用黄瓜和水豚 我有几个类似的错误. 对于步骤: Then /I should see movies of rating 'PG' or 'R'/ do page.body.should match(/tdPG/td/) page.body.should match(/tdR/td/)end 黄瓜错误: undefined method `match' for #Cucumber::Rails::World:... (
我用黄瓜和水豚

我有几个类似的错误.

对于步骤:

Then /I should see movies of rating 'PG' or 'R'/ do
  page.body.should match(/<td>PG</td>/)
  page.body.should match(/<td>R</td>/)
end

黄瓜错误:

undefined method `match' for #<Cucumber::Rails::World:...> (NoMethodError)
./features/step_definitions/movie_steps.rb:37:in 
   `/I should see movies of rating 'PG' or 'R'/'

对于步骤:

Then /I should see an empty table/ do
  page.body.scan(/<tr>/).length.should == 0
end

黄瓜错误:

undefined method `should' for 1:Fixnum (NoMethodError)
./features/step_definitions/movie_steps.rb:46:in 
      `/I should see an empty table/'

并为步骤:

Then /I should see all of the movies/ do
  Movie.find(:all).length.should page.body.scan(/<tr>/).length
end

undefined method `should' for 10:Fixnum (NoMethodError)
./features/step_definitions/movie_steps.rb:59:in 
    `/I should see all of the movies/'

整个文件的步骤是here

正如您所看到的,这些错误非常相似,但我无法理解导致此问题的原因.

解决方法

在我看来,你对rspec期望有问题.尝试添加

require 'rspec/expectations'

到您的env.rb和等效的Gemfile.

(编辑:李大同)

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

    推荐文章
      热点阅读