cookbook 0.1.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.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +10 -0
  5. data/Gemfile +39 -0
  6. data/Gemfile.lock +367 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +105 -0
  9. data/Rakefile +52 -0
  10. data/VERSION +1 -0
  11. data/app/assets/stylesheets/cookbook/application.scss +180 -0
  12. data/app/controllers/concerns/cookbook/params.rb +27 -0
  13. data/app/helpers/cookbook/application_helper.rb +38 -0
  14. data/app/models/cookbook/use.rb +26 -0
  15. data/app/views/cookbook/_fields.html.haml +11 -0
  16. data/app/views/cookbook/_used_in.html.haml +15 -0
  17. data/app/views/cookbook/_uses_of.html.haml +11 -0
  18. data/app/views/cookbook/uses/_fields.html.haml +17 -0
  19. data/bin/rails +16 -0
  20. data/config/initializers/simple_form.rb +180 -0
  21. data/config/locales/simple_form.en.yml +31 -0
  22. data/cookbook.gemspec +249 -0
  23. data/db/migrate/20210909141929_create_uses.cookbook.rb +21 -0
  24. data/lib/cookbook/configuration.rb +28 -0
  25. data/lib/cookbook/engine.rb +34 -0
  26. data/lib/cookbook/extensions/float.rb +10 -0
  27. data/lib/cookbook/mixins/acts_as_use_of.rb +45 -0
  28. data/lib/cookbook/mixins/acts_as_used_in.rb +43 -0
  29. data/lib/cookbook/railtie.rb +6 -0
  30. data/lib/cookbook/version.rb +9 -0
  31. data/lib/cookbook.rb +27 -0
  32. data/lib/tasks/cookbook_tasks.rake +5 -0
  33. data/lib/templates/haml/scaffold/_form.html.haml +12 -0
  34. data/spec/cookbook_spec.rb +9 -0
  35. data/spec/dummy/Rakefile +8 -0
  36. data/spec/dummy/app/assets/config/manifest.js +2 -0
  37. data/spec/dummy/app/assets/images/.keep +0 -0
  38. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  39. data/spec/dummy/app/assets/stylesheets/scaffolds.scss +65 -0
  40. data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
  41. data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
  42. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  43. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  44. data/spec/dummy/app/controllers/how_tos_controller.rb +61 -0
  45. data/spec/dummy/app/controllers/ingredients_controller.rb +60 -0
  46. data/spec/dummy/app/controllers/recipes_controller.rb +61 -0
  47. data/spec/dummy/app/controllers/supplies_controller.rb +60 -0
  48. data/spec/dummy/app/controllers/tools_controller.rb +60 -0
  49. data/spec/dummy/app/javascript/packs/application.js +16 -0
  50. data/spec/dummy/app/jobs/application_job.rb +9 -0
  51. data/spec/dummy/app/mailers/application_mailer.rb +6 -0
  52. data/spec/dummy/app/models/ability.rb +21 -0
  53. data/spec/dummy/app/models/application_record.rb +7 -0
  54. data/spec/dummy/app/models/concerns/.keep +0 -0
  55. data/spec/dummy/app/models/how_to.rb +5 -0
  56. data/spec/dummy/app/models/ingredient.rb +5 -0
  57. data/spec/dummy/app/models/recipe.rb +5 -0
  58. data/spec/dummy/app/models/supply.rb +5 -0
  59. data/spec/dummy/app/models/tool.rb +5 -0
  60. data/spec/dummy/app/models/user.rb +8 -0
  61. data/spec/dummy/app/views/how_tos/_form.html.haml +7 -0
  62. data/spec/dummy/app/views/how_tos/edit.html.haml +7 -0
  63. data/spec/dummy/app/views/how_tos/index.html.haml +25 -0
  64. data/spec/dummy/app/views/how_tos/new.html.haml +5 -0
  65. data/spec/dummy/app/views/how_tos/show.html.haml +17 -0
  66. data/spec/dummy/app/views/ingredients/_form.html.haml +8 -0
  67. data/spec/dummy/app/views/ingredients/edit.html.haml +7 -0
  68. data/spec/dummy/app/views/ingredients/index.html.haml +29 -0
  69. data/spec/dummy/app/views/ingredients/new.html.haml +5 -0
  70. data/spec/dummy/app/views/ingredients/show.html.haml +23 -0
  71. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  72. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  73. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  74. data/spec/dummy/app/views/recipes/_form.html.haml +9 -0
  75. data/spec/dummy/app/views/recipes/edit.html.haml +7 -0
  76. data/spec/dummy/app/views/recipes/index.html.haml +29 -0
  77. data/spec/dummy/app/views/recipes/new.html.haml +5 -0
  78. data/spec/dummy/app/views/recipes/show.html.haml +23 -0
  79. data/spec/dummy/app/views/supplies/_form.html.haml +6 -0
  80. data/spec/dummy/app/views/supplies/edit.html.haml +7 -0
  81. data/spec/dummy/app/views/supplies/index.html.haml +25 -0
  82. data/spec/dummy/app/views/supplies/new.html.haml +5 -0
  83. data/spec/dummy/app/views/supplies/show.html.haml +17 -0
  84. data/spec/dummy/app/views/tools/_form.html.haml +6 -0
  85. data/spec/dummy/app/views/tools/edit.html.haml +7 -0
  86. data/spec/dummy/app/views/tools/index.html.haml +25 -0
  87. data/spec/dummy/app/views/tools/new.html.haml +5 -0
  88. data/spec/dummy/app/views/tools/show.html.haml +17 -0
  89. data/spec/dummy/bin/rails +6 -0
  90. data/spec/dummy/bin/rake +6 -0
  91. data/spec/dummy/bin/setup +35 -0
  92. data/spec/dummy/config/application.rb +28 -0
  93. data/spec/dummy/config/boot.rb +7 -0
  94. data/spec/dummy/config/cable.yml +10 -0
  95. data/spec/dummy/config/database.yml +25 -0
  96. data/spec/dummy/config/environment.rb +7 -0
  97. data/spec/dummy/config/environments/development.rb +80 -0
  98. data/spec/dummy/config/environments/production.rb +122 -0
  99. data/spec/dummy/config/environments/test.rb +61 -0
  100. data/spec/dummy/config/initializers/application_controller_renderer.rb +9 -0
  101. data/spec/dummy/config/initializers/assets.rb +14 -0
  102. data/spec/dummy/config/initializers/backtrace_silencers.rb +10 -0
  103. data/spec/dummy/config/initializers/content_security_policy.rb +29 -0
  104. data/spec/dummy/config/initializers/cookbook.rb +6 -0
  105. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  106. data/spec/dummy/config/initializers/devise.rb +313 -0
  107. data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  108. data/spec/dummy/config/initializers/inflections.rb +17 -0
  109. data/spec/dummy/config/initializers/json.rb +20 -0
  110. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  111. data/spec/dummy/config/initializers/permissions_policy.rb +12 -0
  112. data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
  113. data/spec/dummy/config/locales/devise.en.yml +65 -0
  114. data/spec/dummy/config/locales/en.yml +33 -0
  115. data/spec/dummy/config/puma.rb +45 -0
  116. data/spec/dummy/config/routes.rb +13 -0
  117. data/spec/dummy/config/storage.yml +34 -0
  118. data/spec/dummy/config.ru +8 -0
  119. data/spec/dummy/db/development.sqlite3 +0 -0
  120. data/spec/dummy/db/migrate/20210909175711_create_how_tos.rb +16 -0
  121. data/spec/dummy/db/migrate/20210909181442_create_ingredients.rb +16 -0
  122. data/spec/dummy/db/migrate/20210909181455_create_supplies.rb +14 -0
  123. data/spec/dummy/db/migrate/20210909181516_create_tools.rb +14 -0
  124. data/spec/dummy/db/migrate/20210909181533_create_recipes.rb +16 -0
  125. data/spec/dummy/db/migrate/20210909185303_create_uses.cookbook.rb +23 -0
  126. data/spec/dummy/db/migrate/20210910142322_create_users.rb +11 -0
  127. data/spec/dummy/db/migrate/20210910142323_add_devise_to_users.rb +50 -0
  128. data/spec/dummy/db/schema.rb +92 -0
  129. data/spec/dummy/db/seeds.rb +10 -0
  130. data/spec/dummy/db/test.sqlite3 +0 -0
  131. data/spec/dummy/lib/assets/.keep +0 -0
  132. data/spec/dummy/lib/templates/haml/scaffold/_form.html.haml +6 -0
  133. data/spec/dummy/log/.keep +0 -0
  134. data/spec/dummy/log/development.log +6643 -0
  135. data/spec/dummy/log/test.log +25990 -0
  136. data/spec/dummy/public/404.html +67 -0
  137. data/spec/dummy/public/422.html +67 -0
  138. data/spec/dummy/public/500.html +66 -0
  139. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  140. data/spec/dummy/public/apple-touch-icon.png +0 -0
  141. data/spec/dummy/public/favicon.ico +0 -0
  142. data/spec/dummy/storage/.keep +0 -0
  143. data/spec/factories/how_tos.rb +9 -0
  144. data/spec/factories/ingredients.rb +11 -0
  145. data/spec/factories/recipes.rb +11 -0
  146. data/spec/factories/supplies.rb +9 -0
  147. data/spec/factories/tools.rb +9 -0
  148. data/spec/factories/users.rb +9 -0
  149. data/spec/factories/uses.rb +24 -0
  150. data/spec/helpers/cookbook/application_helper_spec.rb +47 -0
  151. data/spec/models/cookbook/use_spec.rb +82 -0
  152. data/spec/models/how_to_spec.rb +18 -0
  153. data/spec/models/ingredient_spec.rb +15 -0
  154. data/spec/models/recipe_spec.rb +18 -0
  155. data/spec/models/supply_spec.rb +15 -0
  156. data/spec/models/tool_spec.rb +15 -0
  157. data/spec/rails_helper.rb +92 -0
  158. data/spec/requests/how_tos_spec.rb +114 -0
  159. data/spec/requests/recipes_spec.rb +116 -0
  160. data/spec/spec_helper.rb +44 -0
  161. metadata +517 -0
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe Ingredient, type: :model do
6
+ describe 'Relationships' do
7
+ it { should have_many(:uses) }
8
+
9
+ it { should have_many(:recipe_uses) }
10
+ it { should have_many(:recipes).through(:uses) }
11
+
12
+ it { should_not have_many(:how_to_uses) }
13
+ it { should_not have_many(:how_tos).through(:uses) }
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe Recipe, type: :model do
6
+ describe 'Relationships' do
7
+ it { should have_many(:uses) }
8
+
9
+ it { should have_many(:ingredient_uses) }
10
+ it { should have_many(:ingredients).through(:uses) }
11
+
12
+ it { should have_many(:supply_uses) }
13
+ it { should have_many(:supplies).through(:uses) }
14
+
15
+ it { should have_many(:tool_uses) }
16
+ it { should have_many(:tools).through(:uses) }
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe Supply, type: :model do
6
+ describe 'Relationships' do
7
+ it { should have_many(:uses) }
8
+
9
+ it { should have_many(:recipe_uses) }
10
+ it { should have_many(:recipes).through(:uses) }
11
+
12
+ it { should have_many(:how_to_uses) }
13
+ it { should have_many(:how_tos).through(:uses) }
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe Tool, type: :model do
6
+ describe 'Relationships' do
7
+ it { should have_many(:uses) }
8
+
9
+ it { should have_many(:recipe_uses) }
10
+ it { should have_many(:recipes).through(:uses) }
11
+
12
+ it { should have_many(:how_to_uses) }
13
+ it { should have_many(:how_tos).through(:uses) }
14
+ end
15
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ # Previous content of test helper now starts here
7
+
8
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
9
+ ENV['RAILS_ENV'] ||= 'test'
10
+ require 'spec_helper'
11
+ require File.expand_path('dummy/config/environment', __dir__)
12
+ # Add additional requires below this line. Rails is not loaded until this point!
13
+ require 'rspec/rails'
14
+ require 'shoulda/matchers'
15
+ require 'factory_bot_rails'
16
+ require 'capybara/rspec'
17
+ require 'database_cleaner'
18
+ require 'rake'
19
+
20
+ # Requires supporting ruby files with custom matchers and macros, etc, in
21
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
22
+ # run as spec files by default. This means that files in spec/support that end
23
+ # in _spec.rb will both be required and run as specs, causing the specs to be
24
+ # run twice. It is recommended that you do not name files matching this glob to
25
+ # end with _spec.rb. You can configure this pattern with the --pattern
26
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
27
+ #
28
+ # The following line is provided for convenience purposes. It has the downside
29
+ # of increasing the boot-up time by auto-requiring all files in the support
30
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
31
+ # require only the support files necessary.
32
+ #
33
+ Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
34
+ Dir['./spec/support/**/**/*.rb'].sort.each { |f| require f }
35
+
36
+ ActiveRecord::Migrator.migrations_paths = 'spec/dummy/db/migrate'
37
+
38
+ # Checks for pending migrations before tests are run.
39
+ # If you are not using ActiveRecord, you can remove this line.
40
+ # ActiveRecord::Migration.maintain_test_schema!
41
+
42
+ RSpec.configure do |config|
43
+ config.before(:suite) do
44
+ DatabaseCleaner.strategy = :transaction
45
+ DatabaseCleaner.clean_with(:truncation)
46
+ Dummy::Application.load_tasks
47
+ Rake::Task['db:seed'].invoke # loading seeds
48
+ end
49
+ config.around(:each) do |example|
50
+ DatabaseCleaner.cleaning do
51
+ example.run
52
+ end
53
+ end
54
+
55
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
56
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures
57
+
58
+ config.expect_with(:rspec) { |c| c.syntax = %i[should expect] }
59
+
60
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
61
+ # examples within a transaction, remove the following line or assign false
62
+ # instead of true.
63
+ # config.use_transactional_fixtures = true
64
+
65
+ # RSpec Rails can automatically mix in different behaviours to your tests
66
+ # based on their file location, for example enabling you to call `get` and
67
+ # `post` in specs under `spec/controllers`.
68
+ #
69
+ # You can disable this behaviour by removing the line below, and instead
70
+ # explicitly tag your specs with their type, e.g.:
71
+ #
72
+ # RSpec.describe UsersController, type: :controller do
73
+ # # ...
74
+ # end
75
+ #
76
+ # The different available types are documented in the features, such as in
77
+ # https://relishapp.com/rspec/rspec-rails/docs
78
+ config.infer_spec_type_from_file_location!
79
+ config.include RSpecHtmlMatchers
80
+
81
+ # This allows us to log in in request specs
82
+ # https://stackoverflow.com/questions/15211576/rspec-authenticating-devise-user-in-request-specs
83
+ config.include Devise::Test::IntegrationHelpers, type: :request
84
+ config.include Devise::Test::ControllerHelpers, type: :controller
85
+ end
86
+
87
+ Shoulda::Matchers.configure do |config|
88
+ config.integrate do |with|
89
+ with.test_framework :rspec
90
+ with.library :rails
91
+ end
92
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ module Cookbook
6
+ RSpec.describe '/how_tos', type: :request do
7
+ include Engine.routes.url_helpers
8
+ let(:tool) { FactoryBot.create(:tool) }
9
+ let(:supply) { FactoryBot.create(:supply) }
10
+ let(:how_to) { FactoryBot.create(:how_to) }
11
+
12
+ # HowTo. As you add validations to HowTo, be sure to
13
+ # adjust the attributes here as well.
14
+ let(:valid_attributes) do
15
+ {
16
+ name: Faker::Book.title,
17
+ tool_uses_attributes: FactoryBot.build(:use, use_of_id: tool.id, use_of_type: 'Tool'),
18
+ supply_uses_attributes: FactoryBot.build(:use, use_of_id: supply.id, use_of_type: 'Supply')
19
+ }
20
+ end
21
+
22
+ describe 'GET /show' do
23
+ it 'renders a successful response when admin' do
24
+ get how_to_url(how_to)
25
+ expect(response).to be_successful
26
+ end
27
+ end
28
+
29
+ describe 'GET /index' do
30
+ before do
31
+ how_to
32
+ end
33
+ it 'renders a successful response when admin' do
34
+ get how_tos_url
35
+ expect(response).to be_successful
36
+ end
37
+ end
38
+
39
+ describe 'GET /new' do
40
+ it 'renders a successful response when admin' do
41
+ get new_how_to_url
42
+ expect(response).to be_successful
43
+ end
44
+ end
45
+
46
+ describe 'GET /edit' do
47
+ it 'render a successful response when admin' do
48
+ get edit_how_to_url(how_to)
49
+ expect(response).to be_successful
50
+ end
51
+ end
52
+
53
+ describe 'POST /create' do
54
+ context 'with valid parameters' do
55
+ it 'creates a new HowTo' do
56
+ expect do
57
+ post how_tos_url, params: { how_to: valid_attributes }
58
+ end.to change(HowTo, :count).by(1)
59
+ end
60
+
61
+ it 'redirects to the created how_to' do
62
+ post how_tos_url, params: { how_to: valid_attributes }
63
+ expect(response).to redirect_to(how_to_url(HowTo.last))
64
+ end
65
+ end
66
+ end
67
+
68
+ describe 'PATCH /update' do
69
+ let(:new_attributes) do
70
+ {
71
+ name: 'Foo',
72
+ tool_uses_attributes: [
73
+ {
74
+ use_of_id: tool.id,
75
+ use_of_type: 'Tool',
76
+ note: 'Test Note'
77
+ }
78
+ ]
79
+ }
80
+ end
81
+ context 'with valid parameters' do
82
+ it 'updates the requested how_to' do
83
+ patch how_to_url(how_to), params: { how_to: new_attributes }
84
+ how_to.reload
85
+ expect(how_to.name).to eq('Foo')
86
+ expect(how_to.tool_uses.last.note).to eq('Test Note')
87
+ end
88
+
89
+ it 'redirects to the how_to' do
90
+ patch how_to_url(how_to), params: { how_to: new_attributes }
91
+ how_to.reload
92
+ expect(response).to redirect_to(how_to_url(how_to))
93
+ end
94
+ end
95
+ end
96
+
97
+ describe 'DELETE /destroy' do
98
+ before do
99
+ how_to # Call it up so it exists ahead of time
100
+ end
101
+
102
+ it 'destroys the requested how_to' do
103
+ expect do
104
+ delete how_to_url(how_to)
105
+ end.to change(HowTo, :count).by(-1)
106
+ end
107
+
108
+ it 'redirects to the how_tos list' do
109
+ delete how_to_url(how_to)
110
+ expect(response).to redirect_to(how_tos_url)
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ module Cookbook
6
+ RSpec.describe '/recipes', type: :request do
7
+ include Engine.routes.url_helpers
8
+ let(:ingredient) { FactoryBot.create(:ingredient) }
9
+ let(:tool) { FactoryBot.create(:tool) }
10
+ let(:supply) { FactoryBot.create(:supply) }
11
+ let(:recipe) { FactoryBot.create(:recipe) }
12
+
13
+ # Recipe. As you add validations to Recipe, be sure to
14
+ # adjust the attributes here as well.
15
+ let(:valid_attributes) do
16
+ {
17
+ name: Faker::Book.title,
18
+ ingredient_uses_attributes: FactoryBot.build(:use, use_of_id: ingredient.id, use_of_type: 'Ingredient'),
19
+ tool_uses_attributes: FactoryBot.build(:use, use_of_id: tool.id, use_of_type: 'Tool'),
20
+ supply_uses_attributes: FactoryBot.build(:use, use_of_id: supply.id, use_of_type: 'Supply')
21
+ }
22
+ end
23
+
24
+ describe 'GET /show' do
25
+ it 'renders a successful response when admin' do
26
+ get recipe_url(recipe)
27
+ expect(response).to be_successful
28
+ end
29
+ end
30
+
31
+ describe 'GET /index' do
32
+ before do
33
+ recipe
34
+ end
35
+ it 'renders a successful response when admin' do
36
+ get recipes_url
37
+ expect(response).to be_successful
38
+ end
39
+ end
40
+
41
+ describe 'GET /new' do
42
+ it 'renders a successful response when admin' do
43
+ get new_recipe_url
44
+ expect(response).to be_successful
45
+ end
46
+ end
47
+
48
+ describe 'GET /edit' do
49
+ it 'render a successful response when admin' do
50
+ get edit_recipe_url(recipe)
51
+ expect(response).to be_successful
52
+ end
53
+ end
54
+
55
+ describe 'POST /create' do
56
+ context 'with valid parameters' do
57
+ it 'creates a new Recipe' do
58
+ expect do
59
+ post recipes_url, params: { recipe: valid_attributes }
60
+ end.to change(Recipe, :count).by(1)
61
+ end
62
+
63
+ it 'redirects to the created recipe' do
64
+ post recipes_url, params: { recipe: valid_attributes }
65
+ expect(response).to redirect_to(recipe_url(Recipe.last))
66
+ end
67
+ end
68
+ end
69
+
70
+ describe 'PATCH /update' do
71
+ let(:new_attributes) do
72
+ {
73
+ name: 'Foo',
74
+ ingredient_uses_attributes: [
75
+ {
76
+ use_of_id: ingredient.id,
77
+ use_of_type: 'Ingredient',
78
+ note: 'Test Note'
79
+ }
80
+ ]
81
+ }
82
+ end
83
+ context 'with valid parameters' do
84
+ it 'updates the requested recipe' do
85
+ patch recipe_url(recipe), params: { recipe: new_attributes }
86
+ recipe.reload
87
+ expect(recipe.name).to eq('Foo')
88
+ expect(recipe.ingredient_uses.last.note).to eq('Test Note')
89
+ end
90
+
91
+ it 'redirects to the recipe' do
92
+ patch recipe_url(recipe), params: { recipe: new_attributes }
93
+ recipe.reload
94
+ expect(response).to redirect_to(recipe_url(recipe))
95
+ end
96
+ end
97
+ end
98
+
99
+ describe 'DELETE /destroy' do
100
+ before do
101
+ recipe # Call it up so it exists ahead of time
102
+ end
103
+
104
+ it 'destroys the requested recipe' do
105
+ expect do
106
+ delete recipe_url(recipe)
107
+ end.to change(Recipe, :count).by(-1)
108
+ end
109
+
110
+ it 'redirects to the recipes list' do
111
+ delete recipe_url(recipe)
112
+ expect(response).to redirect_to(recipes_url)
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by the `rails generate rspec:install` command.
4
+ # Conventionally, all specs live under a `spec` directory, which RSpec adds
5
+ # to the `$LOAD_PATH`. The generated `.rspec` file contains
6
+ # `--require spec_helper` which will cause this file to always be loaded,
7
+ # without a need to explicitly require it in any files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => 'be bigger than 2 and smaller than 4'
31
+ # ...rather than:
32
+ # # => 'be bigger than 2'
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,517 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cookbook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Loren Lundgren
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: haml-rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '2.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '3'
53
+ - !ruby/object:Gem::Dependency
54
+ name: sass-rails
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '6'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '7'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '6'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '7'
73
+ - !ruby/object:Gem::Dependency
74
+ name: cancancan
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '3.3'
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '4'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '3.3'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '4'
93
+ - !ruby/object:Gem::Dependency
94
+ name: simple_form
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '5.1'
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: '6'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '5.1'
110
+ - - "<"
111
+ - !ruby/object:Gem::Version
112
+ version: '6'
113
+ - !ruby/object:Gem::Dependency
114
+ name: vanilla_nested
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '1.3'
120
+ - - "<"
121
+ - !ruby/object:Gem::Version
122
+ version: '2'
123
+ type: :runtime
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '1.3'
130
+ - - "<"
131
+ - !ruby/object:Gem::Version
132
+ version: '2'
133
+ - !ruby/object:Gem::Dependency
134
+ name: database_cleaner
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '1.8'
140
+ - - "<"
141
+ - !ruby/object:Gem::Version
142
+ version: '2'
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '1.8'
150
+ - - "<"
151
+ - !ruby/object:Gem::Version
152
+ version: '2'
153
+ - !ruby/object:Gem::Dependency
154
+ name: devise
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '4.8'
160
+ - - "<"
161
+ - !ruby/object:Gem::Version
162
+ version: '5'
163
+ type: :development
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '4.8'
170
+ - - "<"
171
+ - !ruby/object:Gem::Version
172
+ version: '5'
173
+ - !ruby/object:Gem::Dependency
174
+ name: faker
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: sqlite3
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: 1.4.2
194
+ - - "<"
195
+ - !ruby/object:Gem::Version
196
+ version: '2'
197
+ type: :development
198
+ prerelease: false
199
+ version_requirements: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: 1.4.2
204
+ - - "<"
205
+ - !ruby/object:Gem::Version
206
+ version: '2'
207
+ - !ruby/object:Gem::Dependency
208
+ name: bundler
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '2'
214
+ - - "<"
215
+ - !ruby/object:Gem::Version
216
+ version: '3'
217
+ type: :development
218
+ prerelease: false
219
+ version_requirements: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '2'
224
+ - - "<"
225
+ - !ruby/object:Gem::Version
226
+ version: '3'
227
+ - !ruby/object:Gem::Dependency
228
+ name: factory_bot_rails
229
+ requirement: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ version: '5.1'
234
+ - - "<"
235
+ - !ruby/object:Gem::Version
236
+ version: '6'
237
+ type: :development
238
+ prerelease: false
239
+ version_requirements: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '5.1'
244
+ - - "<"
245
+ - !ruby/object:Gem::Version
246
+ version: '6'
247
+ - !ruby/object:Gem::Dependency
248
+ name: juwelier
249
+ requirement: !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - "~>"
252
+ - !ruby/object:Gem::Version
253
+ version: 2.1.0
254
+ type: :development
255
+ prerelease: false
256
+ version_requirements: !ruby/object:Gem::Requirement
257
+ requirements:
258
+ - - "~>"
259
+ - !ruby/object:Gem::Version
260
+ version: 2.1.0
261
+ - !ruby/object:Gem::Dependency
262
+ name: puma
263
+ requirement: !ruby/object:Gem::Requirement
264
+ requirements:
265
+ - - ">="
266
+ - !ruby/object:Gem::Version
267
+ version: '4.3'
268
+ - - "<"
269
+ - !ruby/object:Gem::Version
270
+ version: '5'
271
+ type: :development
272
+ prerelease: false
273
+ version_requirements: !ruby/object:Gem::Requirement
274
+ requirements:
275
+ - - ">="
276
+ - !ruby/object:Gem::Version
277
+ version: '4.3'
278
+ - - "<"
279
+ - !ruby/object:Gem::Version
280
+ version: '5'
281
+ - !ruby/object:Gem::Dependency
282
+ name: rubocop
283
+ requirement: !ruby/object:Gem::Requirement
284
+ requirements:
285
+ - - ">="
286
+ - !ruby/object:Gem::Version
287
+ version: '0'
288
+ type: :development
289
+ prerelease: false
290
+ version_requirements: !ruby/object:Gem::Requirement
291
+ requirements:
292
+ - - ">="
293
+ - !ruby/object:Gem::Version
294
+ version: '0'
295
+ - !ruby/object:Gem::Dependency
296
+ name: rubocop-rails
297
+ requirement: !ruby/object:Gem::Requirement
298
+ requirements:
299
+ - - ">="
300
+ - !ruby/object:Gem::Version
301
+ version: '0'
302
+ type: :development
303
+ prerelease: false
304
+ version_requirements: !ruby/object:Gem::Requirement
305
+ requirements:
306
+ - - ">="
307
+ - !ruby/object:Gem::Version
308
+ version: '0'
309
+ - !ruby/object:Gem::Dependency
310
+ name: rubocop-rspec
311
+ requirement: !ruby/object:Gem::Requirement
312
+ requirements:
313
+ - - ">="
314
+ - !ruby/object:Gem::Version
315
+ version: '0'
316
+ type: :development
317
+ prerelease: false
318
+ version_requirements: !ruby/object:Gem::Requirement
319
+ requirements:
320
+ - - ">="
321
+ - !ruby/object:Gem::Version
322
+ version: '0'
323
+ description: Cookbook allows you to associate instructions with components in a cross
324
+ referenced way. Good for cooking recipes or an instruction manual for DIY projects.
325
+ email: loren.lundgren@gmail.com
326
+ executables:
327
+ - rails
328
+ extensions: []
329
+ extra_rdoc_files:
330
+ - LICENSE.txt
331
+ - README.md
332
+ files:
333
+ - ".document"
334
+ - ".rspec"
335
+ - ".rubocop.yml"
336
+ - Gemfile
337
+ - Gemfile.lock
338
+ - LICENSE.txt
339
+ - README.md
340
+ - Rakefile
341
+ - VERSION
342
+ - app/assets/stylesheets/cookbook/application.scss
343
+ - app/controllers/concerns/cookbook/params.rb
344
+ - app/helpers/cookbook/application_helper.rb
345
+ - app/models/cookbook/use.rb
346
+ - app/views/cookbook/_fields.html.haml
347
+ - app/views/cookbook/_used_in.html.haml
348
+ - app/views/cookbook/_uses_of.html.haml
349
+ - app/views/cookbook/uses/_fields.html.haml
350
+ - bin/rails
351
+ - config/initializers/simple_form.rb
352
+ - config/locales/simple_form.en.yml
353
+ - cookbook.gemspec
354
+ - db/migrate/20210909141929_create_uses.cookbook.rb
355
+ - lib/cookbook.rb
356
+ - lib/cookbook/configuration.rb
357
+ - lib/cookbook/engine.rb
358
+ - lib/cookbook/extensions/float.rb
359
+ - lib/cookbook/mixins/acts_as_use_of.rb
360
+ - lib/cookbook/mixins/acts_as_used_in.rb
361
+ - lib/cookbook/railtie.rb
362
+ - lib/cookbook/version.rb
363
+ - lib/tasks/cookbook_tasks.rake
364
+ - lib/templates/haml/scaffold/_form.html.haml
365
+ - spec/cookbook_spec.rb
366
+ - spec/dummy/Rakefile
367
+ - spec/dummy/app/assets/config/manifest.js
368
+ - spec/dummy/app/assets/images/.keep
369
+ - spec/dummy/app/assets/stylesheets/application.css
370
+ - spec/dummy/app/assets/stylesheets/scaffolds.scss
371
+ - spec/dummy/app/channels/application_cable/channel.rb
372
+ - spec/dummy/app/channels/application_cable/connection.rb
373
+ - spec/dummy/app/controllers/application_controller.rb
374
+ - spec/dummy/app/controllers/concerns/.keep
375
+ - spec/dummy/app/controllers/how_tos_controller.rb
376
+ - spec/dummy/app/controllers/ingredients_controller.rb
377
+ - spec/dummy/app/controllers/recipes_controller.rb
378
+ - spec/dummy/app/controllers/supplies_controller.rb
379
+ - spec/dummy/app/controllers/tools_controller.rb
380
+ - spec/dummy/app/javascript/packs/application.js
381
+ - spec/dummy/app/jobs/application_job.rb
382
+ - spec/dummy/app/mailers/application_mailer.rb
383
+ - spec/dummy/app/models/ability.rb
384
+ - spec/dummy/app/models/application_record.rb
385
+ - spec/dummy/app/models/concerns/.keep
386
+ - spec/dummy/app/models/how_to.rb
387
+ - spec/dummy/app/models/ingredient.rb
388
+ - spec/dummy/app/models/recipe.rb
389
+ - spec/dummy/app/models/supply.rb
390
+ - spec/dummy/app/models/tool.rb
391
+ - spec/dummy/app/models/user.rb
392
+ - spec/dummy/app/views/how_tos/_form.html.haml
393
+ - spec/dummy/app/views/how_tos/edit.html.haml
394
+ - spec/dummy/app/views/how_tos/index.html.haml
395
+ - spec/dummy/app/views/how_tos/new.html.haml
396
+ - spec/dummy/app/views/how_tos/show.html.haml
397
+ - spec/dummy/app/views/ingredients/_form.html.haml
398
+ - spec/dummy/app/views/ingredients/edit.html.haml
399
+ - spec/dummy/app/views/ingredients/index.html.haml
400
+ - spec/dummy/app/views/ingredients/new.html.haml
401
+ - spec/dummy/app/views/ingredients/show.html.haml
402
+ - spec/dummy/app/views/layouts/application.html.erb
403
+ - spec/dummy/app/views/layouts/mailer.html.erb
404
+ - spec/dummy/app/views/layouts/mailer.text.erb
405
+ - spec/dummy/app/views/recipes/_form.html.haml
406
+ - spec/dummy/app/views/recipes/edit.html.haml
407
+ - spec/dummy/app/views/recipes/index.html.haml
408
+ - spec/dummy/app/views/recipes/new.html.haml
409
+ - spec/dummy/app/views/recipes/show.html.haml
410
+ - spec/dummy/app/views/supplies/_form.html.haml
411
+ - spec/dummy/app/views/supplies/edit.html.haml
412
+ - spec/dummy/app/views/supplies/index.html.haml
413
+ - spec/dummy/app/views/supplies/new.html.haml
414
+ - spec/dummy/app/views/supplies/show.html.haml
415
+ - spec/dummy/app/views/tools/_form.html.haml
416
+ - spec/dummy/app/views/tools/edit.html.haml
417
+ - spec/dummy/app/views/tools/index.html.haml
418
+ - spec/dummy/app/views/tools/new.html.haml
419
+ - spec/dummy/app/views/tools/show.html.haml
420
+ - spec/dummy/bin/rails
421
+ - spec/dummy/bin/rake
422
+ - spec/dummy/bin/setup
423
+ - spec/dummy/config.ru
424
+ - spec/dummy/config/application.rb
425
+ - spec/dummy/config/boot.rb
426
+ - spec/dummy/config/cable.yml
427
+ - spec/dummy/config/database.yml
428
+ - spec/dummy/config/environment.rb
429
+ - spec/dummy/config/environments/development.rb
430
+ - spec/dummy/config/environments/production.rb
431
+ - spec/dummy/config/environments/test.rb
432
+ - spec/dummy/config/initializers/application_controller_renderer.rb
433
+ - spec/dummy/config/initializers/assets.rb
434
+ - spec/dummy/config/initializers/backtrace_silencers.rb
435
+ - spec/dummy/config/initializers/content_security_policy.rb
436
+ - spec/dummy/config/initializers/cookbook.rb
437
+ - spec/dummy/config/initializers/cookies_serializer.rb
438
+ - spec/dummy/config/initializers/devise.rb
439
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
440
+ - spec/dummy/config/initializers/inflections.rb
441
+ - spec/dummy/config/initializers/json.rb
442
+ - spec/dummy/config/initializers/mime_types.rb
443
+ - spec/dummy/config/initializers/permissions_policy.rb
444
+ - spec/dummy/config/initializers/wrap_parameters.rb
445
+ - spec/dummy/config/locales/devise.en.yml
446
+ - spec/dummy/config/locales/en.yml
447
+ - spec/dummy/config/puma.rb
448
+ - spec/dummy/config/routes.rb
449
+ - spec/dummy/config/storage.yml
450
+ - spec/dummy/db/development.sqlite3
451
+ - spec/dummy/db/migrate/20210909175711_create_how_tos.rb
452
+ - spec/dummy/db/migrate/20210909181442_create_ingredients.rb
453
+ - spec/dummy/db/migrate/20210909181455_create_supplies.rb
454
+ - spec/dummy/db/migrate/20210909181516_create_tools.rb
455
+ - spec/dummy/db/migrate/20210909181533_create_recipes.rb
456
+ - spec/dummy/db/migrate/20210909185303_create_uses.cookbook.rb
457
+ - spec/dummy/db/migrate/20210910142322_create_users.rb
458
+ - spec/dummy/db/migrate/20210910142323_add_devise_to_users.rb
459
+ - spec/dummy/db/schema.rb
460
+ - spec/dummy/db/seeds.rb
461
+ - spec/dummy/db/test.sqlite3
462
+ - spec/dummy/lib/assets/.keep
463
+ - spec/dummy/lib/templates/haml/scaffold/_form.html.haml
464
+ - spec/dummy/log/.keep
465
+ - spec/dummy/log/development.log
466
+ - spec/dummy/log/test.log
467
+ - spec/dummy/public/404.html
468
+ - spec/dummy/public/422.html
469
+ - spec/dummy/public/500.html
470
+ - spec/dummy/public/apple-touch-icon-precomposed.png
471
+ - spec/dummy/public/apple-touch-icon.png
472
+ - spec/dummy/public/favicon.ico
473
+ - spec/dummy/storage/.keep
474
+ - spec/factories/how_tos.rb
475
+ - spec/factories/ingredients.rb
476
+ - spec/factories/recipes.rb
477
+ - spec/factories/supplies.rb
478
+ - spec/factories/tools.rb
479
+ - spec/factories/users.rb
480
+ - spec/factories/uses.rb
481
+ - spec/helpers/cookbook/application_helper_spec.rb
482
+ - spec/models/cookbook/use_spec.rb
483
+ - spec/models/how_to_spec.rb
484
+ - spec/models/ingredient_spec.rb
485
+ - spec/models/recipe_spec.rb
486
+ - spec/models/supply_spec.rb
487
+ - spec/models/tool_spec.rb
488
+ - spec/rails_helper.rb
489
+ - spec/requests/how_tos_spec.rb
490
+ - spec/requests/recipes_spec.rb
491
+ - spec/spec_helper.rb
492
+ homepage: https://gemvein.com/museum/cases/cookbook
493
+ licenses:
494
+ - MIT
495
+ metadata:
496
+ source_code_uri: http://github.com/gemvein/cookbook
497
+ post_install_message:
498
+ rdoc_options: []
499
+ require_paths:
500
+ - lib
501
+ required_ruby_version: !ruby/object:Gem::Requirement
502
+ requirements:
503
+ - - ">="
504
+ - !ruby/object:Gem::Version
505
+ version: '0'
506
+ required_rubygems_version: !ruby/object:Gem::Requirement
507
+ requirements:
508
+ - - ">="
509
+ - !ruby/object:Gem::Version
510
+ version: '0'
511
+ requirements: []
512
+ rubygems_version: 3.0.3
513
+ signing_key:
514
+ specification_version: 4
515
+ summary: Mountable Engine to show instructions with components, like a cookbook or
516
+ instruction manual
517
+ test_files: []