lundi 8 février 2016

Facebook Omniauth cucumber step definition testing login

I'm trying to do a simple setup for facebook login with a stub username/password. So far, after clicking facebook link it gets to the username/password window. I'm not sure how to supply the fake username/password for login.

In my spec/spec_helper.rb

OmniAuth.config.test_mode = true
  OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
    :provider => 'facebook',
    :uid => '123545',
    :email => "foobar@example.com",
    :first_name => "foo",
    :last_name => "bar",
    :password => "gpKU7CaS6p95E6zB"    
  })

  OmniAuth.config.add_mock(:facebook, {:uid => '12345'})

In my step_definitions/facebook_login_steps.rb

Then(/^I should see username\/password when I click login facebook$/) do
  find(:css, '.facebook').click
end

Then(/^I should put in a fake username\/password to login$/) do
 fill_in('email', with: "foobar@example.com")
 fill_in('pass', with: "gpKU7CaS6p95E6zB")
 click_button('Log In')
end

Aucun commentaire:

Enregistrer un commentaire