添加额外示例后,rspec 中出现堆栈级别太深错误

发布于 2024-12-19 14:08:23 字数 1701 浏览 0 评论 0原文

我正在使用ruby-1.9.3-p0。我的捆绑包包括

Using rails (3.1.3)
Using rspec-core (2.7.1) 
Using rspec-expectations (2.7.0) 
Using rspec-mocks (2.7.0) 
Using rspec (2.7.0)
Using rspec-rails (2.7.0)

我的规范中出现了这个非常奇怪的问题。我有大约 5 个示例,如下所示:

describe "Example" do
  context "when adding stuff" do
    it "should do stuff" do
      # ...
    end

    it "..." do
      # ...
    end
  end

  context "when doing other stuff" do
    it "..." do
      # ...
    end

    it "..." do
      # ...
    end

    it "..." do
      # ...
    end
  end
end

但是,如果我在 context“when Doing other stuff” 块中添加一个额外的示例,我会收到此错误

  1) Example when adding stuff should do stuff
     Failure/Error: Unable to find matching line from backtrace
     stack level too deep
     # /../../activesupport-3.1.3/lib/active_support/duration.rb:55


  2) Example when adding stuff should do stuff
     Failure/Error: Unable to find matching line from backtrace
     stack level too deep
     # /../../activesupport-3.1.3/lib/active_support/core_ext/time/calculations.rb:266

奇怪的是,如果我注释掉所有内容在街区内,这样的

it "should do stuff" do
  # everything commented out
end

事情仍然会发生。即使我注释掉我添加的新示例,

it "new example within when doing stuff context" do
  # everything commented out
end

它仍然会引发错误。 然后,如果我注释掉每个示例中的所有代码,它仍然会发生!只有当我完全删除第一个it“should do stuff”示例时,它才会消失。有人经历过这个吗?谢谢。

编辑:我还想补充一件事。当像这样运行所有规范时:

rspec

我的所有示例都通过并运行,没有发生堆栈溢出。但是,只有当我单独运行规范时才会发生这种情况:

rspec spec/models/example_spec.rb

I'm using ruby-1.9.3-p0. My bundle includes

Using rails (3.1.3)
Using rspec-core (2.7.1) 
Using rspec-expectations (2.7.0) 
Using rspec-mocks (2.7.0) 
Using rspec (2.7.0)
Using rspec-rails (2.7.0)

I have this very weird problem occurring in my spec. I have about 5 examples, like so:

describe "Example" do
  context "when adding stuff" do
    it "should do stuff" do
      # ...
    end

    it "..." do
      # ...
    end
  end

  context "when doing other stuff" do
    it "..." do
      # ...
    end

    it "..." do
      # ...
    end

    it "..." do
      # ...
    end
  end
end

However, if I add an extra example, within the context "when doing other stuff" block, I get this error

  1) Example when adding stuff should do stuff
     Failure/Error: Unable to find matching line from backtrace
     stack level too deep
     # /../../activesupport-3.1.3/lib/active_support/duration.rb:55


  2) Example when adding stuff should do stuff
     Failure/Error: Unable to find matching line from backtrace
     stack level too deep
     # /../../activesupport-3.1.3/lib/active_support/core_ext/time/calculations.rb:266

What makes this weird is if I comment out everything within the block like so

it "should do stuff" do
  # everything commented out
end

it still happens. And even if I comment out the new example I added

it "new example within when doing stuff context" do
  # everything commented out
end

it still throws the error as well. And then, if I comment out all the code within each example, it still happens! Only if I remove the first it "should do stuff" example entirely, it goes away. Has anyone experienced this? Thanks.

EDIT: One more thing I'd like to add. When running all specs like so:

rspec

All my examples pass and run with no stack overflow occuring. However, it's only if I run the spec solo is this happening:

rspec spec/models/example_spec.rb

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So要识趣 2024-12-26 14:08:23

还要确保检查您的模型是否有最近的更改,例如

after_save :do_something

def do_something
 self.update_attribute(:att,val)
end

无限循环

Also make sure to check your model for recent changes like

after_save :do_something

def do_something
 self.update_attribute(:att,val)
end

aka endless loops

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文