1

我已经使用 fb_graph 设置了 Facebook 登录,类似于https://github.com/nov/fb_graph_sample,并且一直在尝试为使用 facebook 登录等事情编写一些黄瓜(使用 capybara)集成测试,但我不知道如何获取fb_graph 配合黄瓜。

登录步骤

When(/^I sign in with facebook$/) do
  visit root_path
  mock_graph :get, 'me', 'users/me_private', :access_token => 'access_token' do
    user = FbGraph::User.me('access_token').fetch
  end
end

当我运行 bundle exec cucumber 时输出

Feature: Signing in to DropShare with Facebook
  In order to log into DropShare
  As a user
  I want to log in with my Facebook account

  Background: Start from home page # features/facebook_signin.feature:6
    Given I am on the home page    # features/step_definitions/web_steps.rb:44
    Then I should see "Sign in"    # features/step_definitions/web_steps.rb:105    

  Scenario: A user successfully signs in with facebook (Happy Path) # features/facebook_signin.feature:11
    When I sign in with facebook                 #  features/step_definitions/signin_steps.rb:7
      undefined method `stub_request' for #<Cucumber::Rails::World:0x007fd96d1b6630> (NoMethodError)
      ./features/step_definitions/signin_steps.rb:9:in `/^I sign in with facebook$/'
      features/facebook_signin.feature:12:in `When I sign in with facebook' 

如果我将步骤更改为此,我会收到以下错误

When(/^I sign in with facebook$/) do
  visit root_path
  click_link("Sign in")
end

 uninitialized constant OauthController (ActionController::RoutingError)
  ./features/step_definitions/signin_steps.rb:7:in `/^I sign in with facebook$/'
4

0 回答 0