0

I am trying to create a custom rspec formatter using Watir and got this error while executing the class. I have never used Watir before. Do I need some special gems for it?

Error: uninitialized constant Watir::RSpec::Core (NameError)

My code:

require 'rspec/core/formatters/html_formatter'
module Watir
  class RSpec
    class CustomFormatter < RSpec::Core::Formatters::HtmlFormatter

    end
  end
end
4

1 回答 1

0

由于CustomFormatter尝试继承的类而发生异常。RSpec::Core::Formatters::HtmlFormatter由于位置的关系,它是在类的范围内寻找Watir::RSpec类。

通常自定义格式化程序是这样完成的:

require 'rspec/core/formatters/html_formatter'

class CustomFormatter < RSpec::Core::Formatters::HtmlFormatter
end

您无需将其放在Watir::RSpec空间中。

于 2013-05-31T17:11:49.177 回答