jabysoft-bootstrap_generators 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/jabysoft.js +1 -0
- data/app/assets/stylesheets/jabysoft.sass +38 -0
- data/app/assets/stylesheets/mixins.scss +68 -0
- data/app/views/layouts/admin.html.haml +46 -0
- data/app/views/layouts/application.html.haml +31 -0
- data/app/views/shared/_datepicker_field.html.haml +9 -0
- data/app/views/shared/_layout.html.haml +7 -0
- data/app/views/shared/_messages.html.haml +7 -0
- data/app/views/shared/_panel.html.haml +5 -0
- data/app/views/shared/_search_form.html.haml +6 -0
- data/app/views/shared/form/_error_messages.html.haml +6 -0
- data/app/views/shared/modals/_delete_confirmation.html.haml +17 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +35 -0
- data/config/locales/pt-BR.yml +35 -0
- data/jabysoft-bootstrap_generators.gemspec +40 -0
- data/lib/generators/haml/scaffold/scaffold_generator.rb +35 -0
- data/lib/generators/jabysoft/setup/USAGE +19 -0
- data/lib/generators/jabysoft/setup/setup_generator.rb +57 -0
- data/lib/generators/jabysoft/setup/templates/.rspec +3 -0
- data/lib/generators/jabysoft/setup/templates/Gemfile +52 -0
- data/lib/generators/jabysoft/setup/templates/assets/stylesheets/bootstrap-variables.scss +876 -0
- data/lib/generators/jabysoft/setup/templates/layouts/admin.html.haml +46 -0
- data/lib/generators/jabysoft/setup/templates/layouts/application.html.haml +32 -0
- data/lib/generators/jabysoft/setup/templates/spec/rails_helper.rb +95 -0
- data/lib/generators/jabysoft/setup/templates/spec/spec_helper.rb +97 -0
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +157 -0
- data/lib/jabysoft/bootstrap_generators.rb +15 -0
- data/lib/jabysoft/bootstrap_generators/version.rb +5 -0
- data/lib/templates/haml/scaffold/_form.html.haml +14 -0
- data/lib/templates/haml/scaffold/_index.html.haml +25 -0
- data/lib/templates/haml/scaffold/edit.html.haml +1 -0
- data/lib/templates/haml/scaffold/index.html.haml +1 -0
- data/lib/templates/haml/scaffold/new.html.haml +1 -0
- data/lib/templates/haml/scaffold/show.html.haml +1 -0
- data/lib/templates/rails/scaffold_controller/controller.rb +28 -0
- data/lib/templates/rspec/scaffold/controller_spec.rb +148 -0
- data/lib/templates/rspec/scaffold/model_spec.rb +14 -0
- data/lib/templates/rspec/scaffold/request_spec.rb +10 -0
- data/lib/templates/rspec/scaffold/routing_spec.rb +44 -0
- data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
- data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
- data/vendor/assets/images/.keep +0 -0
- data/vendor/assets/javascripts/bootstrap-sprockets.js +12 -0
- data/vendor/assets/javascripts/bootstrap.js +2377 -0
- data/vendor/assets/javascripts/bootstrap.min.js +7 -0
- data/vendor/assets/javascripts/bootstrap/affix.js +162 -0
- data/vendor/assets/javascripts/bootstrap/alert.js +94 -0
- data/vendor/assets/javascripts/bootstrap/button.js +125 -0
- data/vendor/assets/javascripts/bootstrap/carousel.js +237 -0
- data/vendor/assets/javascripts/bootstrap/collapse.js +212 -0
- data/vendor/assets/javascripts/bootstrap/dropdown.js +165 -0
- data/vendor/assets/javascripts/bootstrap/modal.js +339 -0
- data/vendor/assets/javascripts/bootstrap/popover.js +108 -0
- data/vendor/assets/javascripts/bootstrap/scrollspy.js +172 -0
- data/vendor/assets/javascripts/bootstrap/tab.js +155 -0
- data/vendor/assets/javascripts/bootstrap/tooltip.js +520 -0
- data/vendor/assets/javascripts/bootstrap/transition.js +59 -0
- data/vendor/assets/stylesheets/_bootstrap-compass.scss +9 -0
- data/vendor/assets/stylesheets/_bootstrap-mincer.scss +19 -0
- data/vendor/assets/stylesheets/_bootstrap-sprockets.scss +9 -0
- data/vendor/assets/stylesheets/_bootstrap.scss +56 -0
- data/vendor/assets/stylesheets/bootstrap/_alerts.scss +73 -0
- data/vendor/assets/stylesheets/bootstrap/_badges.scss +68 -0
- data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +28 -0
- data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +244 -0
- data/vendor/assets/stylesheets/bootstrap/_buttons.scss +168 -0
- data/vendor/assets/stylesheets/bootstrap/_carousel.scss +270 -0
- data/vendor/assets/stylesheets/bootstrap/_close.scss +36 -0
- data/vendor/assets/stylesheets/bootstrap/_code.scss +69 -0
- data/vendor/assets/stylesheets/bootstrap/_component-animations.scss +37 -0
- data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +216 -0
- data/vendor/assets/stylesheets/bootstrap/_forms.scss +617 -0
- data/vendor/assets/stylesheets/bootstrap/_glyphicons.scss +307 -0
- data/vendor/assets/stylesheets/bootstrap/_grid.scss +84 -0
- data/vendor/assets/stylesheets/bootstrap/_input-groups.scss +171 -0
- data/vendor/assets/stylesheets/bootstrap/_jumbotron.scss +54 -0
- data/vendor/assets/stylesheets/bootstrap/_labels.scss +66 -0
- data/vendor/assets/stylesheets/bootstrap/_list-group.scss +130 -0
- data/vendor/assets/stylesheets/bootstrap/_media.scss +66 -0
- data/vendor/assets/stylesheets/bootstrap/_mixins.scss +40 -0
- data/vendor/assets/stylesheets/bootstrap/_modals.scss +150 -0
- data/vendor/assets/stylesheets/bootstrap/_navbar.scss +662 -0
- data/vendor/assets/stylesheets/bootstrap/_navs.scss +242 -0
- data/vendor/assets/stylesheets/bootstrap/_normalize.scss +424 -0
- data/vendor/assets/stylesheets/bootstrap/_pager.scss +54 -0
- data/vendor/assets/stylesheets/bootstrap/_pagination.scss +89 -0
- data/vendor/assets/stylesheets/bootstrap/_panels.scss +271 -0
- data/vendor/assets/stylesheets/bootstrap/_popovers.scss +131 -0
- data/vendor/assets/stylesheets/bootstrap/_print.scss +101 -0
- data/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +87 -0
- data/vendor/assets/stylesheets/bootstrap/_responsive-embed.scss +35 -0
- data/vendor/assets/stylesheets/bootstrap/_responsive-utilities.scss +179 -0
- data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +161 -0
- data/vendor/assets/stylesheets/bootstrap/_tables.scss +234 -0
- data/vendor/assets/stylesheets/bootstrap/_theme.scss +291 -0
- data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +38 -0
- data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +101 -0
- data/vendor/assets/stylesheets/bootstrap/_type.scss +298 -0
- data/vendor/assets/stylesheets/bootstrap/_utilities.scss +55 -0
- data/vendor/assets/stylesheets/bootstrap/_variables.scss +874 -0
- data/vendor/assets/stylesheets/bootstrap/_wells.scss +29 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_alerts.scss +14 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_background-variant.scss +12 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_buttons.scss +65 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_forms.scss +88 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_gradients.scss +58 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_grid.scss +122 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_image.scss +33 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_labels.scss +12 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_list-group.scss +32 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_opacity.scss +8 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_pagination.scss +24 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_panels.scss +24 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_progress-bar.scss +10 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_reset-text.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +21 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_size.scss +10 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +12 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
- data/vendor/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +222 -0
- metadata +316 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
5
|
+
%title= t('title.administration')
|
6
|
+
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
7
|
+
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
8
|
+
= csrf_meta_tags
|
9
|
+
%body
|
10
|
+
%nav.navbar.navbar-inverse.navbar-static-top{role: 'navigation'}
|
11
|
+
.container-fluid
|
12
|
+
= link_to t('title.administration'), admin_root_path, class: 'navbar-brand'
|
13
|
+
|
14
|
+
%button{class: "navbar-toggle", "data-toggle" => "collapse", "data-target" => ".navHeaderCollapse"}
|
15
|
+
%span.glyphicon.glyphicon-th
|
16
|
+
#navbar.collapse.navbar-collapse.navHeaderCollapse
|
17
|
+
%ul.nav.navbar-nav.navbar-left
|
18
|
+
%li= link_to t('dashboard'), '#'
|
19
|
+
%li= link_to t('about'), '#'
|
20
|
+
%li.dropdown
|
21
|
+
%a.dropdown-toggle{src: '#', "data-toggle" => 'dropdown'}
|
22
|
+
= "Dropdown"
|
23
|
+
.glyphicon.glyphicon-chevron-down
|
24
|
+
%ul.dropdown-menu
|
25
|
+
%li= link_to 'First link', '#'
|
26
|
+
|
27
|
+
%ul.nav.navbar-nav.navbar-right
|
28
|
+
%li
|
29
|
+
.user-name User Name
|
30
|
+
.logout
|
31
|
+
= link_to t('logout'), '#', method: :delete, class: 'btn btn-default glyphicon glyphicon-off'
|
32
|
+
%li.user-avatar
|
33
|
+
= image_tag("icons/admin.png")
|
34
|
+
|
35
|
+
.container-fluid
|
36
|
+
.row
|
37
|
+
.col-lg-12
|
38
|
+
= render_flash_messages
|
39
|
+
.row
|
40
|
+
.col-lg-12
|
41
|
+
= yield
|
42
|
+
|
43
|
+
%footer.navbar.navbar-default.navbar-static-bottom
|
44
|
+
.container-fluid
|
45
|
+
%p.navbar-text
|
46
|
+
= "© Admin JabySoft #{Date.today.year} All rights reserved".html_safe
|
@@ -0,0 +1,32 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
5
|
+
%title= t('title.application')
|
6
|
+
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
7
|
+
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
8
|
+
= csrf_meta_tags
|
9
|
+
%body
|
10
|
+
%nav.navbar.navbar-inverse.navbar-static-top{role: 'navigation'}
|
11
|
+
.container-fluid
|
12
|
+
= link_to t('title.application'), '#', class: 'navbar-brand'
|
13
|
+
|
14
|
+
%button{class: "navbar-toggle", "data-toggle" => "collapse", "data-target" => ".navHeaderCollapse"}
|
15
|
+
%span.glyphicon.glyphicon-th
|
16
|
+
.collapse.navbar-collapse.navHeaderCollapse
|
17
|
+
%ul.nav.navbar-nav.navbar-left
|
18
|
+
%li= link_to t('dashboard'), '#'
|
19
|
+
%li= link_to t('about'), '#'
|
20
|
+
|
21
|
+
.container-fluid
|
22
|
+
.row
|
23
|
+
.col-lg-12
|
24
|
+
= render_flash_messages
|
25
|
+
.row
|
26
|
+
.col-lg-12
|
27
|
+
= yield
|
28
|
+
|
29
|
+
%footer.navbar.navbar-default.navbar-static-bottom
|
30
|
+
.container-fluid
|
31
|
+
%p.navbar-text
|
32
|
+
= "© JabySoft #{Date.today.year} All rights reserved".html_safe
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# It sends test coverage info to codacy.com
|
2
|
+
require 'codacy-coverage'
|
3
|
+
Codacy::Reporter.start
|
4
|
+
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start :rails do
|
7
|
+
add_filter 'config/initializers'
|
8
|
+
end
|
9
|
+
|
10
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
11
|
+
ENV['RAILS_ENV'] ||= 'test'
|
12
|
+
require File.expand_path('../../config/environment', __FILE__)
|
13
|
+
# Prevent database truncation if the environment is production
|
14
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
15
|
+
require 'spec_helper'
|
16
|
+
require 'rspec/rails'
|
17
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
18
|
+
require 'shoulda/matchers'
|
19
|
+
Shoulda::Matchers.configure do |config|
|
20
|
+
config.integrate do |with|
|
21
|
+
with.test_framework :rspec
|
22
|
+
with.library :rails
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
27
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
28
|
+
# run as spec files by default. This means that files in spec/support that end
|
29
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
30
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
31
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
32
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
33
|
+
#
|
34
|
+
# The following line is provided for convenience purposes. It has the downside
|
35
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
36
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
37
|
+
# require only the support files necessary.
|
38
|
+
#
|
39
|
+
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
40
|
+
|
41
|
+
# Checks for pending migration and applies them before tests are run.
|
42
|
+
# If you are not using ActiveRecord, you can remove this line.
|
43
|
+
ActiveRecord::Migration.maintain_test_schema!
|
44
|
+
|
45
|
+
RSpec.configure do |config|
|
46
|
+
|
47
|
+
# DEVISE
|
48
|
+
config.include Devise::Test::ControllerHelpers, :type => :controller
|
49
|
+
# FACTORY-GIRL
|
50
|
+
config.include FactoryGirl::Syntax::Methods
|
51
|
+
# DatabaseCleaner
|
52
|
+
config.before(:suite) do
|
53
|
+
DatabaseCleaner.clean_with(:truncation)
|
54
|
+
end
|
55
|
+
config.before(:each) do
|
56
|
+
DatabaseCleaner.strategy = :transaction
|
57
|
+
end
|
58
|
+
config.before(:each, :js => true) do
|
59
|
+
DatabaseCleaner.strategy = :truncation
|
60
|
+
end
|
61
|
+
config.before(:each) do
|
62
|
+
DatabaseCleaner.start
|
63
|
+
end
|
64
|
+
config.after(:each) do
|
65
|
+
DatabaseCleaner.clean
|
66
|
+
end
|
67
|
+
|
68
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
69
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
70
|
+
|
71
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
72
|
+
# examples within a transaction, remove the following line or assign false
|
73
|
+
# instead of true.
|
74
|
+
config.use_transactional_fixtures = true
|
75
|
+
|
76
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
77
|
+
# based on their file location, for example enabling you to call `get` and
|
78
|
+
# `post` in specs under `spec/controllers`.
|
79
|
+
#
|
80
|
+
# You can disable this behaviour by removing the line below, and instead
|
81
|
+
# explicitly tag your specs with their type, e.g.:
|
82
|
+
#
|
83
|
+
# RSpec.describe UsersController, :type => :controller do
|
84
|
+
# # ...
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# The different available types are documented in the features, such as in
|
88
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
89
|
+
config.infer_spec_type_from_file_location!
|
90
|
+
|
91
|
+
# Filter lines from Rails gems in backtraces.
|
92
|
+
config.filter_rails_from_backtrace!
|
93
|
+
# arbitrary gems may also be filtered via:
|
94
|
+
# config.filter_gems_from_backtrace("gem name")
|
95
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start :rails do
|
3
|
+
add_filter 'config/initializers'
|
4
|
+
end
|
5
|
+
|
6
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
7
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
8
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
9
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
10
|
+
# files.
|
11
|
+
#
|
12
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
13
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
14
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
15
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
16
|
+
# a separate helper file that requires the additional dependencies and performs
|
17
|
+
# the additional setup, and require it from the spec files that actually need
|
18
|
+
# it.
|
19
|
+
#
|
20
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
21
|
+
# users commonly want.
|
22
|
+
#
|
23
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
24
|
+
RSpec.configure do |config|
|
25
|
+
# rspec-expectations config goes here. You can use an alternate
|
26
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
27
|
+
# assertions if you prefer.
|
28
|
+
config.expect_with :rspec do |expectations|
|
29
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
30
|
+
# and `failure_message` of custom matchers include text for helper methods
|
31
|
+
# defined using `chain`, e.g.:
|
32
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
33
|
+
# # => "be bigger than 2 and smaller than 4"
|
34
|
+
# ...rather than:
|
35
|
+
# # => "be bigger than 2"
|
36
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
37
|
+
end
|
38
|
+
|
39
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
40
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
41
|
+
config.mock_with :rspec do |mocks|
|
42
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
43
|
+
# a real object. This is generally recommended, and will default to
|
44
|
+
# `true` in RSpec 4.
|
45
|
+
mocks.verify_partial_doubles = true
|
46
|
+
end
|
47
|
+
|
48
|
+
# The settings below are suggested to provide a good initial experience
|
49
|
+
# with RSpec, but feel free to customize to your heart's content.
|
50
|
+
=begin
|
51
|
+
# This allows you to limit a spec run to individual examples or groups
|
52
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
53
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
54
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
55
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
56
|
+
config.filter_run_when_matching :focus
|
57
|
+
|
58
|
+
# Allows RSpec to persist some state between runs in order to support
|
59
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
60
|
+
# you configure your source control system to ignore this file.
|
61
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
62
|
+
|
63
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
64
|
+
# recommended. For more details, see:
|
65
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
66
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
67
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
68
|
+
config.disable_monkey_patching!
|
69
|
+
|
70
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
71
|
+
# file, and it's useful to allow more verbose output when running an
|
72
|
+
# individual spec file.
|
73
|
+
if config.files_to_run.one?
|
74
|
+
# Use the documentation formatter for detailed output,
|
75
|
+
# unless a formatter has already been configured
|
76
|
+
# (e.g. via a command-line flag).
|
77
|
+
config.default_formatter = 'doc'
|
78
|
+
end
|
79
|
+
|
80
|
+
# Print the 10 slowest examples and example groups at the
|
81
|
+
# end of the spec run, to help surface which specs are running
|
82
|
+
# particularly slow.
|
83
|
+
config.profile_examples = 10
|
84
|
+
|
85
|
+
# Run specs in random order to surface order dependencies. If you find an
|
86
|
+
# order dependency and want to debug it, you can fix the order by providing
|
87
|
+
# the seed, which is printed after each run.
|
88
|
+
# --seed 1234
|
89
|
+
config.order = :random
|
90
|
+
|
91
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
92
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
93
|
+
# test failures related to randomization by passing the same `--seed` value
|
94
|
+
# as the one that triggered the failure.
|
95
|
+
Kernel.srand config.seed
|
96
|
+
=end
|
97
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'generators/rspec'
|
2
|
+
require 'rails/generators/resource_helpers'
|
3
|
+
|
4
|
+
module Rspec
|
5
|
+
module Generators
|
6
|
+
# @private
|
7
|
+
class ScaffoldGenerator < Base
|
8
|
+
include ::Rails::Generators::ResourceHelpers
|
9
|
+
source_paths << File.expand_path("../../helper/templates", __FILE__)
|
10
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
11
|
+
|
12
|
+
class_option :orm, :desc => "ORM used to generate the controller"
|
13
|
+
class_option :template_engine, :desc => "Template engine to generate view files"
|
14
|
+
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
|
15
|
+
|
16
|
+
class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
|
17
|
+
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
|
18
|
+
class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs"
|
19
|
+
class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs"
|
20
|
+
|
21
|
+
def generate_controller_spec
|
22
|
+
return unless options[:controller_specs]
|
23
|
+
|
24
|
+
template_file = File.join(
|
25
|
+
'spec/controllers',
|
26
|
+
controller_class_path,
|
27
|
+
"#{controller_file_name}_controller_spec.rb"
|
28
|
+
)
|
29
|
+
template 'controller_spec.rb', template_file
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_routing_spec
|
33
|
+
return unless options[:routing_specs]
|
34
|
+
|
35
|
+
template_file = File.join(
|
36
|
+
'spec/routing',
|
37
|
+
controller_class_path,
|
38
|
+
"#{controller_file_name}_routing_spec.rb"
|
39
|
+
)
|
40
|
+
template 'routing_spec.rb', template_file
|
41
|
+
end
|
42
|
+
|
43
|
+
hook_for :integration_tool, :as => :integration
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def copy_view(view)
|
48
|
+
template "#{view}_spec.rb",
|
49
|
+
File.join("spec/views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
|
50
|
+
end
|
51
|
+
|
52
|
+
def formatted_hash(hash)
|
53
|
+
formatted = hash.inspect
|
54
|
+
formatted.gsub!("{", "{ ")
|
55
|
+
formatted.gsub!("}", " }")
|
56
|
+
formatted.gsub!("=>", " => ")
|
57
|
+
formatted
|
58
|
+
end
|
59
|
+
|
60
|
+
# support for namespaced-resources
|
61
|
+
def ns_file_name
|
62
|
+
ns_parts.empty? ? file_name : "#{ns_parts[0].underscore}_#{ns_parts[1].singularize.underscore}"
|
63
|
+
end
|
64
|
+
|
65
|
+
# support for namespaced-resources
|
66
|
+
def ns_table_name
|
67
|
+
ns_parts.empty? ? table_name : "#{ns_parts[0].underscore}/#{ns_parts[1].tableize}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def ns_parts
|
71
|
+
@ns_parts ||= begin
|
72
|
+
matches = ARGV[0].to_s.match(/\A(\w+)(?:\/|::)(\w+)/)
|
73
|
+
matches ? [matches[1], matches[2]] : []
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns the name of the mock. For example, if the file name is user,
|
78
|
+
# it returns mock_user.
|
79
|
+
#
|
80
|
+
# If a hash is given, it uses the hash key as the ORM method and the
|
81
|
+
# value as response. So, for ActiveRecord and file name "User":
|
82
|
+
#
|
83
|
+
# mock_file_name(:save => true)
|
84
|
+
# #=> mock_user(:save => true)
|
85
|
+
#
|
86
|
+
# If another ORM is being used and another method instead of save is
|
87
|
+
# called, it will be the one used.
|
88
|
+
#
|
89
|
+
def mock_file_name(hash = nil)
|
90
|
+
if hash
|
91
|
+
method, and_return = hash.to_a.first
|
92
|
+
method = orm_instance.send(method).split('.').last.gsub(/\(.*?\)/, '')
|
93
|
+
"mock_#{ns_file_name}(:#{method} => #{and_return})"
|
94
|
+
else
|
95
|
+
"mock_#{ns_file_name}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Receives the ORM chain and convert to expects. For ActiveRecord:
|
100
|
+
#
|
101
|
+
# should! orm_class.find(User, "37")
|
102
|
+
# #=> User.should_receive(:find).with(37)
|
103
|
+
#
|
104
|
+
# For Datamapper:
|
105
|
+
#
|
106
|
+
# should! orm_class.find(User, "37")
|
107
|
+
# #=> User.should_receive(:get).with(37)
|
108
|
+
#
|
109
|
+
def should_receive(chain)
|
110
|
+
stub_or_should_chain(:should_receive, chain)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Receives the ORM chain and convert to stub. For ActiveRecord:
|
114
|
+
#
|
115
|
+
# stub orm_class.find(User, "37")
|
116
|
+
# #=> User.stub(:find).with(37)
|
117
|
+
#
|
118
|
+
# For Datamapper:
|
119
|
+
#
|
120
|
+
# stub orm_class.find(User, "37")
|
121
|
+
# #=> User.stub(:get).with(37)
|
122
|
+
#
|
123
|
+
def stub(chain)
|
124
|
+
stub_or_should_chain(:stub, chain)
|
125
|
+
end
|
126
|
+
|
127
|
+
def stub_or_should_chain(mode, chain)
|
128
|
+
receiver, method = chain.split(".")
|
129
|
+
method.gsub!(/\((.*?)\)/, '')
|
130
|
+
|
131
|
+
response = "#{receiver}.#{mode}(:#{method})"
|
132
|
+
response << ".with(#{$1})" unless $1.blank?
|
133
|
+
response
|
134
|
+
end
|
135
|
+
|
136
|
+
def value_for(attribute)
|
137
|
+
raw_value_for(attribute).inspect
|
138
|
+
end
|
139
|
+
|
140
|
+
def raw_value_for(attribute)
|
141
|
+
case attribute.type
|
142
|
+
when :string
|
143
|
+
attribute.name.titleize
|
144
|
+
when :integer, :float
|
145
|
+
@attribute_id_map ||= {}
|
146
|
+
@attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next + attribute.default
|
147
|
+
else
|
148
|
+
attribute.default
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def banner
|
153
|
+
self.class.banner
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "jabysoft/bootstrap_generators/version"
|
2
|
+
require 'rails/engine'
|
3
|
+
|
4
|
+
module Jabysoft
|
5
|
+
module BootstrapGenerators
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
config.app_generators do |g|
|
8
|
+
g.templates.unshift File.expand_path('../../templates', __FILE__)
|
9
|
+
g.orm :active_record
|
10
|
+
g.template_engine :haml
|
11
|
+
g.test_framework :rspec, fixture: false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|