spinach vs cucumber for BDD in rails

后端 未结 4 1864
野的像风
野的像风 2021-02-02 13:49

I am starting on BDD. Was wondering which would be better to start with Cucumber or Spinach. My impression is that Spinach is new off the block. Look here

Which one shou

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 14:04

    If you're stuck with Cucumber and you don't want global steps, you can work around the problem by tagging the steps with some sort of scenario ID:

    # features/1_greetings.feature
    Scenario: Formal greeting
      Given I have an empty array [#1]
      And I append my first name and my last name to it [#1]
      When I pass it to my super-duper method [#1]
      Then the output should contain a formal greeting [#1]
    

    The #1 scenario id can be any value. I like to use ticket numbers for future reference.

    You can then place all the steps in one step definition file. It's close enough to the look of Spinach::FeatureSteps. No regex arguments too!

    # features/step_definitions/1_greetings.rb
    Given 'I have an empty array [#1]' do
      #...
    end
    
    And 'I append my first name and my last name to it [#1]' do
      #...
    end
    
    When 'I pass it to my super-duper method [#1]' do
      #...
    end
    
    Then 'the output should contain a formal greeting [#1]' do
      #...
    end
    

    I posted more about the workaround at github.

提交回复
热议问题