small medium large xlarge

Generic-user-small
29 Jun 2017, 12:21
Randy11 (5 posts)

Hello,

In the ‘Foreword’ part, there is ‘.. knowing how to listen to them. For your tests to be worth the bytes they’re written in, they must be able to speak to you about how well the underlying program is designed and implemented—and, crucially, you must be able to hear them. The words and ideas baked into RSpec are carefully chosen to heighten your sensitivity … ‘

Yes, the syntax is not difficult :

RSpec.describe  ... do 
  it ... do
    expect ...
 end 
end

But I think that many users can have a better result if they can express there ideas to RSpec with there own language. When I don’t use my own language, I reduce the vocabulary and make some simplifications that are not well done at the good place.

Have you a way to use an other language, like French, to write the specs ?

Best regards.

Randy11

Myron-profile-img_pragsmall
29 Jun 2017, 15:26
Myron Marston (13 posts)

Great question! You can use example group or example descriptions in any language. For example:

RSpec.describe "Une tasse de café" do
  it "coûte €1" do
    # ...
  end
end

(Apologies if that’s a poor French translation; it’s what translate.google.com gave me).

Beyond that, if you want to use French words (or words from another language) in place of RSpec’s main APIs like describe and it, you can easily define aliases for them, which can be in any language as long as it satisfies Ruby’s rules for what characters are allowed in method names. Chapter 7 (“Structuring Code Examples”) talks about how to define these aliases. If you want to use another language for in place of RSpec’s English-language matchers, you could define your own custom matchers (as discussed in chapter 12, “Creating Custom Matchers”) or just define aliases for the built in matchers (which is also discussed in chapter 12).

Generic-user-small
30 Jun 2017, 13:49
Randy11 (5 posts)

Hello Myron,

Thanks for your reply. Good translation, don’t worry ;-)

Your explanations are clear, they solve my concern.

I’ve already seen some tools (like Cucumber and Aruba) where the tests are build around the English’s vocabulary or, worst, the English’s grammar like Rails - this why I test Sinatra. I believe that it is a problem for the persons for whom the English is not easy to use.

I’ve bought your book to understand some Gems and thinking ‘If many people use it, it will be interesting to understand the tests written with RSpec’. But, I’ve bought it with many regrets because I was thinking that I am going to have many troubles to write some really useful test in English and in my case Minitest is a better solution.

I’ve looked on Internet for ‘RSpec + French’ without success, but I have some results with ‘Cucumber + French’. This why I was thinking the invest some time and money in Cucumber. With your explanations, it was an error.

You must add to your book a little part to explain how to use RSpesc in an other language than English. The best place is at the beginning or to dedicate an annexe at this subject. One page with examples and references to the others chapters can be sufficient.

Best regards.

Myron-profile-img_pragsmall
30 Jun 2017, 17:12
Myron Marston (13 posts)

When publishing a book, there comes a point when you have to stop adding additional content and tweaking it, and we’ve reached that point. We submitted our final draft a bit ago and are reviewing the copy editor’s changes to it now, before it is sent off to get printed. So we won’t be able to incorporate your idea, at least for this edition. If we do a 2nd edition, we’ll definitely keep your idea in mind!

You must be logged in to comment