某些场景使用的背景

时间:2010-10-12 03:49:56

标签: ruby-on-rails cucumber scenarios

    Feature: list video in stored

      Background:
       Given I have the following videos
          | title                              | format   |
          | Running Central Park in the Fall   | BluRay   |
          | Running Glacier Park in the Spring | Download |
          | Running Balboa Park in the Winter  | DVD      |

    Scenario: list videos in stored   
      When I am on the "video" page
      Then I should see "Running Central Park in the Fall"
      Then I should see "Running Glacier Park in the Spring"
      Then I should see "Running Balboa Park in the Winter"

   Scenario: Page links
     When I view all videos from page "1"
     Then I should not see "Cycling Utah in the Spring"
     Then I should not see "Touring Utah in the Spring"
     Then I should see "Previous"
     Then I should see "1"
     Then I should see "2"
     Then I should see "Next"

   Scenario: Show a message when there is no video
     When I am on the "video" page
     Then I should see "No videos"

我希望在场景中使用背景:“列出已存储的视频”和“页面链接”但排除场景:“在没有视频时显示消息”。请支持我谢谢

1 个答案:

答案 0 :(得分:1)

创建2个功能,一个具有背景和场景,另一个没有背景

    Feature: list video in stored

      Background:
       Given I have the following videos
          | title                              | format   |
          | Running Central Park in the Fall   | BluRay   |
          | Running Glacier Park in the Spring | Download |
          | Running Balboa Park in the Winter  | DVD      |

    Scenario: list videos in stored   
      When I am on the "video" page
      Then I should see "Running Central Park in the Fall"
      Then I should see "Running Glacier Park in the Spring"
      Then I should see "Running Balboa Park in the Winter"

   Scenario: Page links
     When I view all videos from page "1"
     Then I should not see "Cycling Utah in the Spring"
     Then I should not see "Touring Utah in the Spring"
     Then I should see "Previous"
     Then I should see "1"
     Then I should see "2"
     Then I should see "Next"

Feature: list video in stored without video
   Scenario: Show a message when there is no video
     When I am on the "video" page
     Then I should see "No videos"