rapid-core 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +53 -0
- data/Rakefile +61 -0
- data/cucumber.yml +3 -0
- data/doc/plan.txt +89 -0
- data/doc/scaffold/controller.rb +83 -0
- data/doc/scaffold/helper.rb +2 -0
- data/doc/scaffold/model.rb +5 -0
- data/doc/scaffold/rapid_scaffold.rb +5 -0
- data/doc/scaffold/views/_form.html.erb +25 -0
- data/doc/scaffold/views/edit.html.erb +6 -0
- data/doc/scaffold/views/index.html.erb +25 -0
- data/doc/scaffold/views/new.html.erb +5 -0
- data/doc/scaffold/views/show.html.erb +15 -0
- data/features/settings/boolean/default.feature +36 -0
- data/features/settings/double-nested/default.feature +50 -0
- data/features/settings/double-nested/if.feature +41 -0
- data/features/settings/double-nested/unless.feature +39 -0
- data/features/settings/double-nested/validates/exclusion_of.feature +30 -0
- data/features/settings/double-nested/validates/format_of.feature +30 -0
- data/features/settings/double-nested/validates/inclusion_of.feature +30 -0
- data/features/settings/double-nested/validates/length_of.feature +30 -0
- data/features/settings/double-nested/validates/presence_of.feature +37 -0
- data/features/settings/double-nested/validates/size_of.feature +30 -0
- data/features/settings/integer/default.feature +49 -0
- data/features/settings/nested/default.feature +50 -0
- data/features/settings/nested/if.feature +53 -0
- data/features/settings/nested/unless.feature +32 -0
- data/features/settings/nested/validates/exclusion_of.feature +30 -0
- data/features/settings/nested/validates/format_of.feature +30 -0
- data/features/settings/nested/validates/inclusion_of.feature +30 -0
- data/features/settings/nested/validates/length_of.feature +30 -0
- data/features/settings/nested/validates/presence_of.feature +37 -0
- data/features/settings/nested/validates/size_of.feature +30 -0
- data/features/settings/not_found.feature +33 -0
- data/features/settings/string/default.feature +36 -0
- data/features/settings/string/validates/exclusion_of.feature +30 -0
- data/features/settings/string/validates/format_of.feature +30 -0
- data/features/settings/string/validates/inclusion_of.feature +30 -0
- data/features/settings/string/validates/length_of.feature +30 -0
- data/features/settings/string/validates/presence_of.feature +37 -0
- data/features/settings/string/validates/size_of.feature +30 -0
- data/features/step_definitions/settings_steps.rb +92 -0
- data/features/step_definitions/skeleton_steps.rb +68 -0
- data/features/step_definitions/template_steps.rb +39 -0
- data/features/support/env.rb +6 -0
- data/features/templates/comment_if.feature +55 -0
- data/features/templates/comment_unless.feature +56 -0
- data/features/templates/for/for.feature +51 -0
- data/features/templates/if/else.feature +60 -0
- data/features/templates/if/elsif.feature +82 -0
- data/features/templates/if/if.feature +55 -0
- data/features/templates/namespaces/exist.feature +54 -0
- data/features/templates/static.feature +37 -0
- data/features/templates/variables.feature +61 -0
- data/lib/rapid/check.rb +162 -0
- data/lib/rapid/core.rb +37 -0
- data/lib/rapid/error.rb +84 -0
- data/lib/rapid/module.rb +35 -0
- data/lib/rapid/railtie.rb +18 -0
- data/lib/rapid/setting/base.rb +35 -0
- data/lib/rapid/setting/boolean_setting.rb +17 -0
- data/lib/rapid/setting/class_hash.rb +34 -0
- data/lib/rapid/setting/comments.rb +25 -0
- data/lib/rapid/setting/definer.rb +151 -0
- data/lib/rapid/setting/instance_hash.rb +132 -0
- data/lib/rapid/setting/instance_root.rb +107 -0
- data/lib/rapid/setting/integer_setting.rb +24 -0
- data/lib/rapid/setting/namespace/base.rb +113 -0
- data/lib/rapid/setting/namespace/instance.rb +84 -0
- data/lib/rapid/setting/nested_validations.rb +86 -0
- data/lib/rapid/setting/string_setting.rb +13 -0
- data/lib/rapid/settings.rb +129 -0
- data/lib/rapid/skeleton/base.rb +164 -0
- data/lib/rapid/skeleton/helpers/directory.rb +53 -0
- data/lib/rapid/skeleton/helpers/gem.rb +133 -0
- data/lib/rapid/skeleton/helpers/migration.rb +46 -0
- data/lib/rapid/skeleton/helpers/route.rb +115 -0
- data/lib/rapid/skeleton/helpers/script.rb +33 -0
- data/lib/rapid/skeleton/helpers/template.rb +73 -0
- data/lib/rapid/skeleton/helpers/view.rb +35 -0
- data/lib/rapid/spec/template.rb +104 -0
- data/lib/rapid/spec.rb +1 -0
- data/lib/rapid/tasks.rb +29 -0
- data/lib/rapid/template/base.rb +49 -0
- data/lib/rapid/template/node/base.rb +43 -0
- data/lib/rapid/template/node/comment_node.rb +42 -0
- data/lib/rapid/template/node/if_node.rb +109 -0
- data/lib/rapid/template/node/root.rb +51 -0
- data/lib/rapid/template/node/static.rb +29 -0
- data/lib/rapid/template/node/variable.rb +86 -0
- data/lib/rapid/template/parser.rb +167 -0
- data/lib/rapid/template/pulling/base.rb +91 -0
- data/lib/rapid/template/pulling/explicit.rb +92 -0
- data/lib/rapid/template/pulling/forgiving.rb +58 -0
- data/lib/rapid/version.rb +3 -0
- data/lib/rapid.rb +37 -0
- data/rapid-core.gemspec +26 -0
- data/spec/rapid/check_spec.rb +119 -0
- data/spec/rapid/error_spec.rb +14 -0
- data/spec/rapid/module_spec.rb +28 -0
- data/spec/rapid/setting/base_spec.rb +17 -0
- data/spec/rapid/setting/definer_spec.rb +318 -0
- data/spec/rapid/setting/instance_root_spec.rb +161 -0
- data/spec/rapid/setting/namespace/base_spec.rb +93 -0
- data/spec/rapid/setting/namespace/instance_spec.rb +12 -0
- data/spec/rapid/setting/nested_validations_spec.rb +72 -0
- data/spec/rapid/settings_spec.rb +51 -0
- data/spec/rapid/skeleton/base_spec.rb +224 -0
- data/spec/rapid/skeleton/helpers/directory_spec.rb +104 -0
- data/spec/rapid/skeleton/helpers/gem_spec.rb +180 -0
- data/spec/rapid/skeleton/helpers/migration_spec.rb +23 -0
- data/spec/rapid/skeleton/helpers/route_spec.rb +120 -0
- data/spec/rapid/skeleton/helpers/script_spec.rb +57 -0
- data/spec/rapid/skeleton/helpers/template_spec.rb +142 -0
- data/spec/rapid/skeleton/helpers/view_spec.rb +54 -0
- data/spec/rapid/spec/template_spec.rb +168 -0
- data/spec/rapid/template/base_spec.rb +290 -0
- data/spec/rapid/template/node/base_spec.rb +9 -0
- data/spec/rapid/template/node/comment_node_spec.rb +46 -0
- data/spec/rapid/template/node/if_node_spec.rb +28 -0
- data/spec/rapid/template/node/root_spec.rb +9 -0
- data/spec/rapid/template/node/static_spec.rb +17 -0
- data/spec/rapid/template/node/variable_spec.rb +87 -0
- data/spec/rapid/template/parser_spec.rb +187 -0
- data/spec/rapid/template/pulling/base_spec.rb +81 -0
- data/spec/rapid/template/pulling/explicit_spec.rb +33 -0
- data/spec/rapid/template/pulling/forgiving_spec.rb +132 -0
- data/spec/spec_helper.rb +10 -0
- metadata +325 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rapid-core (0.1)
|
5
|
+
activemodel (>= 3.0)
|
6
|
+
activesupport (>= 3.0)
|
7
|
+
erubis
|
8
|
+
i18n
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activemodel (3.2.1)
|
14
|
+
activesupport (= 3.2.1)
|
15
|
+
builder (~> 3.0.0)
|
16
|
+
activesupport (3.2.1)
|
17
|
+
i18n (~> 0.6)
|
18
|
+
multi_json (~> 1.0)
|
19
|
+
builder (3.0.0)
|
20
|
+
cucumber (1.1.4)
|
21
|
+
builder (>= 2.1.2)
|
22
|
+
diff-lcs (>= 1.1.2)
|
23
|
+
gherkin (~> 2.7.1)
|
24
|
+
json (>= 1.4.6)
|
25
|
+
term-ansicolor (>= 1.0.6)
|
26
|
+
diff-lcs (1.1.3)
|
27
|
+
erubis (2.7.0)
|
28
|
+
gherkin (2.7.4)
|
29
|
+
json (>= 1.4.6)
|
30
|
+
i18n (0.6.0)
|
31
|
+
json (1.6.5)
|
32
|
+
multi_json (1.0.4)
|
33
|
+
rake (0.9.2.2)
|
34
|
+
rcov (0.9.9)
|
35
|
+
rspec (2.5.0)
|
36
|
+
rspec-core (~> 2.5.0)
|
37
|
+
rspec-expectations (~> 2.5.0)
|
38
|
+
rspec-mocks (~> 2.5.0)
|
39
|
+
rspec-core (2.5.1)
|
40
|
+
rspec-expectations (2.5.0)
|
41
|
+
diff-lcs (~> 1.1.2)
|
42
|
+
rspec-mocks (2.5.0)
|
43
|
+
term-ansicolor (1.0.7)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
cucumber
|
50
|
+
rake
|
51
|
+
rapid-core!
|
52
|
+
rcov
|
53
|
+
rspec
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new('spec')
|
5
|
+
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
namespace :cucumber do
|
9
|
+
Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
|
10
|
+
# t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
11
|
+
t.fork = true # You may get faster startup if you set this to false
|
12
|
+
t.profile = 'default'
|
13
|
+
end
|
14
|
+
|
15
|
+
Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
|
16
|
+
# t.binary = vendored_cucumber_bin
|
17
|
+
t.fork = true # You may get faster startup if you set this to false
|
18
|
+
t.profile = 'wip'
|
19
|
+
end
|
20
|
+
|
21
|
+
Cucumber::Rake::Task.new(:rerun, 'Record failing features and run only them if any exist') do |t|
|
22
|
+
# t.binary = vendored_cucumber_bin
|
23
|
+
t.fork = true # You may get faster startup if you set this to false
|
24
|
+
t.profile = 'rerun'
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Run all features'
|
28
|
+
task :all => [:ok, :wip]
|
29
|
+
end
|
30
|
+
desc 'Alias for cucumber:ok'
|
31
|
+
task :cucumber => 'cucumber:ok'
|
32
|
+
|
33
|
+
namespace :rcov do
|
34
|
+
|
35
|
+
rcov_opts = '--exclude osx\/objc,cucumber.rb,cucumber\/,gems\/,spec\/,features\/ --aggregate coverage.data'
|
36
|
+
|
37
|
+
desc "Run all specs with rcov"
|
38
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
39
|
+
t.rcov = true
|
40
|
+
t.pattern = "./spec/**/*_spec.rb"
|
41
|
+
t.rcov_opts = rcov_opts
|
42
|
+
end
|
43
|
+
|
44
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features and produce a coverage report') do |t|
|
45
|
+
# t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
46
|
+
t.fork = true # You may get faster startup if you set this to false
|
47
|
+
t.profile = 'default'
|
48
|
+
t.rcov = true
|
49
|
+
t.rcov_opts = "#{rcov_opts} --failure-threshold 100"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Run specs and features and produce a coverage report"
|
53
|
+
task :all do
|
54
|
+
rm "coverage.data" if File.exist?("coverage.data")
|
55
|
+
Rake::Task['rcov:spec'].invoke
|
56
|
+
Rake::Task["rcov:cucumber"].invoke
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
task :ci => 'rcov:all'
|
data/cucumber.yml
ADDED
data/doc/plan.txt
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
***************************
|
2
|
+
***** PURPOSE *****
|
3
|
+
***************************
|
4
|
+
|
5
|
+
- Rails development: easier, faster, better
|
6
|
+
|
7
|
+
- common tasks are done easier easier
|
8
|
+
- common tasks are done "the rails way"
|
9
|
+
- common tasks are done faster
|
10
|
+
|
11
|
+
- aide learning
|
12
|
+
- show the console command when doing something in the UI
|
13
|
+
- help you visualize the project
|
14
|
+
- help you avoid digging through documentation
|
15
|
+
|
16
|
+
- decrease cognitive load
|
17
|
+
|
18
|
+
|
19
|
+
***************************
|
20
|
+
***** PROJ STRUCTURE *****
|
21
|
+
***************************
|
22
|
+
|
23
|
+
/config/rapid.rb
|
24
|
+
|
25
|
+
- holds code to run rapid checks
|
26
|
+
|
27
|
+
/lib/rapid
|
28
|
+
- holds your custom skeletons
|
29
|
+
|
30
|
+
|
31
|
+
***************************
|
32
|
+
***** TASKS STRUCTURE *****
|
33
|
+
***************************
|
34
|
+
|
35
|
+
rake rapid:check
|
36
|
+
- checks that no skeleton has been violated
|
37
|
+
- used in project's continuous integration
|
38
|
+
|
39
|
+
hijack script/rails server
|
40
|
+
- plus username/password file
|
41
|
+
|
42
|
+
|
43
|
+
***************************
|
44
|
+
**** PUBLIC INTERFACE *****
|
45
|
+
***************************
|
46
|
+
|
47
|
+
Rapid.config.filename = 'config/rapid.rb'
|
48
|
+
Rapid.config.route = '/rapid'
|
49
|
+
|
50
|
+
|
51
|
+
***************************
|
52
|
+
**** RAILS INTEGRATION ****
|
53
|
+
***************************
|
54
|
+
|
55
|
+
- gem 'rapid', :group => :development
|
56
|
+
|
57
|
+
- in server mode
|
58
|
+
|
59
|
+
- adds routes /rapid
|
60
|
+
- /rapid [list of plugins+descr like sendgrid]
|
61
|
+
- /rapid/git [commit, merge, push, pull code]
|
62
|
+
- /rapid/ide [modify your project files]
|
63
|
+
- /rapid/debug [use ruby-debug to step through a request]
|
64
|
+
- /rapid/db [create and run migrations]
|
65
|
+
- /rapid/users [manage who can access your dev server, along with auto-signin via token]
|
66
|
+
- /rapid/docs [access to gem documentation, etc]
|
67
|
+
- /rapid/logs [visually browse the request logs]
|
68
|
+
- /rapid/email [catch email and place it in a gmail-like view with a "send" button]
|
69
|
+
- /rapid/console [type into the console!]
|
70
|
+
- /rapid/jobs [??]
|
71
|
+
- /rapid/fix [UI to fix your rapid files, show project code and template side-by-side]
|
72
|
+
- /rapid/docs [visually edit the /docs directory]
|
73
|
+
- /rapid/features [visually edit the cucumber features]
|
74
|
+
- /rapid/errors [linked from dev error screen, helps you figure out the cause and tell others how you solved it]
|
75
|
+
- /rapid/more [look up more rapid gems to add]
|
76
|
+
|
77
|
+
- adds before_filter
|
78
|
+
- prompt for restart if any files requiring a restart have been modified
|
79
|
+
- prompt to run migrations if pending migrations
|
80
|
+
- prompt for password if needed
|
81
|
+
- require SSL if needed
|
82
|
+
|
83
|
+
account, user
|
84
|
+
|
85
|
+
facebook, twitter, linkedin, twello, github
|
86
|
+
|
87
|
+
oauth
|
88
|
+
|
89
|
+
MVC
|
@@ -0,0 +1,83 @@
|
|
1
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
+
# GET <%= route_path %>
|
3
|
+
# GET <%= route_path %>.json
|
4
|
+
def index
|
5
|
+
@<%= records_variable_name %> = <%= model_class_name %>.all
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.json { render :json => @<%= records_variable_name %> }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET <%= route_path %>/1
|
14
|
+
# GET <%= route_path %>/1.json
|
15
|
+
def show
|
16
|
+
@<%= record_variable_name %> = <%= model_class_name %>.find(params[:id])
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.json { render :json => @<%= record_variable_name %> }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET <%= route_path %>/new
|
25
|
+
# GET <%= route_path %>/new.json
|
26
|
+
def new
|
27
|
+
@<%= record_variable_name %> = <%= model_class_name %>.new
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.json { render :json => @<%= record_variable_name %> }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET <%= route_path %>/1/edit
|
36
|
+
def edit
|
37
|
+
@<%= record_variable_name %> = <%= model_class_name %>.find(params[:id])
|
38
|
+
end
|
39
|
+
|
40
|
+
# POST <%= route_path %>
|
41
|
+
# POST <%= route_path %>.json
|
42
|
+
def create
|
43
|
+
@<%= record_variable_name %> = <%= model_class_name %>.new(params[:<%= parameter_name %>])
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
if @<%= record_variable_name %>.save
|
47
|
+
format.html { redirect_to @<%= record_variable_name %>, :notice => '<%= model_readable_name %> was successfully created.' }
|
48
|
+
format.json { render :json => @<%= record_variable_name %>, :status => :created, :location => @<%= record_variable_name %> }
|
49
|
+
else
|
50
|
+
format.html { render :action => "new" }
|
51
|
+
format.json { render :json => @<%= record_variable_name %>.errors, :status => :unprocessable_entity }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# PUT <%= route_path %>/1
|
57
|
+
# PUT <%= route_path %>/1.json
|
58
|
+
def update
|
59
|
+
@<%= record_variable_name %> = <%= model_class_name %>.find(params[:id])
|
60
|
+
|
61
|
+
respond_to do |format|
|
62
|
+
if @<%= record_variable_name %>.update_attributes(params[:<%= parameter_name %>])
|
63
|
+
format.html { redirect_to @<%= record_variable_name %>, :notice => '<%= model_readable_name %> was successfully updated.' }
|
64
|
+
format.json { head :ok }
|
65
|
+
else
|
66
|
+
format.html { render :action => "edit" }
|
67
|
+
format.json { render :json => @<%= record_variable_name %>.errors, :status => :unprocessable_entity }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# DELETE <%= route_path %>/1
|
73
|
+
# DELETE <%= route_path %>/1.json
|
74
|
+
def destroy
|
75
|
+
@<%= record_variable_name %> = <%= model_class_name %>.find(params[:id])
|
76
|
+
@<%= record_variable_name %>.destroy
|
77
|
+
|
78
|
+
respond_to do |format|
|
79
|
+
format.html { redirect_to url_for(:action => :index) }
|
80
|
+
format.json { head :ok }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%%= form_for(@club) do |f| %>
|
2
|
+
<%% if @club.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%%= pluralize(@club.errors.count, "error") %> prohibited this club from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<%% @club.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%%= msg %></li>
|
9
|
+
<%% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<%% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%%= f.label :name %><br />
|
16
|
+
<%%= f.text_field :name %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%%= f.label :exclusive %><br />
|
20
|
+
<%%= f.check_box :exclusive %>
|
21
|
+
</div>
|
22
|
+
<div class="actions">
|
23
|
+
<%%= f.submit %>
|
24
|
+
</div>
|
25
|
+
<%% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<h1>Listing clubs</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Exclusive</th>
|
7
|
+
<th></th>
|
8
|
+
<th></th>
|
9
|
+
<th></th>
|
10
|
+
</tr>
|
11
|
+
|
12
|
+
<%% @clubs.each do |club| %>
|
13
|
+
<tr>
|
14
|
+
<td><%%= club.name %></td>
|
15
|
+
<td><%%= club.exclusive %></td>
|
16
|
+
<td><%%= link_to 'Show', club %></td>
|
17
|
+
<td><%%= link_to 'Edit', edit_club_path(club) %></td>
|
18
|
+
<td><%%= link_to 'Destroy', club, :confirm => 'Are you sure?', :method => :delete %></td>
|
19
|
+
</tr>
|
20
|
+
<%% end %>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<br />
|
24
|
+
|
25
|
+
<%%= link_to 'New Club', new_club_path %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: Default boolean
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given settings "my_settings.rb":
|
5
|
+
"""
|
6
|
+
class MySettings
|
7
|
+
include Rapid::Settings
|
8
|
+
|
9
|
+
setting.boolean :is_admin
|
10
|
+
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
|
14
|
+
Scenario: true value
|
15
|
+
When I load:
|
16
|
+
"""
|
17
|
+
is_admin: true
|
18
|
+
"""
|
19
|
+
Then I should be good
|
20
|
+
And vice versa
|
21
|
+
|
22
|
+
Scenario: false value
|
23
|
+
When I load:
|
24
|
+
"""
|
25
|
+
is_admin: false
|
26
|
+
"""
|
27
|
+
Then I should be good
|
28
|
+
And vice versa
|
29
|
+
|
30
|
+
Scenario: nil value
|
31
|
+
When I load:
|
32
|
+
"""
|
33
|
+
"""
|
34
|
+
Then I should be good
|
35
|
+
And vice versa
|
36
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Feature: Default double nesting
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given settings "my_settings.rb":
|
5
|
+
"""
|
6
|
+
class MySettings
|
7
|
+
include Rapid::Settings
|
8
|
+
|
9
|
+
setting.string "app.author.name"
|
10
|
+
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
|
14
|
+
Scenario: Non-blank value
|
15
|
+
When I load:
|
16
|
+
"""
|
17
|
+
app.author.name: Dan
|
18
|
+
"""
|
19
|
+
Then I should be good
|
20
|
+
And vice versa
|
21
|
+
|
22
|
+
Scenario: nil value
|
23
|
+
When I load:
|
24
|
+
"""
|
25
|
+
"""
|
26
|
+
Then I should be good
|
27
|
+
And vice versa
|
28
|
+
|
29
|
+
Scenario: nested blank value
|
30
|
+
When I load:
|
31
|
+
"""
|
32
|
+
app.author:
|
33
|
+
"""
|
34
|
+
Then I should be good
|
35
|
+
# And vice versa # TODO
|
36
|
+
|
37
|
+
Scenario: blank value
|
38
|
+
When I load:
|
39
|
+
"""
|
40
|
+
app.author.name:
|
41
|
+
"""
|
42
|
+
Then I should be good
|
43
|
+
And vice versa
|
44
|
+
|
45
|
+
Scenario: integer value
|
46
|
+
When I load:
|
47
|
+
"""
|
48
|
+
app.author: 1
|
49
|
+
"""
|
50
|
+
Then "app.author" should have a "doesn't allow values of that type" error
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Feature: Default double nesting if
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given settings "my_settings.rb":
|
5
|
+
"""
|
6
|
+
class MySettings
|
7
|
+
include Rapid::Settings
|
8
|
+
|
9
|
+
setting.integer "app.emails.smtp.port"
|
10
|
+
setting.string "app.name"
|
11
|
+
|
12
|
+
validates_presence_of "app.emails.smtp.port", :if => '_root.app.name'
|
13
|
+
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
|
17
|
+
Scenario: False if
|
18
|
+
When I load:
|
19
|
+
"""
|
20
|
+
|
21
|
+
"""
|
22
|
+
Then I should be good
|
23
|
+
And vice versa
|
24
|
+
|
25
|
+
Scenario: True if and valid
|
26
|
+
When I load:
|
27
|
+
"""
|
28
|
+
app.name: Rapid
|
29
|
+
app.emails.smtp.port: 587
|
30
|
+
"""
|
31
|
+
Then I should be good
|
32
|
+
And vice versa
|
33
|
+
|
34
|
+
Scenario: True if and invalid
|
35
|
+
When I load:
|
36
|
+
"""
|
37
|
+
app.name: Rapid
|
38
|
+
"""
|
39
|
+
Then "app.emails.smtp.port" should have a "can't be blank" error
|
40
|
+
And vice versa
|
41
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: Default double nesting unless
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given settings "my_settings.rb":
|
5
|
+
"""
|
6
|
+
class MySettings
|
7
|
+
include Rapid::Settings
|
8
|
+
|
9
|
+
setting.integer "app.emails.smtp.port"
|
10
|
+
setting.string "app.name"
|
11
|
+
|
12
|
+
validates_presence_of "app.emails.smtp.port", :unless => '_root.app.name'
|
13
|
+
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
|
17
|
+
Scenario: False unless
|
18
|
+
When I load:
|
19
|
+
"""
|
20
|
+
app.name: Rapid
|
21
|
+
"""
|
22
|
+
Then I should be good
|
23
|
+
And vice versa
|
24
|
+
|
25
|
+
Scenario: True unless and valid
|
26
|
+
When I load:
|
27
|
+
"""
|
28
|
+
app.emails.smtp.port: 587
|
29
|
+
"""
|
30
|
+
Then I should be good
|
31
|
+
And vice versa
|
32
|
+
|
33
|
+
Scenario: True unless and invalid
|
34
|
+
When I load:
|
35
|
+
"""
|
36
|
+
|
37
|
+
"""
|
38
|
+
Then "app.emails.smtp.port" should have a "can't be blank" error
|
39
|
+
And vice versa
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: doublt nested validates_exclusion_of
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given settings "my_settings.rb":
|
5
|
+
"""
|
6
|
+
class MySettings
|
7
|
+
include Rapid::Settings
|
8
|
+
|
9
|
+
setting.string 'app.author.name'
|
10
|
+
|
11
|
+
validates_exclusion_of "app.author.name", :in => %w(test)
|
12
|
+
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Valid value
|
17
|
+
When I load:
|
18
|
+
"""
|
19
|
+
app.author.name: Dan
|
20
|
+
"""
|
21
|
+
Then I should be good
|
22
|
+
And vice versa
|
23
|
+
|
24
|
+
Scenario: Invalid value
|
25
|
+
When I load:
|
26
|
+
"""
|
27
|
+
app.author.name: test
|
28
|
+
"""
|
29
|
+
Then "app.author.name" should have a "is reserved" error
|
30
|
+
And vice versa
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: nested validates_format_of
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given settings "my_settings.rb":
|
5
|
+
"""
|
6
|
+
class MySettings
|
7
|
+
include Rapid::Settings
|
8
|
+
|
9
|
+
setting.string 'app.author.version'
|
10
|
+
|
11
|
+
validates_format_of 'app.author.version', :with => /^[0-9]+\.[0-9]+$/
|
12
|
+
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Valid value
|
17
|
+
When I load:
|
18
|
+
"""
|
19
|
+
app.author.version: "1.0"
|
20
|
+
"""
|
21
|
+
Then I should be good
|
22
|
+
And vice versa
|
23
|
+
|
24
|
+
Scenario: Invalid value
|
25
|
+
When I load:
|
26
|
+
"""
|
27
|
+
app.author.version: 1.0a
|
28
|
+
"""
|
29
|
+
Then "app.author.version" should have a "is invalid" error
|
30
|
+
And vice versa
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: nested validates_inclusion_of
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given settings "my_settings.rb":
|
5
|
+
"""
|
6
|
+
class MySettings
|
7
|
+
include Rapid::Settings
|
8
|
+
|
9
|
+
setting.string 'app.author.version'
|
10
|
+
|
11
|
+
validates_inclusion_of 'app.author.version', :in => %w(1.0 1.1)
|
12
|
+
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Included value
|
17
|
+
When I load:
|
18
|
+
"""
|
19
|
+
app.author.version: "1.0"
|
20
|
+
"""
|
21
|
+
Then I should be good
|
22
|
+
And vice versa
|
23
|
+
|
24
|
+
Scenario: Non-included value
|
25
|
+
When I load:
|
26
|
+
"""
|
27
|
+
app.author.version: "2.0"
|
28
|
+
"""
|
29
|
+
Then "app.author.version" should have a "is not included in the list" error
|
30
|
+
And vice versa
|