katapult 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +9 -0
- data/README.md +122 -94
- data/Rakefile +13 -0
- data/bin/katapult +59 -25
- data/features/application_model.feature +55 -0
- data/features/authenticate.feature +88 -62
- data/features/basics.feature +64 -402
- data/features/binary.feature +56 -42
- data/features/configuration.feature +4 -4
- data/features/model.feature +21 -30
- data/features/navigation.feature +35 -48
- data/features/step_definitions/aruba_steps.rb +3 -0
- data/features/step_definitions/katapult_steps.rb +307 -8
- data/features/step_definitions/rails_steps.rb +74 -14
- data/features/step_definitions/test_steps.rb +5 -5
- data/features/step_definitions/version_steps.rb +22 -0
- data/features/support/env.rb +11 -3
- data/features/{wui.feature → web_ui.feature} +175 -148
- data/katapult.gemspec +8 -13
- data/lib/generators/katapult/app_model/app_model_generator.rb +12 -0
- data/lib/generators/katapult/app_model/templates/lib/katapult/application_model.rb +40 -0
- data/lib/generators/katapult/basics/basics_generator.rb +186 -51
- data/lib/generators/katapult/basics/templates/.browserslistrc +1 -0
- data/lib/generators/katapult/basics/templates/.gitignore +20 -21
- data/lib/generators/katapult/basics/templates/.rspec_parallel +3 -0
- data/lib/generators/katapult/basics/templates/Capfile +5 -1
- data/lib/generators/katapult/basics/templates/Gemfile +23 -34
- data/lib/generators/katapult/basics/templates/Guardfile +0 -12
- data/lib/generators/katapult/basics/templates/app/controllers/errors_controller.rb +9 -0
- data/lib/generators/katapult/basics/templates/app/helpers/unpoly_helper.rb +13 -0
- data/lib/generators/katapult/{haml → basics}/templates/app/views/layouts/_flashes.html.haml +1 -1
- data/lib/generators/katapult/basics/templates/app/views/layouts/_menu_bar.html.haml.tt +12 -0
- data/lib/generators/katapult/basics/templates/app/views/layouts/application.html.haml.tt +25 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/images/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/index.js +16 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/application.js +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/bootstrap.js +12 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/compilers/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/macros/content_link.js +17 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/macros/modal_link.js +17 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/javascripts/unpoly.js +9 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_definitions.sass +25 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_environment.sass +2 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/_mixins.sass +3 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/blocks/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/custom_bootstrap.sass +50 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/ext/.keep +0 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/ext/bootstrap/navbar.sass +83 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/theme.sass +11 -0
- data/lib/generators/katapult/basics/templates/app/webpack/assets/stylesheets/unpoly.sass +2 -0
- data/lib/generators/katapult/basics/templates/app/webpack/packs/application.js +13 -0
- data/lib/generators/katapult/basics/templates/config/database.sample.yml +1 -1
- data/lib/generators/katapult/basics/templates/config/deploy.rb +3 -4
- data/lib/generators/katapult/basics/templates/config/environments/staging.rb +5 -0
- data/lib/generators/katapult/basics/templates/config/initializers/better_errors.rb +23 -0
- data/lib/generators/katapult/basics/templates/config/initializers/exception_notification.rb.tt +1 -1
- data/lib/generators/katapult/basics/templates/config/initializers/ext.rb +1 -1
- data/lib/generators/katapult/basics/templates/config/webpack/loaders/unpoly.js +4 -0
- data/lib/generators/katapult/basics/templates/features/support/capybara_screenshot.rb +7 -0
- data/lib/generators/katapult/basics/templates/features/support/factory_bot.rb +1 -0
- data/lib/generators/katapult/basics/templates/features/support/paths.rb +7 -2
- data/lib/generators/katapult/basics/templates/features/support/rspec_doubles.rb +1 -0
- data/lib/generators/katapult/basics/templates/features/support/selectors.rb +3 -3
- data/lib/generators/katapult/basics/templates/features/support/selenium.rb +13 -0
- data/lib/generators/katapult/basics/templates/features/support/{env-custom.rb → spreewald.rb} +0 -0
- data/lib/generators/katapult/basics/templates/features/support/webpacker.rb +35 -0
- data/lib/generators/katapult/basics/templates/lib/ext/action_view/form_for_with_development_errors.rb +31 -31
- data/lib/generators/katapult/basics/templates/lib/ext/active_record/find_by_anything.rb +4 -3
- data/lib/generators/katapult/basics/templates/public/robots.txt +5 -0
- data/lib/generators/katapult/basics/templates/spec/assets/sample.pdf +0 -0
- data/lib/generators/katapult/basics/templates/spec/factories/factories.rb +1 -1
- data/lib/generators/katapult/basics/templates/spec/support/database_cleaner.rb +20 -0
- data/lib/generators/katapult/basics/templates/spec/support/factory_bot.rb +3 -0
- data/lib/generators/katapult/basics/templates/spec/support/fixture_file.rb +6 -0
- data/lib/generators/katapult/basics/templates/spec/support/postgresql_sequences.rb +15 -0
- data/lib/generators/katapult/basics/templates/spec/support/timecop.rb +3 -0
- data/lib/generators/katapult/clearance/clearance_generator.rb +14 -2
- data/lib/generators/katapult/clearance/templates/app/views/layouts/_current_user.html.haml +11 -0
- data/lib/generators/katapult/clearance/templates/app/views/passwords/create.html.haml +10 -4
- data/lib/generators/katapult/clearance/templates/app/views/passwords/edit.html.haml +12 -12
- data/lib/generators/katapult/clearance/templates/app/views/passwords/new.html.haml +14 -11
- data/lib/generators/katapult/clearance/templates/app/views/sessions/new.html.haml +16 -15
- data/lib/generators/katapult/clearance/templates/features/authentication.feature +3 -3
- data/lib/generators/katapult/cucumber_features/templates/feature.feature +1 -1
- data/lib/generators/katapult/model_specs/templates/model_spec.rb +3 -5
- data/lib/generators/katapult/navigation/navigation_generator.rb +7 -1
- data/lib/generators/katapult/navigation/templates/app/views/layouts/_navigation.html.haml +15 -0
- data/lib/generators/katapult/transform/transform_generator.rb +12 -17
- data/lib/generators/katapult/views/templates/_form.html.haml +48 -0
- data/lib/generators/katapult/views/templates/app/helpers/table_helper.rb +14 -0
- data/lib/generators/katapult/views/templates/app/webpack/assets/stylesheets/blocks/action_bar.sass +22 -0
- data/lib/generators/katapult/views/templates/app/webpack/assets/stylesheets/blocks/title.sass +11 -0
- data/lib/generators/katapult/views/templates/custom_action.html.haml +5 -0
- data/lib/generators/katapult/views/templates/edit.html.haml +4 -0
- data/lib/generators/katapult/views/templates/index.html.haml +26 -0
- data/lib/generators/katapult/{haml → views}/templates/new.html.haml +1 -1
- data/lib/generators/katapult/views/templates/show.html.haml +39 -0
- data/lib/generators/katapult/{haml/haml_generator.rb → views/views_generator.rb} +19 -25
- data/lib/generators/katapult/{w_u_i → web_ui}/templates/_route.rb +3 -3
- data/lib/generators/katapult/{w_u_i → web_ui}/templates/controller.rb +21 -23
- data/lib/generators/katapult/{w_u_i/w_u_i_generator.rb → web_ui/web_ui_generator.rb} +7 -12
- data/lib/katapult/action.rb +1 -1
- data/lib/katapult/application_model.rb +8 -8
- data/lib/katapult/binary_util.rb +48 -10
- data/lib/katapult/generator.rb +2 -10
- data/lib/katapult/generator_goodies.rb +23 -0
- data/lib/katapult/navigation.rb +10 -5
- data/lib/katapult/parser.rb +15 -8
- data/lib/katapult/version.rb +5 -1
- data/lib/katapult/{wui.rb → web_ui.rb} +19 -4
- data/lib/katapult.rb +0 -5
- data/script/console +5 -2
- data/script/kta +8 -0
- data/script/update +80 -0
- data/spec/action_spec.rb +0 -1
- data/spec/attribute_spec.rb +0 -1
- data/spec/element_spec.rb +0 -1
- data/spec/model_spec.rb +0 -1
- data/spec/parser_spec.rb +26 -0
- data/spec/util_spec.rb +0 -1
- data/spec/{wui_spec.rb → web_ui_spec.rb} +24 -12
- metadata +86 -124
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_all.sass +0 -4
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_items.sass +0 -11
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_layout.sass +0 -26
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_navigation.sass +0 -11
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_tools.sass +0 -12
- data/lib/generators/katapult/basics/templates/app/assets/stylesheets/application.sass +0 -6
- data/lib/generators/katapult/basics/templates/config/spring.rb +0 -3
- data/lib/generators/katapult/basics/templates/features/support/factory_girl.rb +0 -1
- data/lib/generators/katapult/basics/templates/spec/support/factory_girl.rb +0 -3
- data/lib/generators/katapult/haml/templates/_form.html.haml +0 -38
- data/lib/generators/katapult/haml/templates/app/views/layouts/application.html.haml +0 -33
- data/lib/generators/katapult/haml/templates/custom_action.html.haml +0 -5
- data/lib/generators/katapult/haml/templates/edit.html.haml +0 -4
- data/lib/generators/katapult/haml/templates/index.html.haml +0 -29
- data/lib/generators/katapult/haml/templates/show.html.haml +0 -39
- data/lib/generators/katapult/install/install_generator.rb +0 -14
- data/lib/generators/katapult/install/templates/lib/katapult/application_model.rb +0 -20
- data/lib/generators/katapult/navigation/templates/app/models/navigation.rb +0 -12
data/features/binary.feature
CHANGED
|
@@ -1,16 +1,50 @@
|
|
|
1
|
+
#@announce-output
|
|
2
|
+
#@announce-stderr
|
|
1
3
|
Feature: Katapult binary `katapult`
|
|
2
4
|
|
|
3
|
-
Scenario:
|
|
4
|
-
|
|
5
|
+
Scenario: Run without arguments
|
|
6
|
+
When I run `katapult`
|
|
7
|
+
Then the output should contain "Usage: katapult new APP_NAME | fire [path/to/model] | version"
|
|
8
|
+
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
Scenario: Print versions
|
|
11
|
+
When I run `katapult version`
|
|
12
|
+
Then the output should contain "Katapult"
|
|
13
|
+
And the output should contain "Generating a Rails 5."
|
|
14
|
+
And the output should contain " app on Ruby 2."
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Scenario: Missing options are asked for
|
|
18
|
+
When I run `katapult new` interactively
|
|
19
|
+
And I type "test_app"
|
|
7
20
|
And I type "katapult"
|
|
8
21
|
And I type "secret"
|
|
9
22
|
Then the output should contain "Creating new Rails application"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
|
|
24
|
+
# Aruba seemingly cannot test output interleaved with input, so the output
|
|
25
|
+
# is tested after exiting the script
|
|
26
|
+
When I stop the command above
|
|
27
|
+
Then the output should contain "Please enter the database user"
|
|
28
|
+
Then the output should contain "Please enter the application name"
|
|
29
|
+
Then the output should contain "Please enter the database password"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Scenario: App name gets normalized
|
|
33
|
+
When I run `katapult new TestApp --verbose`
|
|
34
|
+
Then the output should contain "Normalized application name: test_app"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# @announce-output
|
|
38
|
+
Scenario: Start new Rails application
|
|
39
|
+
# Rails new including yarn install + installing basics takes quite some time
|
|
40
|
+
Given the aruba exit timeout is 90 seconds
|
|
41
|
+
|
|
42
|
+
When I successfully run `katapult new binary_test -u katapult -p secret`
|
|
43
|
+
Then the output should contain "Creating new Rails application"
|
|
44
|
+
And the output should contain "Installing katapult"
|
|
45
|
+
And the output should contain "Generating katapult basics"
|
|
46
|
+
And the output should contain the configured Rails version
|
|
47
|
+
And the output should contain:
|
|
14
48
|
"""
|
|
15
49
|
Application initialization done.
|
|
16
50
|
|
|
@@ -19,44 +53,28 @@ Feature: Katapult binary `katapult`
|
|
|
19
53
|
"""
|
|
20
54
|
|
|
21
55
|
When I cd to "binary_test"
|
|
22
|
-
|
|
23
|
-
# test whether katapult is installed
|
|
24
56
|
Then the file "Gemfile" should contain "gem 'katapult'"
|
|
25
|
-
|
|
57
|
+
And a file named "lib/katapult/application_model.rb" should exist
|
|
26
58
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
And the file "config/database.yml" should contain "password: secret"
|
|
59
|
+
And the file "config/database.yml" should contain "username: katapult"
|
|
60
|
+
And the file "config/database.yml" should contain "password: secret"
|
|
30
61
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# When I run `bundle check`
|
|
34
|
-
# Then the output should contain "The Gemfile's dependencies are satisfied"
|
|
62
|
+
When I run `bundle check`
|
|
63
|
+
Then the output should contain "The Gemfile's dependencies are satisfied"
|
|
35
64
|
|
|
36
|
-
# test whether katapult made git commits
|
|
37
65
|
When I run `git log`
|
|
38
66
|
Then the output should contain "rails new binary_test"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Scenario: Forget to pass application name
|
|
45
|
-
When I run `katapult new --non-interactive # Without app name`
|
|
46
|
-
Then the output should contain "No value provided for required arguments 'app_path'"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Scenario: Run without arguments
|
|
50
|
-
When I run `katapult # without arguments`
|
|
51
|
-
Then the output should contain "Usage: katapult [new APP_NAME | fire [path/to/model] ]"
|
|
67
|
+
And the output should contain "rails generate katapult:app_model"
|
|
68
|
+
And the output should contain "rails generate katapult:basics"
|
|
69
|
+
And the output should contain "Author: katapult <katapult@makandra.com>"
|
|
52
70
|
|
|
53
71
|
|
|
54
72
|
Scenario: Transform the application model
|
|
55
|
-
Given a
|
|
56
|
-
|
|
57
|
-
And I generate katapult basics
|
|
73
|
+
Given a new Rails application with Katapult basics installed
|
|
74
|
+
And the default aruba exit timeout is 45 seconds
|
|
58
75
|
|
|
59
|
-
When I
|
|
76
|
+
When I generate the application model
|
|
77
|
+
And I run `katapult fire`
|
|
60
78
|
Then the output should contain "Loading katapult"
|
|
61
79
|
And the output should contain "parse lib/katapult/application_model"
|
|
62
80
|
And the output should contain "render into katapult_test_app"
|
|
@@ -75,9 +93,7 @@ Feature: Katapult binary `katapult`
|
|
|
75
93
|
|
|
76
94
|
|
|
77
95
|
Scenario: Transform a custom application model
|
|
78
|
-
Given a
|
|
79
|
-
And I install katapult
|
|
80
|
-
And I generate katapult basics
|
|
96
|
+
Given a new Rails application with Katapult basics installed
|
|
81
97
|
|
|
82
98
|
When I write to "lib/katapult/custom_model.rb" with:
|
|
83
99
|
"""
|
|
@@ -90,11 +106,9 @@ Feature: Katapult binary `katapult`
|
|
|
90
106
|
|
|
91
107
|
|
|
92
108
|
Scenario: When the transformation fails, an error message is printed
|
|
93
|
-
Given a
|
|
94
|
-
And I install katapult
|
|
95
|
-
And I generate katapult basics
|
|
109
|
+
Given a new Rails application with Katapult basics installed
|
|
96
110
|
|
|
97
|
-
When I
|
|
111
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
98
112
|
"""
|
|
99
113
|
model 'failing example' do |ex|
|
|
100
114
|
ex.attr :fail, type: :nonexistent
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
#@announce-output
|
|
2
|
+
#@announce-stderr
|
|
1
3
|
Feature: Configure katapult
|
|
2
4
|
|
|
3
5
|
Background:
|
|
4
|
-
Given a
|
|
5
|
-
And I install katapult
|
|
6
|
-
And I generate katapult basics
|
|
6
|
+
Given a new Rails application with Katapult basics installed
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Scenario: Custom model template
|
|
10
|
-
When I
|
|
10
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
11
11
|
"""
|
|
12
12
|
model 'Car'
|
|
13
13
|
"""
|
data/features/model.feature
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
#@announce-output
|
|
1
2
|
Feature: Generate Models
|
|
2
3
|
|
|
3
4
|
Background:
|
|
4
|
-
Given a
|
|
5
|
-
And I install katapult
|
|
6
|
-
And I generate katapult basics
|
|
5
|
+
Given a new Rails application with Katapult basics installed
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
Scenario: Generate ActiveRecord Model
|
|
10
|
-
When I
|
|
9
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
11
10
|
"""
|
|
12
11
|
model 'Car'
|
|
13
12
|
"""
|
|
@@ -24,11 +23,11 @@ Feature: Generate Models
|
|
|
24
23
|
"""
|
|
25
24
|
And there should be a migration with:
|
|
26
25
|
"""
|
|
27
|
-
class CreateCars < ActiveRecord::Migration
|
|
26
|
+
class CreateCars < ActiveRecord::Migration[5.1]
|
|
28
27
|
def change
|
|
29
28
|
create_table :cars do |t|
|
|
30
29
|
|
|
31
|
-
t.timestamps
|
|
30
|
+
t.timestamps
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
end
|
|
@@ -36,14 +35,12 @@ Feature: Generate Models
|
|
|
36
35
|
"""
|
|
37
36
|
And the file "spec/models/car_spec.rb" should contain exactly:
|
|
38
37
|
"""
|
|
39
|
-
require 'rails_helper'
|
|
40
|
-
|
|
41
38
|
describe Car do
|
|
42
39
|
|
|
43
40
|
describe '#to_s' do
|
|
44
41
|
it 'returns its class name with its id' do
|
|
45
42
|
subject.id = 17
|
|
46
|
-
expect(subject.to_s).to
|
|
43
|
+
expect(subject.to_s).to eq("Car#17")
|
|
47
44
|
end
|
|
48
45
|
end
|
|
49
46
|
|
|
@@ -53,7 +50,7 @@ Feature: Generate Models
|
|
|
53
50
|
|
|
54
51
|
|
|
55
52
|
Scenario: Generate ActiveRecord Model with attributes
|
|
56
|
-
When I
|
|
53
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
57
54
|
"""
|
|
58
55
|
model 'Person' do |person|
|
|
59
56
|
|
|
@@ -72,7 +69,7 @@ Feature: Generate Models
|
|
|
72
69
|
person.attr :plain_json, type: :plain_json
|
|
73
70
|
end
|
|
74
71
|
"""
|
|
75
|
-
And I successfully transform the application model
|
|
72
|
+
And I successfully transform the application model including migrations
|
|
76
73
|
Then the file "app/models/person.rb" should contain exactly:
|
|
77
74
|
"""
|
|
78
75
|
class Person < ActiveRecord::Base
|
|
@@ -87,7 +84,7 @@ Feature: Generate Models
|
|
|
87
84
|
"""
|
|
88
85
|
And there should be a migration with:
|
|
89
86
|
"""
|
|
90
|
-
class CreatePeople < ActiveRecord::Migration
|
|
87
|
+
class CreatePeople < ActiveRecord::Migration[5.1]
|
|
91
88
|
def change
|
|
92
89
|
create_table :people do |t|
|
|
93
90
|
t.integer :age
|
|
@@ -101,7 +98,7 @@ Feature: Generate Models
|
|
|
101
98
|
t.jsonb :indexable_json
|
|
102
99
|
t.json :plain_json
|
|
103
100
|
|
|
104
|
-
t.timestamps
|
|
101
|
+
t.timestamps
|
|
105
102
|
end
|
|
106
103
|
end
|
|
107
104
|
end
|
|
@@ -109,28 +106,26 @@ Feature: Generate Models
|
|
|
109
106
|
"""
|
|
110
107
|
And the file "spec/models/person_spec.rb" should contain exactly:
|
|
111
108
|
"""
|
|
112
|
-
require 'rails_helper'
|
|
113
|
-
|
|
114
109
|
describe Person do
|
|
115
110
|
|
|
116
111
|
describe '#to_s' do
|
|
117
112
|
it 'returns the #age attribute' do
|
|
118
113
|
subject.age = 778
|
|
119
|
-
expect(subject.to_s).to
|
|
114
|
+
expect(subject.to_s).to eq("778")
|
|
120
115
|
end
|
|
121
116
|
end
|
|
122
117
|
|
|
123
118
|
describe '#homepage' do
|
|
124
119
|
|
|
125
120
|
it 'has a default' do
|
|
126
|
-
expect(
|
|
121
|
+
expect(subject.homepage).to eq("http://www.makandra.de")
|
|
127
122
|
end
|
|
128
123
|
end
|
|
129
124
|
|
|
130
125
|
describe '#locked' do
|
|
131
126
|
|
|
132
127
|
it 'has a default' do
|
|
133
|
-
expect(
|
|
128
|
+
expect(subject.locked).to eq(false)
|
|
134
129
|
end
|
|
135
130
|
end
|
|
136
131
|
|
|
@@ -143,7 +138,7 @@ Feature: Generate Models
|
|
|
143
138
|
|
|
144
139
|
|
|
145
140
|
Scenario: Get a helpful error message when an attribute has an unknown option
|
|
146
|
-
When I
|
|
141
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
147
142
|
"""
|
|
148
143
|
model 'Person' do |person|
|
|
149
144
|
person.attr :x, invalid_option: 'here'
|
|
@@ -154,14 +149,14 @@ Feature: Generate Models
|
|
|
154
149
|
|
|
155
150
|
|
|
156
151
|
Scenario: Specify assignable values
|
|
157
|
-
When I
|
|
152
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
158
153
|
"""
|
|
159
154
|
model 'Person' do |person|
|
|
160
155
|
person.attr :age, type: :integer, assignable_values: 9..99
|
|
161
156
|
person.attr :hobby, assignable_values: %w[soccer baseball], default: 'soccer', allow_blank: true
|
|
162
157
|
end
|
|
163
158
|
"""
|
|
164
|
-
And I successfully transform the application model
|
|
159
|
+
And I successfully transform the application model including migrations
|
|
165
160
|
Then the file "app/models/person.rb" should contain exactly:
|
|
166
161
|
"""
|
|
167
162
|
class Person < ActiveRecord::Base
|
|
@@ -180,14 +175,12 @@ Feature: Generate Models
|
|
|
180
175
|
"""
|
|
181
176
|
And the file "spec/models/person_spec.rb" should contain exactly:
|
|
182
177
|
"""
|
|
183
|
-
require 'rails_helper'
|
|
184
|
-
|
|
185
178
|
describe Person do
|
|
186
179
|
|
|
187
180
|
describe '#to_s' do
|
|
188
181
|
it 'returns the #age attribute' do
|
|
189
182
|
subject.age = 9
|
|
190
|
-
expect(subject.to_s).to
|
|
183
|
+
expect(subject.to_s).to eq("9")
|
|
191
184
|
end
|
|
192
185
|
end
|
|
193
186
|
|
|
@@ -201,7 +194,7 @@ Feature: Generate Models
|
|
|
201
194
|
it { is_expected.to_not allow_value("baseball-unassignable").for(:hobby) }
|
|
202
195
|
|
|
203
196
|
it 'has a default' do
|
|
204
|
-
expect(
|
|
197
|
+
expect(subject.hobby).to eq("soccer")
|
|
205
198
|
end
|
|
206
199
|
end
|
|
207
200
|
|
|
@@ -217,12 +210,10 @@ Feature: Generate Models
|
|
|
217
210
|
|
|
218
211
|
Do not add routes twice.
|
|
219
212
|
|
|
220
|
-
When I
|
|
213
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
221
214
|
"""
|
|
222
|
-
model
|
|
223
|
-
|
|
224
|
-
wui.crud
|
|
225
|
-
end
|
|
215
|
+
model('Car') { |c| c.attr :model }
|
|
216
|
+
web_ui 'Car', &:crud
|
|
226
217
|
"""
|
|
227
218
|
And I successfully transform the application model
|
|
228
219
|
Then the file named "config/routes.rb" should contain:
|
data/features/navigation.feature
CHANGED
|
@@ -1,76 +1,63 @@
|
|
|
1
|
+
#@announce-stderr
|
|
1
2
|
Feature: Navigation
|
|
2
3
|
|
|
3
4
|
Background:
|
|
4
|
-
Given a
|
|
5
|
-
And I install katapult
|
|
6
|
-
And I generate katapult basics
|
|
5
|
+
Given a new Rails application with Katapult basics installed
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
Scenario: Generate navigation
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
A navigation is rendered from all WebUIs in the application model. It
|
|
12
11
|
consists of links to their index pages.
|
|
13
12
|
|
|
14
|
-
When I
|
|
13
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
15
14
|
"""
|
|
16
15
|
model 'Customer' do |customer|
|
|
17
16
|
customer.attr :name
|
|
18
17
|
end
|
|
18
|
+
web_ui 'Customer', &:crud
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
wui.action :index
|
|
22
|
-
wui.action :show
|
|
23
|
-
wui.action :create
|
|
24
|
-
wui.action :update
|
|
25
|
-
wui.action :destroy
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
navigation 'main'
|
|
20
|
+
navigation
|
|
29
21
|
"""
|
|
30
22
|
And I successfully transform the application model
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
And the file "app/controllers/customers_controller.rb" should contain:
|
|
52
|
-
"""
|
|
53
|
-
def set_section
|
|
54
|
-
in_sections :customers
|
|
55
|
-
end
|
|
56
|
-
"""
|
|
23
|
+
And the file "app/views/layouts/_menu_bar.html.haml" should contain:
|
|
24
|
+
"""
|
|
25
|
+
= render 'layouts/navigation'
|
|
26
|
+
"""
|
|
27
|
+
And the file "app/views/layouts/_navigation.html.haml" should contain:
|
|
28
|
+
"""
|
|
29
|
+
%ul.nav.navbar-nav
|
|
30
|
+
%li(up-expand)
|
|
31
|
+
= content_link_to "Customers", customers_path
|
|
32
|
+
|
|
33
|
+
%li.dropdown
|
|
34
|
+
= link_to '#', data: { toggle: 'dropdown' } do
|
|
35
|
+
Dropdown example
|
|
36
|
+
%span.caret
|
|
37
|
+
|
|
38
|
+
%ul.dropdown-menu
|
|
39
|
+
%li= link_to 'One', '#'
|
|
40
|
+
%li.divider
|
|
41
|
+
%li= link_to 'Two', '#'
|
|
42
|
+
"""
|
|
57
43
|
|
|
58
44
|
|
|
59
45
|
Scenario: Homepage (aka root route) is set automatically
|
|
60
46
|
|
|
61
|
-
The first
|
|
47
|
+
The first WebUI with an index action is set as home page. This does not
|
|
48
|
+
require a navigation.
|
|
62
49
|
|
|
63
|
-
When I
|
|
50
|
+
When I write to "lib/katapult/application_model.rb" with:
|
|
64
51
|
"""
|
|
65
|
-
model
|
|
66
|
-
model
|
|
52
|
+
model('Customer') { |c| c.attr :name }
|
|
53
|
+
model('Elephant') { |e| e.attr :name }
|
|
67
54
|
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
web_ui 'Elephant' do |web_ui|
|
|
56
|
+
web_ui.action :trumpet, scope: :member, method: :post
|
|
70
57
|
end
|
|
71
58
|
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
web_ui 'Customer' do |web_ui|
|
|
60
|
+
web_ui.crud
|
|
74
61
|
end
|
|
75
62
|
"""
|
|
76
63
|
And I successfully transform the application model
|