尝试测试用户登录(管理员)然后创建更多用户的场景。
在日志中,我可以看到控制进入登录页面,然后管理员用户登录,当控制重定向到进一步的用户创建页面时,登录过滤器停止并将控制重定向回登录页面。
黄瓜新手,所以代码质量不好,所以任何测试登录用户服务的指南都会有所帮助
这是我的场景
Feature: Create user from LMS
In order to create lms user with multiple groups
As a author
I want to create lms user with multipl groups
Scenario: Add new user with multiple groups
Given the following user information
And I am logged in as author "gulled" with password "thebest"
When I request for new lms user creation
Then the new user "user1" should be created
这是定义
Given /^the following user information$/ do
# Factory(:login)
# Factory(:author)
end
Given /^I am logged in as author "([^"]*)" with password "([^"]*)"$/ do |username, password|
visit "account/login"
fill_in "loginfield", :with => username
fill_in "password", :with => password
click_button "submit_button"
end
When /^I request for new lms user creation$/ do
visit "/author_backend_lms/new_user"
fill_in "login_first_name", :with => ""
fill_in "login_last_name", :with => ""
fill_in "login_login", :with => ""
fill_in "login_email", :with => ""
fill_in "login_password_confirmation", :with => ""
click_button "create_user_form_submit_button"
end
Then /^the new user "([^"]*)" should be created$/ do |user_login|
login = Login.find_by_login user
assert_no_nil login, "Record creation failed"
end
在“请求创建新的 lms 用户”中,当尝试访问 lms 用户创建页面时,控件会重定向回登录页面。
这是我的宝石测试清单
gem "capybara", "1.1.1"
gem "cucumber", "1.1.0"
gem "cucumber-rails", "0.3.2"