forked from judgegem/judge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform_builder_spec.rb
79 lines (63 loc) · 2.33 KB
/
form_builder_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require "spec_helper"
describe Judge::FormBuilder do
let(:builder) do
args = [:user, FactoryGirl.build(:user), ActionView::Base.new, {}]
args << nil if Rails::VERSION::MAJOR == 3
Judge::FormBuilder.new(*args)
end
let(:categories) do
category = FactoryGirl.build(:category)
sport = FactoryGirl.build(:sport)
sport.disciplines << FactoryGirl.build_list(:discipline, 3)
category.sports << sport
[category]
end
let(:expected) do
/data\-validate=\"\[.+\]\"/
end
specify "#text_field" do
builder.text_field(:name, :validate => true).should match expected
end
specify "#text_area" do
builder.text_area(:bio, :validate => true).should match expected
end
specify "#password_field" do
builder.password_field(:password, :validate => true).should match expected
end
specify "#check_box" do
builder.check_box(:accepted, :validate => true).should match expected
end
specify "#radio_button" do
builder.radio_button(:gender, "female", :validate => true).should match expected
end
specify "#select" do
builder.select(:country, [["US", "US"], ["GB", "GB"]], :validate => true).should match expected
end
specify "#collection_select" do
cs = builder.collection_select(:team_id, FactoryGirl.create_list(:team, 5), :id, :name, :validate => true)
cs.should match expected
end
specify "#grouped_collection_select" do
gcs = builder.grouped_collection_select(:discipline_id, categories, :sports, :name, :id, :name, :validate => true)
gcs.should match expected
end
specify "#date_select" do
builder.date_select(:dob, :validate => true, :minute_step => 30).should match expected
end
specify "#datetime_select" do
builder.datetime_select(:dob, :validate => true, :minute_step => 30).should match expected
end
specify "#time_select" do
builder.time_select(:dob, :validate => true, :minute_step => 30).should match expected
end
specify "#time_zone_select" do
tzs = builder.time_zone_select(:time_zone, ActiveSupport::TimeZone.us_zones, :include_blank => true, :validate => true)
tzs.should match expected
end
specify "#email_field" do
builder.email_field(:username, :validate => true).should match expected
end
specify "#telephone_field" do
builder.telephone_field(:telephone, :validate => true).should match expected
end
end