欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ruby , rspec中测试 module rubyrspecmodule 

程序员文章站 2024-01-08 16:44:58
...
见:  http://*.com/questions/1542945/testing-modules-in-rspec/1546493#1546493

What mike said. Here's a trivial example:

module code...
module Say
  def hello
    "hello"
  end
end


spec fragment...

class DummyClass
end

before(:each) do
  @dummy_class = DummyClass.new
  @dummy_class.extend(Say)
end

it "get hello string" do
  @dummy_class.hello.should == "hello"
end



相关标签: ruby rspec module