2016-08-19 9 views
0

顧客レコードを見つけるとアクセスするための私のRubyの機能ファイルでこの手順:キュウリアリティの不一致エラー

When I search with the following details: "<recordReference>", "<secondIdentifier>", "<postcode>": 
    | recordReference | secondIdentifier| postcode | 
    | REFABCDE12345678| IDcode1234  | PC11 1PC | 

をそれは、このステップの定義があります。

When(/^I search with the following details: "(.*?)", "(.*?)", "(.*?)":$/) do |recordReference, secondIdentifier, postcode| 
    find(:css, "#dln").native.send_keys recordReference 
    find(:css, "#nino").native.send_keys secondIdentifier 
    find(:css, "#postcode").native.send_keys postcode 
    check 'confirmation' 
    click_button 'submit' 
end 

それは実行だとき、私は次の取得エラー:

Cucumber::ArityMismatchError: Your block takes 3 arguments, but the Regexp matched 4 arguments. 
features/step_definitions/refactored_commands.rb:207:in `/^I search with the following details: "(.*?)", "(.*?)", "(.*?)":$/' 

何が間違っていて、どのように修正できますか?

When /^I search with the following details: "(.*?)", "(.*?)", "(.*?)":$/ do |recordReference, secondIdentifier, postcode| 

答えて

1

四番目の引数は、DataTableのである: -

は情報についてparenthasesは、ステップ定義の外に取るされている場合、私は同じエラーメッセージが表示されます。最初の3つのパラメータを削除し、DataTableオプションだけを入力すると、DataTableからすべてのデータが取得されます。あなたはキュウリが適切なステップ定義照合を作成できるようにDRYRUN = trueオプションを使用して提案する、これが私のJavaの知識からであるが、このDRYRUNオプションがルビーであるかを知りません。 プラスあなたはシナリオが、それはあなたのテーブルのフォーマットからのステップ

にデータテーブルを渡して概説混同しているように見えます言及した3つのパラメータ

0

を削除する機能ファイルで、あなたのステップを変更する必要がありますあなたが実際に

Scenario Outline: xxx 
    ... 
    When I search with the following details: "<recordReference>", "<secondIdentifier>", "<postcode>" 
    ... 

    Examples: 
    | recordReference | secondIdentifier| postcode | 
    | REFABCDE12345678| IDcode1234  | PC11 1PC | 

あるべきためになるだろうし、各の枠の内部が塗りつぶさ値を持つ例の行ごとに一度呼び出されますどのように見えます - ので、あなたのステップは次のようになり

When(/^I search with the following details: "(.*?)", "(.*?)", "(.*?)"$/) do |recordReference, secondIdentifier, postcode| 
    ... 
end 
サイドノートで

- あなたは.native.send_keysを呼び出しているいずれかの理由がある - 私はそれだけだろうので、すべてのドライバーが今通常のカピバラsend_keys APIをサポートしています信じてfind(:css, '#dln').send_keys recordReference(またはコースのちょうどfill_in('dln', with: recordReference)