Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
91a8078cae
2
Gemfile
2
Gemfile
|
@ -38,7 +38,7 @@ group :test do
|
|||
gem 'factory_girl', '~> 4.4.0'
|
||||
gem 'selenium-webdriver', '~> 2.42.0'
|
||||
|
||||
|
||||
gem "faker"
|
||||
# platforms :mri, :mingw do
|
||||
# group :rmagick do
|
||||
# # RMagick 2 supports ruby 1.9
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
method: :post do |f| %>
|
||||
<div class="box tabular">
|
||||
<%= render :partial => 'form_contest', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= submit_tag l(:button_create), :style=> "margin-left: 100px;margin-top: 10px;" %>
|
||||
<%= javascript_tag "$('#bid_name').focus();" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
require 'spec_helper'
|
||||
describe User do
|
||||
# 测试数据验证
|
||||
# before { @user = User.new(login: "ExampleUser" ,mail: "user@example.com",
|
||||
# password: "foobar",password_confirmation: "foobar" ) }
|
||||
# 此处采用预构件的方式生成数据
|
||||
# it "has a valid facrtory" do
|
||||
# expect(FactoryGirl.create(:user)).not_to be_valid
|
||||
# end
|
||||
|
||||
before :each do
|
||||
@user = User.new(login: "ExampleUser" ,mail: "user@example.com",
|
||||
password: "foobar",password_confirmation: "foobar" )
|
||||
@user = User.new(login: 'ExampleUser',firstname: 'sanfeng',lastname: 'zhang' ,mail: 'user@example.com',
|
||||
password: 'foobar',password_confirmation: 'foobar' )
|
||||
end
|
||||
subject { @user }#指定@user为测试对象
|
||||
|
||||
# 指定@user为测试对象
|
||||
subject { @user }
|
||||
# 属性存在性的测试
|
||||
it { should respond_to(:login) }
|
||||
it { should respond_to(:mail) }
|
||||
|
||||
#此处采用与构建的方式生成数据
|
||||
# it"is invalid without login" do
|
||||
# user=FactoryGirl.build(:user,login: nil)
|
||||
# expect(user).to_not be_valid
|
||||
# end
|
||||
|
||||
# 用户名唯一性的测试
|
||||
describe "when login is already taken" do
|
||||
before do
|
||||
|
@ -32,8 +33,9 @@ describe User do
|
|||
# 邮箱唯一性测试
|
||||
describe "when mail address is already taken " do
|
||||
before do
|
||||
user_with_same_mail=@user.dup#dup method copy mail
|
||||
user_with_same_mail.mail=@user.mail.upcase#转大写
|
||||
#dup method copy mail
|
||||
user_with_same_mail=@user.dup
|
||||
user_with_same_mail.mail=@user.mail.upcase
|
||||
user_with_same_mail.save
|
||||
end
|
||||
it{should_not be_valid}
|
||||
|
@ -48,8 +50,8 @@ describe User do
|
|||
|
||||
#login长度测试(login最大25字符)
|
||||
describe "when the login is too long " do
|
||||
before{@user.login='a'*25}
|
||||
it{should be_valid}
|
||||
before{@user.login='a'*26}
|
||||
it{should_not be_valid}
|
||||
end
|
||||
# 姓和名的长度测试
|
||||
describe "when the first name is too long " do
|
||||
|
@ -104,8 +106,8 @@ describe User do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "when the mail is too long" do#邮箱长度验证的测试
|
||||
# 邮箱长度验证的测试
|
||||
describe "when the mail is too long" do
|
||||
before{@user.mail='a'*60}
|
||||
it{should_not be_valid}
|
||||
end
|
||||
|
@ -116,25 +118,27 @@ describe User do
|
|||
it{should_not be_valid}
|
||||
end
|
||||
|
||||
#调用相关方法是否能返回期待的结果
|
||||
#userInfo方法,选择项目成员时显示的用户信息的文字
|
||||
describe "returns the user info when choice the members of the project" do
|
||||
context "第一种情况" do
|
||||
@user=User.new()
|
||||
expect(@user.userInfo).to eq ''
|
||||
end
|
||||
context "二种情况" do
|
||||
@user=User.new()
|
||||
expect(@user.userInfo).to eq ''
|
||||
end
|
||||
# 选择项目成员时显示的用户信息文字userInfo方法的测试
|
||||
# describe "when choice the peoject number show the user info" do
|
||||
# before{ @userwd = User.new(login: 'wudang',firstname: 'sanfeng',lastname: 'zhang' ,mail: 'user@example.com',
|
||||
# password: 'foobar',password_confirmation: 'foobar' )}
|
||||
# it "when the firstname and lastname is nil " do
|
||||
# expect(@userwd.userInfo).to eq 'wudang (zhang sanfeng)'
|
||||
# end
|
||||
#
|
||||
# end
|
||||
# 返回用户全名的测试
|
||||
it "return full user's name" do
|
||||
expect(@user.show_name).to eq 'zhangsanfeng'
|
||||
end
|
||||
|
||||
# 返回匿名用户方法的测试
|
||||
# User调用其类方法anonymous,返回一个AnonymousUser的实例对象@anonymoususer
|
||||
# 该对象的lastname属性被赋值为"Anonymous",最后对比其值是否相等
|
||||
it "return the anonymous user" do
|
||||
@anonymoususer=AnonymousUser.new
|
||||
@anonymoususer=User.anonymous
|
||||
expect(@anonymoususer.lastname).to eq 'Anonymous'
|
||||
end
|
||||
|
||||
# def name
|
||||
# [firstname, lastname].join(' ')
|
||||
# end
|
||||
# it "returns a contact's full name as a string" do
|
||||
# contact = Contact.new(firstname: 'John', lastname: 'Doe',
|
||||
# email: 'johndoe@example.com')
|
||||
# expect(contact.name).to eq 'John Doe'#调用contact的name方法
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue