hot-glue 0.5.12 → 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +74 -0
- data/.github/workflows/test.yml +33 -14
- data/.gitignore +0 -2
- data/.ruby-version +1 -1
- data/Gemfile +4 -2
- data/Gemfile.lock +280 -0
- data/README.md +73 -1
- data/lib/generators/hot_glue/direct_upload_install_generator.rb +1 -1
- data/lib/generators/hot_glue/dropzone_install_generator.rb +1 -1
- data/lib/generators/hot_glue/field_factory.rb +4 -1
- data/lib/generators/hot_glue/fields/association_field.rb +73 -6
- data/lib/generators/hot_glue/fields/attachment_field.rb +7 -3
- data/lib/generators/hot_glue/fields/boolean_field.rb +21 -0
- data/lib/generators/hot_glue/fields/date_field.rb +13 -0
- data/lib/generators/hot_glue/fields/date_time_field.rb +14 -2
- data/lib/generators/hot_glue/fields/enum_field.rb +40 -7
- data/lib/generators/hot_glue/fields/field.rb +44 -4
- data/lib/generators/hot_glue/fields/float_field.rb +9 -0
- data/lib/generators/hot_glue/fields/integer_field.rb +5 -1
- data/lib/generators/hot_glue/fields/string_field.rb +17 -0
- data/lib/generators/hot_glue/fields/text_field.rb +17 -0
- data/lib/generators/hot_glue/fields/time_field.rb +20 -0
- data/lib/generators/hot_glue/fields/uuid_field.rb +2 -3
- data/lib/generators/hot_glue/flash_notices_install_generator.rb +20 -0
- data/lib/generators/hot_glue/install_generator.rb +16 -15
- data/lib/generators/hot_glue/markup_templates/erb.rb +14 -279
- data/lib/generators/hot_glue/scaffold_generator.rb +27 -9
- data/lib/generators/hot_glue/templates/controller.rb.erb +5 -4
- data/lib/generators/hot_glue/templates/erb/_edit.erb +12 -0
- data/lib/generators/hot_glue/templates/erb/_flash_notices.erb +12 -8
- data/lib/generators/hot_glue/templates/erb/_show.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +3 -4
- data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +7 -1
- data/lib/generators/hot_glue/templates/erb/edit.erb +1 -12
- data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +3 -6
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +1 -1
- data/lib/hot-glue.rb +4 -1
- data/lib/hotglue/version.rb +1 -1
- data/script/test +9 -14
- metadata +7 -19
- data/lib/generators/hot_glue/templates/erb/_errors.erb +0 -11
- data/lib/generators/hot_glue/templates/haml/_errors.haml +0 -6
- data/lib/generators/hot_glue/templates/haml/_flash_notices.haml +0 -8
- data/lib/generators/hot_glue/templates/haml/_form.haml +0 -5
- data/lib/generators/hot_glue/templates/haml/_line.haml +0 -6
- data/lib/generators/hot_glue/templates/haml/_list.haml +0 -15
- data/lib/generators/hot_glue/templates/haml/_new_button.haml +0 -2
- data/lib/generators/hot_glue/templates/haml/_new_form.haml +0 -7
- data/lib/generators/hot_glue/templates/haml/_show.haml +0 -7
- data/lib/generators/hot_glue/templates/haml/create.turbo_stream.haml +0 -14
- data/lib/generators/hot_glue/templates/haml/destroy.turbo_stream.haml +0 -2
- data/lib/generators/hot_glue/templates/haml/edit.haml +0 -19
- data/lib/generators/hot_glue/templates/haml/edit.turbo_stream.haml +0 -4
- data/lib/generators/hot_glue/templates/haml/index.haml +0 -8
- data/lib/generators/hot_glue/templates/haml/new.haml +0 -1
- data/lib/generators/hot_glue/templates/haml/update.turbo_stream.haml +0 -9
@@ -1,8 +1,10 @@
|
|
1
1
|
class AttachmentField < Field
|
2
2
|
attr_accessor :attachment_data
|
3
3
|
def initialize(name:, class_name:, alt_lookups:, singular:, update_show_only:, hawk_keys:, auth:,
|
4
|
-
sample_file_path: nil, attachment_data:
|
4
|
+
sample_file_path: nil, attachment_data:, ownership_field:, layout_strategy: ,
|
5
|
+
form_placeholder_labels: , form_labels_position:)
|
5
6
|
super
|
7
|
+
|
6
8
|
@attachment_data = attachment_data
|
7
9
|
end
|
8
10
|
|
@@ -30,7 +32,9 @@ class AttachmentField < Field
|
|
30
32
|
return field_result
|
31
33
|
end
|
32
34
|
|
33
|
-
def
|
34
|
-
|
35
|
+
def line_field_output
|
36
|
+
thumbnail = attachment_data[:thumbnail]
|
37
|
+
|
38
|
+
(thumbnail ? "<%= #{singular}.#{name}.attached? ? image_tag(#{singular}.#{name}.variant(:#{thumbnail})) : '' %>" : "")
|
35
39
|
end
|
36
40
|
end
|
@@ -15,4 +15,25 @@ class BooleanField < Field
|
|
15
15
|
def spec_list_view_assertion
|
16
16
|
" " + ["expect(page).to have_content(#{singular}#{1}.#{name} ? 'YES' : 'NO')"].join("\n ")
|
17
17
|
end
|
18
|
+
|
19
|
+
|
20
|
+
def form_field_output
|
21
|
+
(form_labels_position == 'before' ? " <br />" : "") +
|
22
|
+
" <%= f.radio_button(:#{name}, '0', checked: #{singular}.#{name} ? '' : 'checked') %>\n" +
|
23
|
+
" <%= f.label(:#{name}, value: 'No', for: '#{singular}_#{name}_0') %>\n" +
|
24
|
+
" <%= f.radio_button(:#{name}, '1', checked: #{singular}.#{name} ? 'checked' : '') %>\n" +
|
25
|
+
" <%= f.label(:#{name}, value: 'Yes', for: '#{singular}_#{name}_1') %>\n" +
|
26
|
+
(form_labels_position == 'after' ? " <br />" : "")
|
27
|
+
end
|
28
|
+
|
29
|
+
def line_field_output
|
30
|
+
"
|
31
|
+
<% if #{singular}.#{name}.nil? %>
|
32
|
+
<span class='alert-danger'>MISSING</span>
|
33
|
+
<% elsif #{singular}.#{name} %>
|
34
|
+
YES
|
35
|
+
<% else %>
|
36
|
+
NO
|
37
|
+
<% end %>"
|
38
|
+
end
|
18
39
|
end
|
@@ -7,4 +7,17 @@ class DateField < Field
|
|
7
7
|
def spec_setup_let_arg
|
8
8
|
"#{name}: Date.current + rand(50).days"
|
9
9
|
end
|
10
|
+
|
11
|
+
|
12
|
+
def form_field_output
|
13
|
+
"<%= date_field_localized(f, :#{name}, #{singular}.#{name}, '#{ name.to_s.humanize }', #{auth ? auth+'.timezone' : 'nil'}) %>"
|
14
|
+
end
|
15
|
+
|
16
|
+
def line_field_output
|
17
|
+
"<% unless #{singular}.#{name}.nil? %>
|
18
|
+
<%= #{singular}.#{name} %>
|
19
|
+
<% else %>
|
20
|
+
<span class='alert-danger'>MISSING</span>
|
21
|
+
<% end %>"
|
22
|
+
end
|
10
23
|
end
|
@@ -10,7 +10,7 @@ class DateTimeField < Field
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def spec_make_assertion
|
13
|
-
|
13
|
+
"expect(page).to have_content(new_#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone))"
|
14
14
|
end
|
15
15
|
|
16
16
|
def spec_setup_let_arg
|
@@ -18,6 +18,18 @@ class DateTimeField < Field
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def spec_list_view_assertion
|
21
|
-
"
|
21
|
+
"expect(page).to have_content(#{singular}#{1}.#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ').gsub(' ', ' ') + timezonize(current_timezone) )"
|
22
|
+
end
|
23
|
+
|
24
|
+
def form_field_output
|
25
|
+
"<%= datetime_field_localized(f, :#{name}, #{singular}.#{name}, '#{ name.to_s.humanize }', #{auth ? auth+'.timezone' : 'nil'}) %>"
|
26
|
+
end
|
27
|
+
|
28
|
+
def line_field_output
|
29
|
+
"<% unless #{singular}.#{name}.nil? %>
|
30
|
+
<%= #{singular}.#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone) %>
|
31
|
+
<% else %>
|
32
|
+
<span class='alert-danger'>MISSING</span>
|
33
|
+
<% end %>"
|
22
34
|
end
|
23
35
|
end
|
@@ -1,12 +1,17 @@
|
|
1
1
|
class EnumField < Field
|
2
2
|
def spec_setup_and_change_act(which_partial = nil)
|
3
|
-
|
4
|
-
"
|
5
|
-
|
3
|
+
# what is the enum name
|
4
|
+
" list_of_#{enum_type} = #{class_name}.defined_enums['#{enum_type}'].keys \n" +
|
5
|
+
" " + "new_#{name} = list_of_#{enum_type}[rand(list_of_#{enum_type}.length)].to_s \n" +
|
6
|
+
' find("select[name=\'' + singular + '[' + name + ']\'] option[value=\'#{new_' + name + '}\']").select_option'
|
7
|
+
end
|
8
|
+
|
9
|
+
def enum_type
|
10
|
+
eval("#{class_name}.columns.select{|x| x.name == '#{name}'}[0].sql_type")
|
6
11
|
end
|
7
12
|
|
8
13
|
def spec_make_assertion
|
9
|
-
if(eval("#{
|
14
|
+
if(eval("#{class_name}.respond_to?(:#{name}_labels)"))
|
10
15
|
"expect(page).to have_content(#{singular_class}.#{name}_labels[new_#{name}])"
|
11
16
|
else
|
12
17
|
"expect(page).to have_content(new_#{name})"
|
@@ -18,10 +23,38 @@ class EnumField < Field
|
|
18
23
|
end
|
19
24
|
|
20
25
|
def spec_list_view_assertion
|
21
|
-
if(eval("#{
|
22
|
-
"
|
26
|
+
if(eval("#{class_name}.respond_to?(:#{name}_labels)"))
|
27
|
+
"expect(page).to have_content(#{class_name}.#{name}_labels[#{singular}#{1}.#{name}])"
|
28
|
+
else
|
29
|
+
"expect(page).to have_content(#{singular}1.#{name})"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def form_field_output
|
34
|
+
enum_type = eval("#{class_name}.columns.select{|x| x.name == '#{name}'}[0].sql_type")
|
35
|
+
|
36
|
+
if eval("defined? #{class_name}.#{enum_type}_labels") == "method"
|
37
|
+
enum_definer = "#{class_name}.#{enum_type}_labels"
|
38
|
+
else
|
39
|
+
enum_definer = "#{class_name}.defined_enums['#{enum_type}']"
|
40
|
+
end
|
41
|
+
return "<%= f.collection_select(:#{name}, enum_to_collection_select(#{enum_definer}), :key, :value, {selected: #{singular}.#{name} }, class: 'form-control') %>"
|
42
|
+
end
|
43
|
+
|
44
|
+
def line_field_output
|
45
|
+
enum_type = eval("#{class_name}.columns.select{|x| x.name == '#{name}'}[0].sql_type")
|
46
|
+
|
47
|
+
if eval("defined? #{class_name}.#{enum_type}_labels") == "method"
|
48
|
+
enum_definer = "#{class_name}.#{enum_type}_labels"
|
23
49
|
else
|
24
|
-
|
50
|
+
enum_definer = "#{class_name}.defined_enums['#{enum_type}']"
|
25
51
|
end
|
52
|
+
"
|
53
|
+
<% if #{singular}.#{name}.nil? %>
|
54
|
+
<span class='alert-danger'>MISSING</span>
|
55
|
+
<% else %>
|
56
|
+
<%= #{enum_definer}[#{singular}.#{name}.to_sym] %>
|
57
|
+
<% end %>
|
58
|
+
"
|
26
59
|
end
|
27
60
|
end
|
@@ -3,11 +3,16 @@ class Field
|
|
3
3
|
:update_show_only
|
4
4
|
attr_accessor :assoc_model, :assoc_name, :assoc_class, :associations, :alt_lookups, :assoc_label
|
5
5
|
|
6
|
-
attr_accessor :hawk_keys, :auth, :sample_file_path
|
6
|
+
attr_accessor :hawk_keys, :auth, :sample_file_path, :form_placeholder_labels, :ownership_field,
|
7
|
+
:sql_type, :limit, :layout_strategy, :form_labels_position
|
8
|
+
|
9
|
+
def initialize(name: , class_name: , alt_lookups: , singular: , update_show_only: , form_labels_position:,
|
10
|
+
form_placeholder_labels: ,
|
11
|
+
auth: , ownership_field: , hawk_keys: nil, layout_strategy: ,
|
12
|
+
sample_file_path: nil, attachment_data: nil )
|
7
13
|
|
8
|
-
def initialize(name: , class_name: , alt_lookups: , singular: , update_show_only: ,
|
9
|
-
hawk_keys: , auth: , sample_file_path: nil, attachment_data: nil )
|
10
14
|
@name = name
|
15
|
+
@layout_strategy = layout_strategy
|
11
16
|
@alt_lookups = alt_lookups
|
12
17
|
@singular = singular
|
13
18
|
@class_name = class_name
|
@@ -15,12 +20,26 @@ class Field
|
|
15
20
|
@hawk_keys = hawk_keys
|
16
21
|
@auth = auth
|
17
22
|
@sample_file_path = sample_file_path
|
23
|
+
@form_placeholder_labels = form_placeholder_labels
|
24
|
+
@ownership_field = ownership_field
|
25
|
+
@form_labels_position = form_labels_position
|
26
|
+
|
27
|
+
|
28
|
+
# TODO: remove knowledge of subclasses from Field
|
29
|
+
unless self.class == AttachmentField
|
30
|
+
@sql_type = eval("#{class_name}.columns_hash['#{name}']").sql_type
|
31
|
+
@limit = eval("#{class_name}.columns_hash['#{name}']").limit
|
32
|
+
end
|
18
33
|
end
|
19
34
|
|
20
35
|
def getName
|
21
36
|
@name
|
22
37
|
end
|
23
38
|
|
39
|
+
def field_error_name
|
40
|
+
name
|
41
|
+
end
|
42
|
+
|
24
43
|
def spec_random_data
|
25
44
|
|
26
45
|
end
|
@@ -42,10 +61,31 @@ class Field
|
|
42
61
|
end
|
43
62
|
|
44
63
|
def spec_list_view_assertion
|
45
|
-
"
|
64
|
+
"expect(page).to have_content(#{singular}#{1}.#{name})"
|
46
65
|
end
|
47
66
|
|
48
67
|
def spec_related_column_lets
|
49
68
|
""
|
50
69
|
end
|
70
|
+
|
71
|
+
def form_show_only_output
|
72
|
+
"<%= #{singular}.#{name} %>"
|
73
|
+
end
|
74
|
+
|
75
|
+
def line_field_output
|
76
|
+
"<%= #{singular}.#{name} %>"
|
77
|
+
end
|
78
|
+
|
79
|
+
def field_output(type = nil, width )
|
80
|
+
" <%= f.text_field :#{name}, value: #{singular}.#{name}, autocomplete: 'off', size: #{width}, class: 'form-control', type: '#{type}'" + (form_placeholder_labels ? ", placeholder: '#{name.to_s.humanize}'" : "") + " %>\n " + "\n"
|
81
|
+
end
|
82
|
+
|
83
|
+
def text_area_output(field_length )
|
84
|
+
lines = field_length % 40
|
85
|
+
if lines > 5
|
86
|
+
lines = 5
|
87
|
+
end
|
88
|
+
|
89
|
+
"<%= f.text_area :#{name}, class: 'form-control', autocomplete: 'off', cols: 40, rows: '#{lines}'" + ( form_placeholder_labels ? ", placeholder: '#{name.to_s.humanize}'" : "") + " %>"
|
90
|
+
end
|
51
91
|
end
|
@@ -8,4 +8,13 @@ class FloatField < Field
|
|
8
8
|
def spec_setup_let_arg
|
9
9
|
"#{name}: rand(1)*10000"
|
10
10
|
end
|
11
|
+
|
12
|
+
def form_field_output
|
13
|
+
field_output(nil, 5)
|
14
|
+
end
|
15
|
+
|
16
|
+
def line_field_output
|
17
|
+
width = (limit && limit < 40) ? limit : (40)
|
18
|
+
"<%= #{singular}.#{name}%>"
|
19
|
+
end
|
11
20
|
end
|
@@ -21,6 +21,10 @@ class IntegerField < Field
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def spec_list_view_assertion
|
24
|
-
"
|
24
|
+
"expect(page).to have_content(#{singular}#{1}.#{name})"
|
25
|
+
end
|
26
|
+
|
27
|
+
def form_field_output
|
28
|
+
" <%= f.text_field :#{name}, value: #{singular}.#{name}, autocomplete: 'off', size: 4, class: 'form-control', type: 'number'" + (form_placeholder_labels ? ", placeholder: '#{name.to_s.humanize}'" : "") + " %>\n " + "\n"
|
25
29
|
end
|
26
30
|
end
|
@@ -30,4 +30,21 @@ class StringField < Field
|
|
30
30
|
"#{name}: FFaker::Movie.title"
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
def form_field_output
|
35
|
+
if sql_type == "varchar" || sql_type == "character varying"
|
36
|
+
field_output(nil, limit || 40)
|
37
|
+
else
|
38
|
+
text_area_output( 65536)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: dry with text_field.rb
|
43
|
+
def text_result(col, sql_type, limit)
|
44
|
+
if sql_type == "varchar"
|
45
|
+
field_output( nil, limit)
|
46
|
+
else
|
47
|
+
text_area_output( 65536)
|
48
|
+
end
|
49
|
+
end
|
33
50
|
end
|
@@ -11,4 +11,21 @@ class TextField < Field
|
|
11
11
|
def spec_setup_let_arg
|
12
12
|
"#{name}: FFaker::Lorem.paragraphs(10).join(" ")"
|
13
13
|
end
|
14
|
+
|
15
|
+
def form_field_output
|
16
|
+
if sql_type == "varchar" || sql_type == "character varying"
|
17
|
+
field_output( nil, limit || 40)
|
18
|
+
else
|
19
|
+
text_area_output( 65536)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# TODO: dry with string_field.rb
|
24
|
+
def text_result( sql_type, limit)
|
25
|
+
if sql_type == "varchar"
|
26
|
+
field_output( nil, limit)
|
27
|
+
else
|
28
|
+
text_area_output( 65536)
|
29
|
+
end
|
30
|
+
end
|
14
31
|
end
|
@@ -3,4 +3,24 @@ class TimeField < Field
|
|
3
3
|
def spec_setup_let_arg
|
4
4
|
"#{name}: Time.current + rand(5000).seconds"
|
5
5
|
end
|
6
|
+
|
7
|
+
def form_field_output
|
8
|
+
"<%= time_field_localized(f, :#{name}, #{singular}.#{name}, '#{ name.to_s.humanize }', #{auth ? auth+'.timezone' : 'nil'}) %>"
|
9
|
+
end
|
10
|
+
|
11
|
+
def line_field_output
|
12
|
+
"<% unless #{singular}.#{name}.nil? %>
|
13
|
+
<%= #{singular}.#{name}.in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone) %>
|
14
|
+
<% else %>
|
15
|
+
<span class='alert-danger'>MISSING</span>
|
16
|
+
<% end %>"
|
17
|
+
end
|
18
|
+
|
19
|
+
def spec_make_assertion
|
20
|
+
"#expect(page).to have_content(new_#{name} .in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone))"
|
21
|
+
end
|
22
|
+
|
23
|
+
def spec_list_view_assertion
|
24
|
+
"#expect(page).to have_content(#{singular}#{1}.#{name})"
|
25
|
+
end
|
6
26
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class UUIDField <
|
1
|
+
class UUIDField < AssociationField
|
2
2
|
def spec_setup_let_arg
|
3
3
|
"#{name.to_s.gsub('_id','')}: #{name.to_s.gsub('_id','')}1"
|
4
4
|
end
|
@@ -6,7 +6,6 @@ class UUIDField < Field
|
|
6
6
|
def spec_list_view_assertion
|
7
7
|
assoc_name = name.to_s.gsub('_id','')
|
8
8
|
association = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
|
9
|
-
"
|
10
|
-
|
9
|
+
"expect(page).to have_content(#{singular}#{1}.#{assoc_name}.#{HotGlue.derrive_reference_name(association.class_name)})"
|
11
10
|
end
|
12
11
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module HotGlue
|
2
|
+
class FlashNoticesInstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('templates', __dir__)
|
4
|
+
|
5
|
+
def filepath_prefix
|
6
|
+
# todo: inject the context
|
7
|
+
'spec/dummy/' if $INTERNAL_SPECS
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def initialize(*args) #:nodoc:
|
12
|
+
super
|
13
|
+
copy_file "erb/_flash_notices.erb", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.erb"
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
@@ -13,6 +13,12 @@ module HotGlue
|
|
13
13
|
|
14
14
|
|
15
15
|
|
16
|
+
|
17
|
+
def filepath_prefix
|
18
|
+
'spec/dummy/' if $INTERNAL_SPECS
|
19
|
+
end
|
20
|
+
|
21
|
+
|
16
22
|
def initialize(*args) #:nodoc:
|
17
23
|
super
|
18
24
|
layout = options['layout'] || "hotglue"
|
@@ -27,13 +33,8 @@ module HotGlue
|
|
27
33
|
end
|
28
34
|
|
29
35
|
|
30
|
-
@markup = options['markup']
|
31
|
-
|
32
|
-
copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
|
33
|
-
elsif @markup == "erb"
|
34
|
-
copy_file "erb/_flash_notices.erb", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.erb"
|
35
|
-
|
36
|
-
end
|
36
|
+
@markup = options['markup'] || "erb"
|
37
|
+
copy_file "erb/_flash_notices.erb", "#{filepath_prefix}app/views/layouts/_flash_notices.erb"
|
37
38
|
|
38
39
|
begin
|
39
40
|
if Rails.version.split(".")[0].to_i == 6
|
@@ -56,7 +57,7 @@ module HotGlue
|
|
56
57
|
|
57
58
|
|
58
59
|
begin
|
59
|
-
rails_helper_contents = File.read("#{
|
60
|
+
rails_helper_contents = File.read("#{filepath_prefix}spec/rails_helper.rb")
|
60
61
|
if !rails_helper_contents.include?("Capybara.default_driver =")
|
61
62
|
rails_helper_contents << "\nCapybara.default_driver = :selenium_chrome_headless "
|
62
63
|
puts " HOTGLUE --> added to spec/rails_helper.rb: `Capybara.default_driver = :selenium_chrome_headless` "
|
@@ -66,14 +67,14 @@ module HotGlue
|
|
66
67
|
rails_helper_contents.gsub!("RSpec.configure do |config|", "RSpec.configure do |config| \n
|
67
68
|
config.include FactoryBot::Syntax::Methods
|
68
69
|
")
|
69
|
-
puts " HOTGLUE --> added to #{
|
70
|
+
puts " HOTGLUE --> added to #{filepath_prefix}spec/rails_helper.rb: `config.include FactoryBot::Syntax::Methods` "
|
70
71
|
end
|
71
72
|
|
72
73
|
if ! rails_helper_contents.include?("require 'support/capybara_login.rb'")
|
73
74
|
rails_helper_contents.gsub!("require 'rspec/rails'","require 'rspec/rails' \nrequire 'support/capybara_login.rb'")
|
74
75
|
puts " HOTGLUE --> added to spec/rails_helper.rb: `require 'support/capybara_login.rb'` "
|
75
76
|
end
|
76
|
-
File.write("#{
|
77
|
+
File.write("#{filepath_prefix}spec/rails_helper.rb", rails_helper_contents)
|
77
78
|
|
78
79
|
rescue StandardError => e
|
79
80
|
puts "WARNING: error writing to spec/rails_helper --- #{e.message}"
|
@@ -100,7 +101,7 @@ module HotGlue
|
|
100
101
|
theme_location = "themes/hotglue_scaffold_#{@theme}.scss"
|
101
102
|
theme_file = "hotglue_scaffold_#{@theme}.scss"
|
102
103
|
|
103
|
-
copy_file theme_location, "#{
|
104
|
+
copy_file theme_location, "#{filepath_prefix}app/assets/stylesheets/#{theme_file}"
|
104
105
|
|
105
106
|
application_scss = File.read("app/assets/stylesheets/application.scss")
|
106
107
|
|
@@ -119,10 +120,10 @@ module HotGlue
|
|
119
120
|
|
120
121
|
|
121
122
|
begin
|
122
|
-
if !File.exist?("#{
|
123
|
+
if !File.exist?("#{filepath_prefix}config/hot_glue.yml")
|
123
124
|
yaml = {layout: layout,
|
124
125
|
markup: @markup}.to_yaml
|
125
|
-
File.write("#{
|
126
|
+
File.write("#{filepath_prefix}config/hot_glue.yml", yaml)
|
126
127
|
|
127
128
|
end
|
128
129
|
rescue StandardError => e
|
@@ -131,8 +132,8 @@ module HotGlue
|
|
131
132
|
|
132
133
|
|
133
134
|
begin
|
134
|
-
if !File.exist?("#{
|
135
|
-
copy_file "capybara_login.rb", "#{
|
135
|
+
if !File.exist?("#{filepath_prefix}spec/support/capybara_login.rb")
|
136
|
+
copy_file "capybara_login.rb", "#{filepath_prefix}spec/support/capybara_login.rb"
|
136
137
|
end
|
137
138
|
rescue StandardError => e
|
138
139
|
puts "WARNING: error writing to #{Rails.env.test? ? 'spec/dummmy/' : ''}spec/support/capybara_login.rb --- #{e.message}"
|