ITeye博客

ruby , rspec中测试 module

sg552 · 2012-07-30 10:29 · 编程语言 · Markdown

见: http://stackoverflow.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


评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。