我使用fb_graph设置Facebook登录与https://github.com/nov/fb_graph_sample类似,并且一直试图写一些黄瓜(与capybara)集成测试,例如登录facebook,我无法弄清楚如何获取fb_graph与黄瓜合作。
signin_steps
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$/'