This repository has been archived by the owner on Oct 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
/
phone_input_spec.rb
86 lines (65 loc) · 2.29 KB
/
phone_input_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
80
81
82
83
84
85
# encoding: utf-8
require 'spec_helper'
describe 'phone input' do
include FormtasticSpecHelper
before do
@output_buffer = ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:phone))
end)
end
it_should_have_bootstrap_horizontal_wrapping
it_should_have_input_wrapper_with_class(:phone)
it_should_have_input_wrapper_with_class(:input)
it_should_have_input_wrapper_with_class(:stringish)
it_should_have_input_wrapper_with_id("post_phone_input")
it_should_have_label_with_text(/Phone/)
it_should_have_label_for("post_phone")
it_should_have_input_with_id("post_phone")
it_should_have_input_with_type(:tel)
it_should_have_input_with_name("post[phone]")
end
describe "when namespace is provided" do
before do
concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
concat(builder.input(:phone))
end)
end
it_should_have_input_wrapper_with_id("context2_post_phone_input")
it_should_have_label_and_input_with_id("context2_post_phone")
end
describe "when index is provided" do
before do
@output_buffer = ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.fields_for(:author, :index => 3) do |author|
concat(author.input(:name, :as => :phone))
end)
end)
end
it 'should index the id of the control group' do
output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
end
it 'should index the id of the select tag' do
output_buffer.should have_tag("input#post_author_attributes_3_name")
end
it 'should index the name of the select tag' do
output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
end
end
describe "when required" do
it "should add the required attribute to the input's html options" do
with_config :use_required_attribute, true do
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:title, :as => :phone, :required => true))
end)
output_buffer.should have_tag("input[@required]")
end
end
end
end