开发者

Gem features doesn't properly load actual gem code

I've got a gem with cukes and specs that extend RSpec subjects.

All specs runs fine but the features doesn't seem to properly load the current gem code. Seems part开发者_StackOverflowially there though.

The gem is at https://github.com/ZenCocoon/rspec-subject-extensions

Note: New to cucumber, I might have skipped something obvious.


This is because rspec is being launched as a separate process. The spec file you're defining in your Cucumber feature does not require these extensions and so they won't be made available. The reason it's working in your RSpec tests is because you do require these extensions.

To fix this, you can add one line to the top of your Cucumber feature to require the rspec/subject/extensions.rb file:

Given a file named "example_spec.rb" with:
"""
  require 'rspec/subject/extensions'

  class Movie
    def ratings
      [9, 7, 9]
    end
  end

  describe Movie do
    each(:rating) { should be_an(Integer) }
  end
"""

This will fix the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜