rapid-core 0.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +35 -2
- data/Rakefile +77 -48
- data/doc/server.txt +15 -0
- data/features/settings/double-nested/default.feature +2 -2
- data/features/settings/double-nested/validates/presence_of.feature +1 -1
- data/features/settings/nested/default.feature +1 -1
- data/features/settings/nested/validates/presence_of.feature +1 -1
- data/features/settings/not_found.feature +2 -2
- data/features/step_definitions/settings_steps.rb +7 -3
- data/features/step_definitions/template_steps.rb +3 -1
- data/lib/rapid/check.rb +30 -23
- data/lib/rapid/core.rb +12 -0
- data/lib/rapid/error.rb +1 -0
- data/lib/rapid/module.rb +10 -1
- data/lib/rapid/railtie.rb +6 -0
- data/lib/rapid/setting/base.rb +31 -8
- data/lib/rapid/setting/boolean_setting.rb +20 -1
- data/lib/rapid/setting/definer.rb +11 -47
- data/lib/rapid/setting/integer_setting.rb +7 -7
- data/lib/rapid/setting/module.rb +56 -0
- data/lib/rapid/setting/namespace/base.rb +35 -60
- data/lib/rapid/setting/namespace/instance.rb +195 -28
- data/lib/rapid/setting/string_setting.rb +7 -1
- data/lib/rapid/settings.rb +51 -65
- data/lib/rapid/skeleton/base.rb +39 -18
- data/lib/rapid/skeleton/helpers/directory.rb +5 -6
- data/lib/rapid/skeleton/helpers/files.rb +62 -0
- data/lib/rapid/skeleton/helpers/gem.rb +43 -32
- data/lib/rapid/skeleton/helpers/if_setting.rb +44 -0
- data/lib/rapid/skeleton/helpers/migration.rb +102 -32
- data/lib/rapid/skeleton/helpers/route.rb +8 -12
- data/lib/rapid/skeleton/helpers/script.rb +1 -2
- data/lib/rapid/skeleton/helpers/template.rb +23 -25
- data/lib/rapid/skeleton/helpers/view.rb +7 -7
- data/lib/rapid/spec/template.rb +1 -1
- data/lib/rapid/version.rb +1 -1
- data/lib/rapid/web/base.rb +35 -0
- data/lib/rapid/web/bootstrap.rb +98 -0
- data/lib/rapid/web/controller_helpers.rb +60 -0
- data/lib/rapid/web/navigator.rb +18 -0
- data/lib/rapid/web/select_helpers.rb +63 -0
- data/lib/rapid/web/settings_form_builder.rb +205 -0
- data/lib/rapid/web/static_helpers.rb +28 -0
- data/lib/rapid/web/tasks.rb +10 -0
- data/public/rapid/core/bootstrap-collapse.js +136 -0
- data/public/rapid/core/bootstrap-responsive.min.css +3 -0
- data/public/rapid/core/bootstrap.min.css +556 -0
- data/public/rapid/core/jquery-1.7.1.js +9253 -0
- data/public/rapid/core/prettify.css +30 -0
- data/public/rapid/core/prettify.js +28 -0
- data/rapid-core.gemspec +5 -0
- data/spec/rapid/check_spec.rb +11 -4
- data/spec/rapid/module_spec.rb +18 -0
- data/spec/rapid/setting/base_spec.rb +71 -0
- data/spec/rapid/setting/boolean_setting_spec.rb +95 -0
- data/spec/rapid/setting/definer_spec.rb +7 -13
- data/spec/rapid/setting/integer_setting_spec.rb +49 -0
- data/spec/rapid/setting/module_spec.rb +25 -0
- data/spec/rapid/setting/namespace/base_spec.rb +88 -54
- data/spec/rapid/setting/namespace/instance_spec.rb +308 -5
- data/spec/rapid/setting/string_setting_spec.rb +43 -0
- data/spec/rapid/settings_spec.rb +65 -17
- data/spec/rapid/skeleton/base_spec.rb +113 -7
- data/spec/rapid/skeleton/helpers/directory_spec.rb +8 -6
- data/spec/rapid/skeleton/helpers/files_spec.rb +93 -0
- data/spec/rapid/skeleton/helpers/gem_spec.rb +65 -36
- data/spec/rapid/skeleton/helpers/if_setting_spec.rb +110 -0
- data/spec/rapid/skeleton/helpers/migration_spec.rb +190 -1
- data/spec/rapid/skeleton/helpers/route_spec.rb +13 -12
- data/spec/rapid/skeleton/helpers/script_spec.rb +2 -1
- data/spec/rapid/skeleton/helpers/template_spec.rb +22 -35
- data/spec/rapid/spec/template_spec.rb +1 -1
- data/spec/rapid/web/base_spec.rb +33 -0
- data/spec/rapid/web/bootstrap_spec.rb +72 -0
- data/spec/rapid/web/controller_helpers_spec.rb +86 -0
- data/spec/rapid/web/navigator_spec.rb +17 -0
- data/spec/rapid/web/select_helpers_spec.rb +71 -0
- data/spec/rapid/web/settings_form_builder_spec.rb +255 -0
- data/spec/rapid/web/static_helpers_spec.rb +26 -0
- data/spec/spec_helper.rb +3 -0
- data/views/index.erb +11 -0
- data/views/layout.erb +9 -0
- metadata +107 -12
- data/lib/rapid.rb +0 -37
- data/lib/rapid/setting/class_hash.rb +0 -34
- data/lib/rapid/setting/instance_hash.rb +0 -132
- data/lib/rapid/setting/instance_root.rb +0 -107
- data/spec/rapid/setting/instance_root_spec.rb +0 -161
@@ -109,7 +109,7 @@ describe Rapid::Spec::Template do
|
|
109
109
|
|
110
110
|
it "should allow custom implementation of build_skeleton" do
|
111
111
|
@settings = mock("settings", :get_binding => nil)
|
112
|
-
@settings.should_receive(:
|
112
|
+
@settings.should_receive(:load).with("foo" => true)
|
113
113
|
@skeleton = Rapid::Skeleton::Base.new @settings
|
114
114
|
|
115
115
|
@instance = MyClass.new
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Rapid::Web::Base do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Object.class_eval do
|
7
|
+
class MyClass < Rapid::Web::Base
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
@instance = MyClass.new
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
Object.send(:remove_const, :MyClass) rescue nil
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "self.file=" do
|
20
|
+
|
21
|
+
it "should set @gem_path" do
|
22
|
+
MyClass.file = "/foo/lib/bar"
|
23
|
+
MyClass.instance_variable_get(:@gem_path).should == "/foo"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should set @file" do
|
27
|
+
MyClass.file = "/foo/lib/bar"
|
28
|
+
MyClass.instance_variable_get(:@file).should == "/foo/lib/bar"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Rapid::Web::Bootstrap do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Object.class_eval do
|
7
|
+
class MyClass
|
8
|
+
include SinatraMore::TagHelpers
|
9
|
+
include Rapid::Web::Bootstrap
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
@instance = MyClass.new
|
14
|
+
@instance.stub!(:block_is_template?).and_return(false)
|
15
|
+
@instance.stub!(:public_path).and_return(nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
Object.send(:remove_const, :MyClass) rescue nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have head" do
|
23
|
+
@instance.bootstrap_head.class.should == String
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have body" do
|
27
|
+
@instance.should_receive(:capture_html).and_return("HI")
|
28
|
+
@instance.should_receive(:concat_content)
|
29
|
+
|
30
|
+
@instance.bootstrap_body
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have stylesheets" do
|
34
|
+
@instance.bootstrap_stylesheets.class.should == String
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should include application.css in the stylesheets" do
|
38
|
+
@instance.stub!(:public_path).and_return("/foo")
|
39
|
+
@instance.stub!(:rapid_name).and_return("bar")
|
40
|
+
File.should_receive(:exists?).with('/foo/application.css').and_return(true)
|
41
|
+
|
42
|
+
@content = @instance.bootstrap_stylesheets
|
43
|
+
@content.should include %(href="/rapid/bar/application.css")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should have scripts" do
|
47
|
+
@instance.bootstrap_scripts.class.should == String
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should include application.js in the stylesheets" do
|
51
|
+
@instance.stub!(:public_path).and_return("/foo")
|
52
|
+
@instance.stub!(:rapid_name).and_return("bar")
|
53
|
+
File.should_receive(:exists?).with('/foo/application.js').and_return(true)
|
54
|
+
|
55
|
+
@content = @instance.bootstrap_scripts
|
56
|
+
@content.should include %(src="/rapid/bar/application.js")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have topnav" do
|
60
|
+
@instance.bootstrap_topnav.class.should == String
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have flash" do
|
64
|
+
@session = mock('session')
|
65
|
+
@session.should_receive(:delete).with(:notice).and_return("hi")
|
66
|
+
@session.should_receive(:delete).with(:error).and_return("hi")
|
67
|
+
@instance.stub!(:session).and_return(@session)
|
68
|
+
|
69
|
+
@instance.bootstrap_flash.class.should == String
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Rapid::Web::ControllerHelpers do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Object.class_eval do
|
7
|
+
class MyClass
|
8
|
+
include Rapid::Web::ControllerHelpers
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_accessor :rapid_name, :gem_path
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
@instance = MyClass.new
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
Object.send(:remove_const, :MyClass) rescue nil
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "application_path" do
|
25
|
+
|
26
|
+
it "should read it from the ENV" do
|
27
|
+
ENV.should_receive(:[]).with("APP").and_return("foo")
|
28
|
+
@instance.send(:application_path).should == "foo"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have a public path" do
|
34
|
+
MyClass.gem_path = '/gem'
|
35
|
+
MyClass.rapid_name = 'foo'
|
36
|
+
|
37
|
+
@instance.send(:public_path).should == "/gem/public/rapid/foo"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a rapid_name" do
|
41
|
+
MyClass.rapid_name = 'foo'
|
42
|
+
@instance.rapid_name
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have a gem_path" do
|
46
|
+
MyClass.gem_path = 'foo'
|
47
|
+
@instance.gem_path
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "setting_params" do
|
51
|
+
|
52
|
+
def setting_params params, options = {}
|
53
|
+
p = mock('params')
|
54
|
+
p.should_receive(:[]).with(:settings).and_return(params)
|
55
|
+
|
56
|
+
@instance.should_receive(:params).and_return(p)
|
57
|
+
@settings = @instance.send(:setting_params)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should handle nil param" do
|
61
|
+
setting_params(nil).should == nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should filter off namespaces to false" do
|
65
|
+
setting_params("test" => {"on" => "0", "rspec" => {"hi" => "1"}})
|
66
|
+
@settings.should == {"test" => false}
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should filter blank on namespaces to true" do
|
70
|
+
setting_params("test" => {"on" => "1"})
|
71
|
+
@settings.should == {"test" => true}
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should filter blank strings to nil" do
|
75
|
+
setting_params("test" => "")
|
76
|
+
@settings.should == {"test" => nil}
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should remove on setting for non-blank namespaces" do
|
80
|
+
setting_params("test" => {"on" => "1", "rspec" => "1"})
|
81
|
+
@settings.should == {"test" => {"rspec" => "1"}}
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
set :environment, :test
|
4
|
+
|
5
|
+
describe Rapid::Web::Navigator do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
def app
|
9
|
+
Rapid::Web::Navigator
|
10
|
+
end
|
11
|
+
|
12
|
+
it "/rapid without any middleware" do
|
13
|
+
get '/rapid'
|
14
|
+
last_response.should be_ok
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Rapid::Web::SelectHelpers do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Object.class_eval do
|
7
|
+
class MyClass
|
8
|
+
include SinatraMore::TagHelpers
|
9
|
+
include Rapid::Web::SelectHelpers
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
@instance = MyClass.new
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
Object.send(:remove_const, :MyClass) rescue nil
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "options_for_select" do
|
21
|
+
|
22
|
+
it "should handle blank options" do
|
23
|
+
@instance.options_for_select([]).should == ""
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should select the option even with parenthesises" do
|
27
|
+
@instance.should_receive(:block_is_template?).twice.and_return(false)
|
28
|
+
|
29
|
+
@content = @instance.options_for_select(["hi (hi)", "hey"], ["hi (hi)"])
|
30
|
+
|
31
|
+
@content.should include %(value="hi (hi)")
|
32
|
+
@content.should include %(value="hey")
|
33
|
+
@content.should include %(selected="selected")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "time_zone_select" do
|
39
|
+
|
40
|
+
before do
|
41
|
+
@instance.stub!(:block_is_template?).and_return(false)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should work with no options" do
|
45
|
+
@value = @instance.time_zone_select(:zone)
|
46
|
+
@value.should include %(<select name="zone">)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should accept priority zones" do
|
50
|
+
@value = @instance.time_zone_select(:zone, :priority => ActiveSupport::TimeZone.us_zones)
|
51
|
+
@value.should include %(<select name="zone"><option value="Hawaii">(GMT-10:00) Hawaii</option)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should accept priority zones as a regex" do
|
55
|
+
@value = @instance.time_zone_select(:zone, :priority => /Eastern/)
|
56
|
+
@value.should include %(<select name="zone"><option value="Eastern Time (US & Canada)")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should select a timezone" do
|
60
|
+
@value = @instance.time_zone_select(:zone, :selected => "Eastern Time (US & Canada)")
|
61
|
+
@value.should include %(selected="selected")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should include a blank timezone" do
|
65
|
+
@value = @instance.time_zone_select(:zone, :include_blank => true)
|
66
|
+
@value.should include %(<select name="zone"><option value=""></option>)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Rapid::Web::SettingsFormBuilder do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Object.class_eval do
|
7
|
+
class MyClass
|
8
|
+
include SinatraMore::TagHelpers
|
9
|
+
include SinatraMore::FormHelpers
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
@template = MyClass.new
|
14
|
+
@object = mock('object')
|
15
|
+
@builder = Rapid::Web::SettingsFormBuilder.new @template, @object
|
16
|
+
@builder.object_name = "settings"
|
17
|
+
|
18
|
+
@template.stub!(:block_is_template?).and_return(false)
|
19
|
+
@template.stub!(:configured_form_builder_class).and_return(Rapid::Web::SettingsFormBuilder)
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
Object.send(:remove_const, :MyClass) rescue nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should remove the dot-notation when making a label" do
|
27
|
+
@content = @builder.label("test.rspec")
|
28
|
+
|
29
|
+
@content.should include %(for="settings_test_rspec")
|
30
|
+
@content.should include %(>Rspec: )
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should accept a symbol for a label" do
|
34
|
+
@content = @builder.label(:foo)
|
35
|
+
|
36
|
+
@content.should include %(for="settings_foo")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should #fields_for" do
|
40
|
+
@template.should_receive(:capture_html).and_return("HI")
|
41
|
+
@template.should_receive(:concat_content).with("HI")
|
42
|
+
@object.should_receive(:foo).and_return("foo" => "bar")
|
43
|
+
|
44
|
+
@builder.fields_for(:foo)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should #section" do
|
48
|
+
@template.should_receive(:capture_html).and_return("HI")
|
49
|
+
@template.should_receive(:concat_content) {|c| @content = c }
|
50
|
+
|
51
|
+
@builder.section("foo")
|
52
|
+
|
53
|
+
@content.should include %(id="section_foo")
|
54
|
+
@content.should include %(class="toggle-section")
|
55
|
+
@content.should include "HI"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should hidden #settings" do
|
59
|
+
@template.should_receive(:capture_html).and_return("HI")
|
60
|
+
@template.should_receive(:concat_content) {|c| @content = c }
|
61
|
+
|
62
|
+
@object.should_receive(:[]).with('foo').and_return(nil)
|
63
|
+
|
64
|
+
@builder.settings("foo")
|
65
|
+
|
66
|
+
@content.should include %(class="subsettings settings-off")
|
67
|
+
@content.should include "HI"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should shown #settings" do
|
71
|
+
@template.should_receive(:capture_html).and_return("HI")
|
72
|
+
@template.should_receive(:concat_content) {|c| @content = c }
|
73
|
+
|
74
|
+
setting = mock("setting")
|
75
|
+
setting.should_receive(:respond_to?).with(:on?).and_return(true)
|
76
|
+
setting.should_receive(:on?).and_return(true)
|
77
|
+
@object.should_receive(:[]).with('foo').and_return(setting)
|
78
|
+
|
79
|
+
@builder.settings("foo")
|
80
|
+
|
81
|
+
@content.should include %(class="subsettings")
|
82
|
+
@content.should include "HI"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should #control_group" do
|
86
|
+
@template.should_receive(:capture_html).and_return("HI")
|
87
|
+
@template.should_receive(:concat_content) {|c| @content = c }
|
88
|
+
|
89
|
+
@builder.control_group("foo")
|
90
|
+
|
91
|
+
@content.should include %(id="settings_foo_group")
|
92
|
+
@content.should include %(label for="settings_foo")
|
93
|
+
@content.should include %(HI)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should turn the checkbox on if the namespace is on" do
|
97
|
+
@object.should_receive(:[]).with('test.cucumber.on').and_return(true)
|
98
|
+
@object.should_receive(:[]).with('test.cucumber').and_return(mock('rspec', :on? => true))
|
99
|
+
@builder.object_name = "settings"
|
100
|
+
|
101
|
+
@content = @builder.check_box 'test.cucumber.on'
|
102
|
+
|
103
|
+
@content.should include %(type="hidden")
|
104
|
+
@content.should include %(id="settings_test_cucumber_on")
|
105
|
+
@content.should include %(name="settings[test][cucumber][on]")
|
106
|
+
@content.should include %(value="0")
|
107
|
+
@content.should include %(value="1")
|
108
|
+
@content.should include %(checked="checked")
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "field helpers" do
|
112
|
+
|
113
|
+
before do
|
114
|
+
@object.should_receive(:[]).with('test.rspec').and_return('hi')
|
115
|
+
@builder.object_name = "settings"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should #text_field" do
|
119
|
+
@content = @builder.text_field 'test.rspec'
|
120
|
+
|
121
|
+
@content.should include %(type="text")
|
122
|
+
@content.should include %(id="settings_test_rspec")
|
123
|
+
@content.should include %(name="settings[test][rspec]")
|
124
|
+
@content.should include %(value="hi")
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should #password_field" do
|
128
|
+
@content = @builder.password_field 'test.rspec'
|
129
|
+
|
130
|
+
@content.should include %(type="password")
|
131
|
+
@content.should include %(id="settings_test_rspec")
|
132
|
+
@content.should include %(name="settings[test][rspec]")
|
133
|
+
@content.should include %(value="hi")
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should #text_area" do
|
137
|
+
@content = @builder.text_area 'test.rspec'
|
138
|
+
|
139
|
+
@content.should include %(<textarea)
|
140
|
+
@content.should include %(id="settings_test_rspec")
|
141
|
+
@content.should include %(name="settings[test][rspec]")
|
142
|
+
@content.should include %(>hi</textarea>)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should #select" do
|
146
|
+
@content = @builder.select 'test.rspec', :options => %w(hi hey)
|
147
|
+
|
148
|
+
@content.should include %(<select)
|
149
|
+
@content.should include %(id="settings_test_rspec")
|
150
|
+
@content.should include %(name="settings[test][rspec]")
|
151
|
+
@content.should include %(selected="selected")
|
152
|
+
@content.should include %(<option value="hey">hey</option>)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should #check_box" do
|
156
|
+
@content = @builder.check_box 'test.rspec'
|
157
|
+
|
158
|
+
@content.should include %(type="hidden")
|
159
|
+
@content.should include %(id="settings_test_rspec")
|
160
|
+
@content.should include %(name="settings[test][rspec]")
|
161
|
+
@content.should include %(value="0")
|
162
|
+
@content.should include %(value="1")
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should #radio_button" do
|
166
|
+
@content = @builder.radio_button 'test.rspec'
|
167
|
+
|
168
|
+
@content.should include %(type="radio")
|
169
|
+
@content.should include %(id="settings_test_rspec")
|
170
|
+
@content.should include %(name="settings[test][rspec]")
|
171
|
+
@content.should include %(selected="selected")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should #file_field" do
|
175
|
+
@content = @builder.file_field 'test.rspec'
|
176
|
+
|
177
|
+
@content.should include %(type="file")
|
178
|
+
@content.should include %(id="settings_test_rspec")
|
179
|
+
@content.should include %(name="settings[test][rspec]")
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should #time_zone_select" do
|
183
|
+
@template.should_receive(:time_zone_select).with('settings[test][rspec]', {:selected=>"", :value => "hi", :id => "settings_test_rspec"})
|
184
|
+
|
185
|
+
@content = @builder.time_zone_select 'test.rspec'
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "control group fields" do
|
191
|
+
|
192
|
+
before do
|
193
|
+
@field = "foo"
|
194
|
+
@options = {"foo" => "bar"}
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should #control_group_text_field" do
|
198
|
+
@builder.should_receive(:control_group_field).with(:text_field, @field, @options)
|
199
|
+
@builder.control_group_text_field @field, @options
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should #control_group_text_area" do
|
203
|
+
@builder.should_receive(:control_group_field).with(:text_area, @field, @options)
|
204
|
+
@builder.control_group_text_area @field, @options
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should #control_group_password_field" do
|
208
|
+
@builder.should_receive(:control_group_field).with(:password_field, @field, @options)
|
209
|
+
@builder.control_group_password_field @field, @options
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should #control_group_select" do
|
213
|
+
@builder.should_receive(:control_group_field).with(:select, @field, @options)
|
214
|
+
@builder.control_group_select @field, @options
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should #control_group_check_box" do
|
218
|
+
@builder.should_receive(:control_group_field).with(:check_box, @field, @options)
|
219
|
+
@builder.control_group_check_box @field, @options
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should #control_group_radio_button" do
|
223
|
+
@builder.should_receive(:control_group_field).with(:radio_button, @field, @options)
|
224
|
+
@builder.control_group_radio_button @field, @options
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should #control_group_file_field" do
|
228
|
+
@builder.should_receive(:control_group_field).with(:file_field, @field, @options)
|
229
|
+
@builder.control_group_file_field @field, @options
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should #control_group_time_zone_select" do
|
233
|
+
@builder.should_receive(:control_group_field).with(:time_zone_select, @field, @options)
|
234
|
+
@builder.control_group_time_zone_select @field, @options
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should generate a control field" do
|
240
|
+
@object.should_receive(:[]).with('test.rspec').and_return("hi")
|
241
|
+
@content = @builder.send(:control_group_field, :text_field, "test.rspec", {:size => :large})
|
242
|
+
|
243
|
+
@content.should include %(class="control-group")
|
244
|
+
@content.should include %(id="settings_test_rspec_group")
|
245
|
+
@content.should include %(for="settings_test_rspec")
|
246
|
+
@content.should include %(name="settings[test][rspec]")
|
247
|
+
@content.should include %(id="settings_test_rspec")
|
248
|
+
@content.should include %(class="input input-large")
|
249
|
+
end
|
250
|
+
|
251
|
+
it "should generate the setting_id for a symbol" do
|
252
|
+
@builder.send(:setting_id, :foo).should == "settings_foo"
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|