2012-05-03 15 views
0

私は失敗しているステップ定義を持っています。私はそれがで失敗している「とその機能に問題がある」私はそれがみんなのためのステップの定義を書くにはどうすればよい(タイトルで未定義のローカル変数)キュウリのステップ定義に失敗しました

Feature: Viewing issue 
In order to view the issues for a feature 
As a user 
I want to see them on that feature's page 
Background:  
    Given there is a release called "Confluence" 
    And that release has a feature: 
     | title    | description | 
     | Make it shiny!  | Gradients! Starbursts! Oh my! | 
    And that feature has a issue: 
     | title    | description | 
     | First Issue   | This is a first issue. | 
    And I am on the homepage 

    Scenario: Viewing issue for a given feature 
    When I follow "Confluence" 
    Then I should see "Standards compliance" 
    When I follow "Standards compliance" 
    Then I should see "First Issue" 
    And I should see "This is a first issue." 

を、以下の機能から

これは私が機能定義に持っているものであり、それは素晴らしい作品が、私は問題のオブジェクトに対して同じことをやってみました、それはあなたがあなたの中でインスタンス変数を使用しないでください

Given /^that release has a feature:$/ do |table| 
    table.hashes.each do |attributes| 
    @release.features.create!(attributes) 
    end 
end 
+2

「その機能には問題があります」というステップ定義があります。 –

答えて

0

を動作しません。ステップ、ベストプラクティスとして。彼らはお互いに依存しています。

私は(擬似っぽいコードで)このようなあなたの手順を記述します

Given there is a release called <name> 
    # create model 

Given release <name> has a feature <table> 
    release = Release.find_by_name(<name>) 
    # rest of your code here is fine, but reference 'release' instead of '@release' 

Given release <name>'s <feature_name> has issues <table> 
    release = Release.find_by_name(<name>) 
    feature = release.features.find_by_name(<feature_name>) 
    table.hashes.each do |attributes| 
     # create issue 
    end 

その後、あなたのキュウリの機能は、このような優れた読みます:あなたがあなたのコードをポストする必要が

Given there is a release called "Confluence" 
And release "Confluence" has a feature: 
    | title    | description | 
    | Make it shiny!  | Gradients! Starbursts! Oh my! | 
And release "Confluence"'s "Make it shiny!" feature has issues 
    | title    | description | 
    | First Issue   | This is a first issue. | 
関連する問題