Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 86 lines (64 sloc) 2.247 kb
73e71b6 @asanghi string type html defaults for newer fields
asanghi authored
1 # encoding: utf-8
2 require 'spec_helper'
3
4 describe 'url input' do
5
6 include FormtasticSpecHelper
7
8 before do
9 @output_buffer = ''
10 mock_everything
11 end
12
13 describe "when object is provided" do
14 before do
39470ee @justinfrench No need for output_buffer.concat(form) any more now that we're only supp...
authored
15 concat(semantic_form_for(@new_post) do |builder|
e0a7874 @asanghi Added auto-guessing and updated some docs
asanghi authored
16 concat(builder.input(:url))
39470ee @justinfrench No need for output_buffer.concat(form) any more now that we're only supp...
authored
17 end)
73e71b6 @asanghi string type html defaults for newer fields
asanghi authored
18 end
19
20 it_should_have_input_wrapper_with_class(:url)
3535c5f @justinfrench add an .input class to all inputs to allow easy styling of all of them
authored
21 it_should_have_input_wrapper_with_class(:input)
9109f7d @justinfrench Added a new "stringish" class to wrapper around all inputs that use Stri...
authored
22 it_should_have_input_wrapper_with_class(:stringish)
73e71b6 @asanghi string type html defaults for newer fields
asanghi authored
23 it_should_have_input_wrapper_with_id("post_url_input")
24 it_should_have_label_with_text(/Url/)
25 it_should_have_label_for("post_url")
26 it_should_have_input_with_id("post_url")
7a47388 @justinfrench remove rails 3 conditional stuff from specs and spec support
authored
27 it_should_have_input_with_type(:url)
73e71b6 @asanghi string type html defaults for newer fields
asanghi authored
28 it_should_have_input_with_name("post[url]")
7444066 @yabawock Whitespace cleanup from HTML5 merge
yabawock authored
29
73e71b6 @asanghi string type html defaults for newer fields
asanghi authored
30 end
31
d174db0 @asanghi change id_prefix to namespace; added documentation in README
asanghi authored
32 describe "when namespace is provided" do
717d8e8 @asanghi full(ish) implementation of namespacing a form's id prefix; more tests r...
asanghi authored
33
34 before do
39470ee @justinfrench No need for output_buffer.concat(form) any more now that we're only supp...
authored
35 concat(semantic_form_for(@new_post, :namespace => "context2") do |builder|
717d8e8 @asanghi full(ish) implementation of namespacing a form's id prefix; more tests r...
asanghi authored
36 concat(builder.input(:url))
39470ee @justinfrench No need for output_buffer.concat(form) any more now that we're only supp...
authored
37 end)
717d8e8 @asanghi full(ish) implementation of namespacing a form's id prefix; more tests r...
asanghi authored
38 end
39
40 it_should_have_input_wrapper_with_id("context2_post_url_input")
41 it_should_have_label_and_input_with_id("context2_post_url")
42
43 end
260674b @justinfrench Add the HTML5 required attribute to all inputs except HiddenInput, resol...
authored
44
253dc6d @justinfrench coverage to assert that fields for with :index works on various inputs, ...
authored
45 describe "when index is provided" do
46
47 before do
48 @output_buffer = ''
49 mock_everything
50
51 concat(semantic_form_for(@new_post) do |builder|
0566774 @jslag address syntax errors with 1.9.2-p290
jslag authored
52 concat(builder.fields_for(:author, :index => 3) do |author|
253dc6d @justinfrench coverage to assert that fields for with :index works on various inputs, ...
authored
53 concat(author.input(:name, :as => :url))
54 end)
55 end)
56 end
57
58 it 'should index the id of the wrapper' do
59 output_buffer.should have_tag("li#post_author_attributes_3_name_input")
60 end
61
62 it 'should index the id of the select tag' do
63 output_buffer.should have_tag("input#post_author_attributes_3_name")
64 end
65
66 it 'should index the name of the select tag' do
67 output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
68 end
69
70 end
71
72
260674b @justinfrench Add the HTML5 required attribute to all inputs except HiddenInput, resol...
authored
73 describe "when required" do
74 it "should add the required attribute to the input's html options" do
7d3bb2f @justinfrench Changed HTML5 configuration defaults from true to false fixes #662
authored
75 with_config :use_required_attribute, true do
76 concat(semantic_form_for(@new_post) do |builder|
77 concat(builder.input(:title, :as => :url, :required => true))
78 end)
79 output_buffer.should have_tag("input[@required]")
80 end
260674b @justinfrench Add the HTML5 required attribute to all inputs except HiddenInput, resol...
authored
81 end
82 end
83
73e71b6 @asanghi string type html defaults for newer fields
asanghi authored
84 end
85
Something went wrong with that request. Please try again.