English 中文(简体)
将数据档案与RSpec /Ruby 的具体测试联系起来的最佳方式
原标题:Best way to associate data files with particular tests in RSpec / Ruby
  • 时间:2010-05-28 19:43:20
  •  标签:
  • ruby
  • rspec

对我的RSpec测试 我将自动将数据文档与每次测试联系起来。 为了澄清,如果我每次测试都需要一个Xml文档,作为投入数据,然后是一些xpath报表,以验证他们回来的回复,我想将Xml和xpath作为文档外部化,并且通过将测试的独特身份作为档案,很容易地与测试框架联系起来。 我试图采取这种行动,但解决办法并不明确。 我写了一种计算“描述”价值的助手方法,并将之与FILE结合起来,以形成一个独特的识别标志,该识别标志被设定为其他公共事业部门可以获取的全球变量。 独一无二的识别码被用于链接我所需要的数据文档。 我必须把这一助手方法称为每一次试验的第一线,这很奇怪。

如果我有这样的一个RSpec例子:

describe "Basic functions of this server I m testing" do
  it "should give me back a response" do
    # Sets a global var to: "my_tests_spec.rb_should_give_me_back_a_response"
    TestHelper::who_am_i __FILE__, description
    ...
  end
end

是否有更好的/微调/微薄的方法,我能为每次测试获得独一无二的识别资料,我可以把数据档案与数据档案联系起来? 也许,在SRSpec I m中,没有意识到什么?

Thank you, -Bill

问题回答

我刚刚学会了冲绳之前和之后的全球大厦。 我可以躲藏在那里独一无二的国际发展法。 这使得事情更加清洁。 我或许会同意这一解决办法,除非有更微薄的方法,为每次试验获得一个独特的身份证。 增 编





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签