Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails-3 – 最佳实践,写真正的bdd黄瓜功能/场景大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_696_1@我们是bdd / cucumber的新手,并讨论如何编写正确的功能/场景.

我们想出了以下两种方法,应该几乎描述/解决同样的要求:

@H_801_4@Feature: Give access to dossiers to other registered users As a logged in user In order to show my dossier to other users I want to give other users (limited) access to my dossiers BACkground: Given I am logged in as "Oliver" And another user "Pascal" exists And another user "Tobias" exists Scenario: I can give access to my own dossier When I grant access to "Pascal" with permisson "readonly" Then I should see "Access granted." And user "Pascal" should have permission "readonly" on dossier "Oliver" Scenario: I can give access to a created dossier Given I created a new dossier "Max Müller" When I grant access on dossier "Max Müller" to "Pascal" with permisson "readonly" Then I should see "Access granted." And user "Pascal" should have permission "readonly" on dossier "Max Müller" Scenario: I can give access to a managed dossier Given I manage the dossier from "Tobias" When I grant access on dossier "Tobias" to "Pascal" with permisson "readonly" Then I should see "Access granted." And user "Pascal" should have permission "readonly" on dossier "Tobias" Scenario: I cAnnot give access to a writable dossier Given I have write access to the dossier from "Tobias" When I follow "Grant access" Then I should see "You are not allowed to grant access on this dossier." Scenario: I cAnnot give access to a readonly dossier Given I have readonly access to the dossier from "Tobias" When I follow "Grant access" Then I should see "You are not allowed to grant access on this dossier." Scenario: I can give access to a dossier with an expiration date Given I created a new dossier "Max Müller" When I grant access on dossier "Max Müller" to "Pascal" with permisson "readonly" until "2020-01-01" Then I should see "Access granted till 2020-01-01." And user "Pascal" should have permission "readonly" on dossier "Max Müller" until "2020-01-01" Scenario: I cAnnot transfer a created dossier to a new owner who is already registered Given I created a new dossier "Max Müller" When I transfer dossier "Max Müller" to "Pascal" Then I should see "Pascal already has a dossier,transfer not possible."

第二个:

@H_801_4@Feature: Grant access on dossiers to registered users As a logged in user In order to allow others to view/ manage dossiers I have access to I want to give access of those to other users BACkground: Given I am logged in as "gucki@email.com" And I am working with my own dossier Scenario: Invalid data entered When I visit the grant dossier access page And I press "Grant access" Then I should see a validation error on "eMail-Address" Scenario: Valid data entered Given a user "pascal@email.com" exists When I visit the grant dossier access page And I fill in "eMail-Address" with "pascal@email.com" And I SELEct "readonly" from "Permissions" And I press "Grant access" Then I should see "Access granted." And I should be on the dossiers page Scenario: Valid data entered with expiry date Given a user "pascal@email.com" exists When I visit the grant dossier access page And I fill in "eMail-Address" with "pascal@email.com" And I SELEct "readonly" from "Permissions" And I fill in "Valid until" with "2010-03-01" And I press "Grant access" Then I should see "Access granted till 2010-03-01." And I should be on the dossiers page Scenario: Display calendar on click on "Valid until" When I click on the field "Valid until" Then a calendar popup should be displayed When I click on "1943-01-02" Then the field "Valid until" should be have "1943-01-02" and the calendar popup should be hidden Scenario: Only allow to grant access to categories I have access to myself Given I have limited access to the working dossier When I visit the grant dossier access page Then I should not see categories I have no access to Scenario: Dossier with permission "manager" can only grant readonly,readwrite Given I have the permission "manager" on my working dossier When I visit the grant dossier access page Then I should only see the permissions "readonly,readwrite" Scenario: Dossier with permission "readwrite" is not allowed to GRANT ANy permissions Given I have the permission "readwrite" on my working dossier When I visit the grant dossier access page Then I should the see the error "You cAnnot grant access on this dossier!" And I should be on the dossiers page

你会喜欢哪一个,为什么?

解决方法

编写Cucumber测试的要点是创建一个规范,说明您的团队中无法读取代码的人可以读取的代码.我首先问他们他们喜欢哪一个.

我的猜测是他们更喜欢第一个,因为它更具声明性.因为它写在更高层次的抽象(而不是关心点击页面上的小部件),它更容易阅读.

与Josh说的相反,我认为通过UI可以工作的步骤是一个很好的主意.表面UI对功能的关注可能会使合法的设计变化变得脆弱,而且阅读也很无聊.

我最近就这个话题做了一个演讲,我认为这与你所处的位置非常相关:
http://skillsmatter.com/podcast/agile-testing/refuctoring-your-cukes

另请参阅这些相关博文:

> http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
> http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
> http://elabs.se/blog/15-you-re-cuking-it-wrong

祝你好运!

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails-3 – 最佳实践,写真正的bdd黄瓜功能/场景全部内容,希望文章能够帮你解决ruby-on-rails-3 – 最佳实践,写真正的bdd黄瓜功能/场景所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。