论坛首页 编程语言技术论坛

在netbeans6.7中使用rspec1.2.7

浏览 1753 次
精华帖 (0) :: 良好帖 (3) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-07-10  
将开发工具换成了netbeans6.7,rspec的版本,也变成了1.2.7,使用的过程中,发现一直无法跑起来,幸好netbeans forum上面已经有人发现并解决了:
引用

Just thought I'd let people know that rpsec-1.2.7 seems to have changed the way you get the line number from a spec file.

As a result, netbeans 6.7 won't run specs if you have 1.2.7 installed. The fix I've implemented (ymmv) is to change nb_rspec_mediator.rb. This lives in /usr/local/netbeans-6.7/ruby2/nb_rspec_mediator.rb on my linux machine.

Line 204 defines NbSpecParser, but it extends a class that no longer exists.

Change that line to:

class NbSpecParser < Spec::Runner::LineNumberQuery

and all should be well again. You now won't be able to run with rspec < 1.2.7, so if that's required, you might need some conditional logic around the class definition.
Anyway, I hope this helps someone.

解决也非常简单:将/netbeans-6.7/ruby2/nb_rspec_mediator.rb中的第204行换成
class NbSpecParser < Spec::Runner::LineNumberQuery
下面就按照rspec wiki上面的步骤操作:
ruby script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.7'
ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.7.1'
ruby script/generate rspec


接下来就可以在netbeans下使用rspec相应的generator了。
在新版的rspec中,已经告别了那个“it”,变成了下面的方式:
specify "should count two Users" do
    User.count.should be 2
end

是不是更加的明确了?不再是去"it"一个story了,呵呵。

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics