2011-07-11 6 views
2

私は新しいRuby on Railsアプリケーションを起動する比較的初心者です。私は、https://github.com/intridea/omniauthhttp://www.communityguides.eu/articles/16http://intridea.com/2011/1/31/easy-rails-admin-login-with-google-apps-and-omniauth?blog=companyという命令の組み合わせに従って始めました。すべてが正しく機能するようになった時点で、私はキュウリの最初の機能と手順を書き始めました。私はいくつかのステップを実行することができましたが、私は考えていたステップでうんざりしていました。私は2つのフォームを持っていますが、私は成功するためのシナリオを得ることができませんbasic And I press "button" step。キュウリ `プレスボタン`失敗(Capybara :: ElementNotFound)

関連する可能性の宝石:問題のフォームの

 
rails (3.1.0.rc4) 
capybara (1.0.0) 
cucumber (1.0.1) 
cucumber-rails (1.0.2) 
nokogiri (1.4.7) 
gherkin (2.4.5) 
rack-test (0.6.0) 
selenium-webdriver (0.2.2) 

セクション:問題の

<%= form_tag :controller => "services", :action => "newaccount" do %> 
    <%= submit_tag "confirm", :id => "confirm", :title => "confirm", :value => "confirm", :text => "confirm", :name => "confirm" %> 
    <%= submit_tag "cancel", :id => "cancel", :title => "cancel", :value => "cancel", :text => "cancel", :name => "cancel" %> 
<% end %> 

シナリオ:

Scenario: I register with a valid and currently active google account 
    Given I am not registered 
    When I sign in with a valid and currently active google account 
     And I press "confirm" # <-- THE PROBLEMATIC STEP 
    Then I should see "Your account has been created and you have been signed in!" 

私はこれが(ストレートから関連web_stepだと思います私が編集していないデフォルトweb_steps.rb):

When /^(?:|I)press "([^"]*)"$/ do |button| 
    click_button(button) 
end 

関連キュウリ出力:

Scenario: I register with a valid and currently active google account   # features/auth_and_auth/initial_tests.feature:6 
    Given I am not registered              # features/step_definitions/authentication_steps.rb:1 
    When I sign in with a valid and currently active google account    # features/step_definitions/authentication_steps.rb:5 
    And I press "confirm"               # features/step_definitions/web_steps.rb:52 
    no button with value or id or text 'confirm' found (Capybara::ElementNotFound) 
    (eval):2:in `click_button' 
    ./features/step_definitions/web_steps.rb:53:in `/^(?:|I)press "([^"]*)"$/' 
    features/auth_and_auth/initial_tests.feature:9:in `And I press "confirm"' 
    Then I should see "Your account has been created and you have been signed in!" # features/step_definitions/web_steps.rb:105 

関連するHTML出力:

<input id="confirm" name="confirm" text="confirm" title="confirm" type="submit" value="confirm"> 
<input id="cancel" name="cancel" text="cancel" title="cancel" type="submit" value="cancel"> 

明らかなように、私はvalueidtextだけでなく、nametitleを占めてきました。私はまた入力タイプがsubmitと指定されなければならなかったという記事を見ました。そして私はconfirmボタンとcancelボタンの両方で試しました。

私が知っているすべての場所を検索し、リモートで関連性があると思われるすべての提案を試した後、私は難局です。私は何が欠けていますか?

+3

ステップが呼び出されているときに実際にキュウリが正しいページにありますか? Capybaraには非常に便利な「save_and_open_page」メソッドがあります。web_steps.rbのclick_button呼び出しの上に配置し、実際に正しいページにあるかどうかを確認してください。 – idlefingers

答えて

3

私が遭遇した問題に対処する最善の方法は次のコードでは分かりませんが、合格するための適切なステップが得られています。

オリジナルweb_steps.rbバージョンが失敗した理由を
  • 、これは適切なアプローチであるかどうかを
  • 、および
  • がある場合:

     
    When /^(?:|I)press "([^"]*)"$/ do |button| 
    # click_button(button) # the original web_steps.rb version that fails 
        %{I press (button)} # my revised version that passes 
    end 
    

    私はまだ上の任意のフィードバックをいただければと思いますこれに対処するためのより多くの「レール」方法。

+0

ありがとう@MacSeanそれは私のためにも働いた。私は最後の3日以来、この解決策を探していた..あなたは私の一日を作った:) –

関連する問題