`
golden05
  • 浏览: 1886 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

rspec setup autotest

阅读更多
RSpec, autotest and Snarl on Windows

Earlier this year I started using RSpec and loved it immediately. Testing is not the most exciting or glamorous part of software development but a behavioural driven approach really appealed to me, as did the much more readable RSpec syntax.

To get me started I bought the RSpec Basics screencast from PeepCode (which has since expanded into a 3 part series). It was a good introduction but, as is often the case in Rails-land, it left me with a case of Mac envy.

The screencast includes a section on using autotest (part of the ZenTest package) and Growl to get instant pop-up notifications when specifications pass or fail. But what about me on my trusty Dell laptop? Where are my shiny notifications?

The good news is that autotest also includes support for Snarl, a Windows alternative to Growl. Hurrah!

Here’s how to set it up – I’m assuming that you’ve already got a Rails application with the RSpec plugins installed:

   1.

      Download and install Snarl (version 1.6). You’ll also be asked to install Melon, a Windows development toolkit, but you only need to install the core component when prompted.
   2.

      Install ZenTest (version 3.6.1): gem install --include-dependencies ZenTest
   3.

      Install diff-lcs (version 1.1.2): gem install diff-lcs

      Update: see the comments for additional information about this gem.
   4.

      Install ruby-snarl (version 0.0.8): gem install ruby-snarl
   5.

      Set the HOME user environment variable to your user profile directory, for example on my system it is set to: C:\Documents and Settings\Rob
   6.

      Download the install the GNU DiffUtils package – I installed this into my C:\Windows\System32 directory.
   7.

      Download and unzip the famfamfam Silk icons and copy the following files into $RUBY_HOME\lib\ruby\gems\1.8\gems\ZenTest-3.6.1\lib\icons where $RUBY_HOME is the directory where Ruby is installed:
          * accept.png
          * exclamation.png
          * information.png

      You can of course use any icons you prefer: I’m currently using Crystal icons from Everaldo Coelho. Just make sure you use PNGs and, if necessary, rename them to accept.png, exclamation.png and information.png.
   8.

      Create a file called .autotest in your Rails application root containing:

      require 'autotest/snarl'

   9.

      Open the spec/spec.opts file in your Rails application and remove the --color option (if it is present). My file looks like this:

      --format
      progress
      --loadby
      mtime
      --reverse

  10. A screenshot of Snarl in action

      From your Rails application root type autotest to start the testing process and you should see Snarl notifications popping up as shown in the screenshot on the right.

      Autotest will re-run your specifications each time you change your code and a Snarl notification will popup to tell you if you broke anything.

And finally: if you’re looking for a way to annoy your co-workers then you should take a look at Foz’s sound effects plugin for autotest and maybe use a DHH-style whoops when your specifications fail!
分享到:
评论

相关推荐

    rspec 入门者学习

    @setup_code end after do @cleanup_code end ``` 4. **Let**: 用于延迟计算对象,只有当真正需要的时候才会计算,可以提高测试效率。 - 示例: ```ruby let(:my_object) { MyClass.new } ``` 5. **...

    the rspec book.pdf

    《RSpec Book》是一本专注于Rspec的权威指南,它详细阐述了如何使用Rspec这个强大的测试框架进行行为驱动开发(BDD)。Rspec是Ruby编程语言中的一个测试库,它使得编写可读性强、表达力丰富的测试代码成为可能。这...

    rspec测试.pdf

    《RSpec测试:行为驱动开发与RSpec、Cucumber及其他工具》 RSpec是一种用于Ruby语言的单元测试框架,它提倡一种称为“行为驱动开发”(Behavior Driven Development,BDD)的测试方式。RSpec允许开发者以自然语言的...

    搭建Rails测试环境2: Autotest和Spork的安装和配置

    然而,值得注意的是,随着Rails的发展,像`rspec-rails`等库已经内置了对Autotest的替代方案,如`spring`,它们提供了更现代、更高效的测试体验。因此,虽然Autotest和Spork是过去常用的组合,但在最新的Rails项目中...

    rspec-setup-rails:如何使用 Rspec 快速设置导轨

    ##在 Rails 中快速设置 RSpec,使用 Capybara、Factory Girl、Database Cleaner、Shoulda-matchers 等... 在命令行中,运行rails new app_name -T (关闭默认测试单元) 将 Gems 添加到 gemfile,然后捆绑。 gem '...

    RSpec 3.1中文版

    RSpec是Ruby语言开发的一款行为驱动开发(BDD)工具,它通过使用领域特定语言(DSL)来帮助开发人员编写测试用例。RSpec 3.1版本是RSpec框架的更新版,提供了更多的功能和更好的用户体验。Rails是一个用Ruby语言编写的...

    Pragmatic.The RSpec Book.2010.pdf

    #### 一、RSpec框架简介与特性 **RSpec** 是 Ruby 社区中最受欢迎的行为驱动开发(Behavior Driven Development, BDD)框架之一。它为开发者提供了一种灵活的方式来定义应用程序的行为,并通过简洁易读的语法来编写...

    rspec_api_documentation, 从RSpec自动生成API文档.zip

    rspec_api_documentation, 从RSpec自动生成API文档 RSpec Doc为你的Rails API生成漂亮的。查看一个示例文件。更改请查看维基以了解最新的更改。安装将rspec_api_documentation添加到你的文件gem 'rspec_a

    rspec測試工具書

    Rspec是一种行为驱动开发(Behavior-Driven Development,简称BDD)工具,它在软件测试领域被广泛使用。其目的是通过描述软件行为来提高开发人员与非技术团队成员之间的沟通效率。Rspec允许开发者编写一个可读性很强...

    使用RSpec 测试Rails 程序.pdf

    ### 使用RSpec 测试Rails 程序的知识点总结 #### 一、RSpec与Rails结合的基础概念 **RSpec**(RSpec is not a unit testing framework)是一种为Ruby编程语言设计的行为驱动开发(BDD)框架,而**Rails**是基于...

    jruby-1.5.5+OperaWatir+RSpec

    标题 "jruby-1.5.5+OperaWatir+RSpec" 暗示了这是一个关于使用 JRuby 1.5.5 版本、OperaWatir 和 RSpec 进行自动化测试的项目或者资源集合。现在,我们将深入探讨这三个关键组件以及它们在 IT 领域中的应用。 JRuby...

    RSpec.Essentials

    ### RSpec Essentials: Key Insights and Learning Points **RSpec Essentials** is an essential guide for developers looking to enhance their skills in testing Ruby applications using the RSpec framework...

    rspec-api-blueprint-formatter, 从RSpec测试自动生成API文档 !.zip

    rspec-api-blueprint-formatter, 从RSpec测试自动生成API文档 ! RSpec APIBlueprint格式化程序从RSpec测试自动生成API文档 !像这样it 'retrievs the patients medications' do retrieve_medications

    The Rspec Book 最新版 (带Cucmber章节) - 最好的BDD书籍

    《RSpec Book》是关于行为驱动开发(BDD)的一本权威书籍,特别是针对Rspec这一Ruby语言的测试框架。本书的最新版包含了Cucumber章节,使得读者能够更好地理解和实践BDD理念。 行为驱动开发(BDD)是一种软件开发...

    rspec-collection_matchers, 集合基数匹配器,从rspec期望中提取.zip

    rspec-collection_matchers, 集合基数匹配器,从rspec期望中提取 RSpec::CollectionMatchers RSpec::CollectionMatchers 让你在一个例子中表达一个对象集合的预期结果。expect(account.shopping_cart).to have_

    The.RSpec.Book

    ### 《RSpec 书籍》:行为驱动开发与RSpec、Cucumber等工具的深入探索 #### 知识点一:RSpec 概述 - **RSpec**(RSpec)是一种为Ruby编程语言设计的行为驱动开发(Behavior Driven Development, BDD)框架。它通过...

    rspec_junit_formatter, RSpec结果格式化为你的CI可以读取的JUnit.zip

    rspec_junit_formatter, RSpec结果格式化为你的CI可以读取的JUnit RSpec JUnit格式化程序 RSpec 2 & 3结果, Jenkins可以读取。 可能还有其他的CI服务。灵感来自于的工作,在的RSpec格式化程序在对 Reporter的失望...

    Ruby-RSpec和Minitest匹配器来预防N1查询问题

    Ruby提供了两种强大的测试工具,RSpec和Minitest,它们通过匹配器功能可以帮助我们预防这种问题的发生。 RSpec是Ruby中广泛使用的BDD(行为驱动开发)框架,它允许开发者以自然语言的方式编写测试。匹配器是RSpec的...

Global site tag (gtag.js) - Google Analytics