incredible 0.0.3.pre → 0.0.4.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/incredible.rb +1 -0
- data/lib/incredible/rule.rb +15 -0
- data/lib/incredible/step.rb +1 -1
- data/lib/incredible/version.rb +1 -1
- data/lib/incredible/wizard.rb +8 -5
- data/spec/controllers/forms_controller_spec.rb +16 -1
- data/spec/dummy/app/controllers/forms_controller.rb +1 -2
- data/spec/dummy/app/rules/step1_rule.rb +4 -3
- data/spec/dummy/bin/bundle +1 -1
- data/spec/dummy/bin/setup +1 -1
- data/spec/dummy/bin/update +1 -1
- data/spec/dummy/bin/yarn +2 -2
- data/spec/dummy/config/forms/form.yml +3 -0
- data/spec/form_spec.rb +2 -2
- data/spec/loader_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +46 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9967783a3c29d3e6e0c2dc35620a1b2e701c641
|
4
|
+
data.tar.gz: d256c193fee0f8890f4249c569c80fc53e6542e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f49b649c899ec64a7f315b8bfa7fc5669a990b7603eedfa5fca255f78a80cb9fbf26770210602c60ee83c750b492f2835888ac19f32aba1b3216a23f14ab90f
|
7
|
+
data.tar.gz: eb69d551623f687e35e9a98bc4dc5ae4797bf77b5aec0cd70b3f1d45f947380942a203e59715d5e54a6a126bdba22c9abd8eabfb59cf78c5c5ef2055efcfa322
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ rescue LoadError
|
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
6
|
end
|
7
7
|
|
8
|
-
APP_RAKEFILE = File.expand_path('
|
8
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
9
9
|
load 'rails/tasks/engine.rake'
|
10
10
|
|
11
11
|
Bundler::GemHelper.install_tasks
|
data/lib/incredible.rb
CHANGED
data/lib/incredible/step.rb
CHANGED
data/lib/incredible/version.rb
CHANGED
data/lib/incredible/wizard.rb
CHANGED
@@ -7,7 +7,7 @@ module Incredible
|
|
7
7
|
|
8
8
|
included do
|
9
9
|
before_action :load_step, only: %i[show update]
|
10
|
-
before_action :
|
10
|
+
before_action :load_next_step, only: :update
|
11
11
|
before_action :load_step_data, only: %i[show update]
|
12
12
|
end
|
13
13
|
|
@@ -20,10 +20,13 @@ module Incredible
|
|
20
20
|
self.questions = step_data.questions
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def load_next_step
|
24
|
+
if step_data.rule
|
25
|
+
@rule = step_data.rule.send(:new, params)
|
26
|
+
jump_to @rule.next_step
|
27
|
+
elsif step_data.next_step
|
28
|
+
jump_to step_data.next_step
|
29
|
+
end
|
27
30
|
end
|
28
31
|
|
29
32
|
module ClassMethods
|
@@ -20,7 +20,7 @@ describe FormsController, type: :controller do
|
|
20
20
|
it 'follows a rule' do
|
21
21
|
expect(
|
22
22
|
(put :update, params: { id: :step1, model: { name: 'Mike' } })
|
23
|
-
).to redirect_to('http://test.host/forms/step3')
|
23
|
+
).to redirect_to('http://test.host/forms/step3?foo=bar')
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'goes to the next step by default' do
|
@@ -30,4 +30,19 @@ describe FormsController, type: :controller do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
context 'next step is specified' do
|
34
|
+
it 'goes to that step' do
|
35
|
+
expect(
|
36
|
+
(put :update, params: {
|
37
|
+
id: :step2,
|
38
|
+
model: {
|
39
|
+
email: 'me@example.org',
|
40
|
+
phone_number: '323232'
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
).to redirect_to('http://test.host/forms/step4')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
33
48
|
end
|
@@ -9,7 +9,7 @@ class FormsController < ActionController::Base
|
|
9
9
|
|
10
10
|
def update
|
11
11
|
@model = StubModel.new(permitted_params)
|
12
|
-
render_wizard @model
|
12
|
+
render_wizard @model, {}, (@rule&.next_params || {})
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -17,5 +17,4 @@ class FormsController < ActionController::Base
|
|
17
17
|
def permitted_params
|
18
18
|
params.require(:model).permit(:name, :postcode, :email, :phone_number)
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
data/spec/dummy/bin/bundle
CHANGED
data/spec/dummy/bin/setup
CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
4
4
|
include FileUtils
|
5
5
|
|
6
6
|
# path to your application root.
|
7
|
-
APP_ROOT = Pathname.new File.expand_path('
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('..', __dir__)
|
8
8
|
|
9
9
|
def system!(*args)
|
10
10
|
system(*args) || abort("\n== Command #{args} failed ==")
|
data/spec/dummy/bin/update
CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
4
4
|
include FileUtils
|
5
5
|
|
6
6
|
# path to your application root.
|
7
|
-
APP_ROOT = Pathname.new File.expand_path('
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('..', __dir__)
|
8
8
|
|
9
9
|
def system!(*args)
|
10
10
|
system(*args) || abort("\n== Command #{args} failed ==")
|
data/spec/dummy/bin/yarn
CHANGED
@@ -4,8 +4,8 @@ Dir.chdir(VENDOR_PATH) do
|
|
4
4
|
begin
|
5
5
|
exec "yarnpkg #{ARGV.join(' ')}"
|
6
6
|
rescue Errno::ENOENT
|
7
|
-
|
8
|
-
|
7
|
+
warn 'Yarn executable was not detected in the system.'
|
8
|
+
warn 'Download Yarn at https://yarnpkg.com/en/docs/install'
|
9
9
|
exit 1
|
10
10
|
end
|
11
11
|
end
|
data/spec/form_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Incredible::Form do
|
|
7
7
|
describe '#step_names' do
|
8
8
|
|
9
9
|
it 'returns step names' do
|
10
|
-
expect(subject.step_names).to match_array(%w[step1 step2 step3])
|
10
|
+
expect(subject.step_names).to match_array(%w[step1 step2 step3 step4])
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -15,7 +15,7 @@ describe Incredible::Form do
|
|
15
15
|
describe '#steps' do
|
16
16
|
|
17
17
|
it 'returns the correct amount of steps' do
|
18
|
-
expect(subject.steps.count).to eq(
|
18
|
+
expect(subject.steps.count).to eq(4)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns steps as Steps' do
|
data/spec/loader_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Incredible::Loader do
|
|
9
9
|
it 'loads a form' do
|
10
10
|
expect(form).to be_a(Hash)
|
11
11
|
expect(form['form']['name']).to eq('Test form')
|
12
|
-
expect(form['form']['steps'].keys).to eq(%w[step1 step2 step3])
|
12
|
+
expect(form['form']['steps'].keys).to eq(%w[step1 step2 step3 step4])
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'with non-existent form' do
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ Coveralls.wear_merged!
|
|
3
3
|
|
4
4
|
ENV['RAILS_ENV'] ||= 'test'
|
5
5
|
|
6
|
-
require File.expand_path('
|
6
|
+
require File.expand_path('dummy/config/environment.rb', __dir__)
|
7
7
|
require 'rspec/rails'
|
8
8
|
require 'rails-controller-testing'
|
9
9
|
Rails::Controller::Testing.install
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incredible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pezholio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.3.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: coveralls
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rails-controller-testing
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rspec-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec_junit_formatter
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: sqlite3
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/incredible/engine.rb
|
152
152
|
- lib/incredible/form.rb
|
153
153
|
- lib/incredible/loader.rb
|
154
|
+
- lib/incredible/rule.rb
|
154
155
|
- lib/incredible/step.rb
|
155
156
|
- lib/incredible/version.rb
|
156
157
|
- lib/incredible/wizard.rb
|
@@ -225,49 +226,49 @@ signing_key:
|
|
225
226
|
specification_version: 4
|
226
227
|
summary: Build multi-page forms like a General
|
227
228
|
test_files:
|
229
|
+
- spec/loader_spec.rb
|
230
|
+
- spec/controllers/forms_controller_spec.rb
|
228
231
|
- spec/step_spec.rb
|
229
|
-
- spec/dummy/
|
230
|
-
- spec/dummy/
|
231
|
-
- spec/dummy/
|
232
|
-
- spec/dummy/
|
232
|
+
- spec/dummy/bin/rake
|
233
|
+
- spec/dummy/bin/bundle
|
234
|
+
- spec/dummy/bin/setup
|
235
|
+
- spec/dummy/bin/rails
|
236
|
+
- spec/dummy/bin/yarn
|
237
|
+
- spec/dummy/bin/update
|
238
|
+
- spec/dummy/app/models/application_record.rb
|
239
|
+
- spec/dummy/app/models/stub_model.rb
|
240
|
+
- spec/dummy/app/controllers/forms_controller.rb
|
241
|
+
- spec/dummy/app/controllers/application_controller.rb
|
242
|
+
- spec/dummy/app/views/forms/bar.html.erb
|
243
|
+
- spec/dummy/app/views/forms/foo.html.erb
|
244
|
+
- spec/dummy/app/views/layouts/mailer.html.erb
|
245
|
+
- spec/dummy/app/views/layouts/mailer.text.erb
|
246
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
247
|
+
- spec/dummy/app/rules/step1_rule.rb
|
248
|
+
- spec/dummy/config.ru
|
249
|
+
- spec/dummy/Rakefile
|
250
|
+
- spec/dummy/package.json
|
251
|
+
- spec/dummy/config/environment.rb
|
233
252
|
- spec/dummy/config/secrets.yml
|
234
|
-
- spec/dummy/config/
|
235
|
-
- spec/dummy/config/cable.yml
|
236
|
-
- spec/dummy/config/forms/form.yml
|
237
|
-
- spec/dummy/config/forms/bad-yaml.yml
|
238
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
253
|
+
- spec/dummy/config/initializers/inflections.rb
|
239
254
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
240
|
-
- spec/dummy/config/initializers/mime_types.rb
|
241
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
242
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
243
255
|
- spec/dummy/config/initializers/application_controller_renderer.rb
|
244
256
|
- spec/dummy/config/initializers/assets.rb
|
245
|
-
- spec/dummy/config/initializers/
|
257
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
258
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
259
|
+
- spec/dummy/config/initializers/mime_types.rb
|
260
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
246
261
|
- spec/dummy/config/boot.rb
|
247
|
-
- spec/dummy/config/environment.rb
|
248
|
-
- spec/dummy/config/puma.rb
|
249
262
|
- spec/dummy/config/routes.rb
|
263
|
+
- spec/dummy/config/forms/bad-yaml.yml
|
264
|
+
- spec/dummy/config/forms/form.yml
|
250
265
|
- spec/dummy/config/locales/en.yml
|
251
|
-
- spec/dummy/
|
252
|
-
- spec/dummy/
|
253
|
-
- spec/dummy/
|
254
|
-
- spec/dummy/
|
255
|
-
- spec/dummy/
|
256
|
-
- spec/dummy/
|
257
|
-
- spec/dummy/
|
258
|
-
- spec/dummy/app/controllers/application_controller.rb
|
259
|
-
- spec/dummy/app/controllers/forms_controller.rb
|
260
|
-
- spec/dummy/app/models/application_record.rb
|
261
|
-
- spec/dummy/app/models/stub_model.rb
|
262
|
-
- spec/dummy/package.json
|
263
|
-
- spec/dummy/config.ru
|
264
|
-
- spec/dummy/bin/rails
|
265
|
-
- spec/dummy/bin/setup
|
266
|
-
- spec/dummy/bin/rake
|
267
|
-
- spec/dummy/bin/update
|
268
|
-
- spec/dummy/bin/yarn
|
269
|
-
- spec/dummy/bin/bundle
|
266
|
+
- spec/dummy/config/puma.rb
|
267
|
+
- spec/dummy/config/application.rb
|
268
|
+
- spec/dummy/config/cable.yml
|
269
|
+
- spec/dummy/config/spring.rb
|
270
|
+
- spec/dummy/config/environments/test.rb
|
271
|
+
- spec/dummy/config/environments/development.rb
|
272
|
+
- spec/dummy/config/environments/production.rb
|
270
273
|
- spec/form_spec.rb
|
271
|
-
- spec/loader_spec.rb
|
272
274
|
- spec/spec_helper.rb
|
273
|
-
- spec/controllers/forms_controller_spec.rb
|