Rspec-i18n

Install

[sudo] gem install rspec-i18n

Or if you use rvm(for example ruby 1.8.7):

rvm 1.8.7 gem install rspec-i18n

Description

The Rspec-i18n gem provide a easy way to write specs in any speaking language you prefer - If don’t have your speaking language, please make a fork =) The Rspec-i18n was created for the purpose of teaching people who are starting to developing applications but also serves to Production use. I know that many people prefer to write code/specs in English. But if you don’t prefer that, you’ll like the Rspec-i18n. =)

Synopsis

Rspec-i18n will supports some speaking language(If don’t have your speaking language, please make a fork and send pull requests!) (See github.com/tomas-stefano/rspec-i18n/blob/master/lib/spec-i18n/languages.yml file). Here is a simple example of Portuguese(Brazil):

First your spec_helper:

# In spec/spec_helper

require 'spec-i18n'

Spec::Runner.configure do |config|

  config.spec_language :pt

  # ...
end

Then you have Translated -> Matchers, Before Hooks, After Hooks …(etc) in Portuguese Language. Start with a very very simple example in Portuguese:

# In spec/personagem_spec.rb

require 'spec_helper'

descreva Personagem do

  antes(:de_cada) do
    @homer = Personagem.new("Homer Simpson", :desenho => :simpson)

@meggie = Personagem.new(“Meggie Simpson”, :desenho => :simpson)

    end

    isto "deve retornar o desenho ao qual o personagem pertence" do             
      @homer.desenho.deve ser_igual_a(:simpson)                                 
    end                                                                         

    isto "deve ser personagem principal" do                                     
      @homer.deve ser_personagem_principal # look personagem_principal? method  
    end                                                                         

    isto "deve beber cerveja Duffy" do                                          
      @homer.bebe_cerveja_duffy?.deve ser_verdadeiro                            
    end                                                                         

    isto "deve beber cerveja Duffy" do                                          
      @meggie.bebe_cerveja_duffy?.deve ser_falso                                
    end

end

Examples

See more examples in github.com/tomas-stefano/rspec-i18n/blob/master/examples/i18n

Listing the available languages

rspec-i18n --language help

Listing the available keywords for the language

rspec-i18n –language pt rspec-i18n –language es

Adding a new language or completing a existing one

1. Make a fork of Rspec-i18n and pull it down
2. Add your language keywords to languages.yml
3. Commit and push your changes - then send a pull request at Github

OBS: Ideas for better words in languages.yml are Welcome =D.

Tested Versions

ONLY Ruby 1.8 Rspec-i18n >= 1.0.0 supports ONLY Rspec 1.3

The older versions supports this versions: Rspec: 1.2.7, 1.2.8, 1.2.9

Support for Rspec 2.0 and Ruby 1.9 come soon!

TODO

See the TODO.txt file and see more details