diff --git a/.gitignore b/.gitignore index e422e0120..110936ade 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,7 @@ !/log/.keep /tmp .DS_Store + +# SECRETS .env +/test/cassettes/ diff --git a/Gemfile b/Gemfile index 13d617ca2..61460c65e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,10 @@ source 'https://rubygems.org' +# Two gems, to use Foundation: +# Foundation Rails Gem +gem 'foundation-rails' +# Required due to an incompatibility between TurboLinks and Foundation. +gem 'jquery-turbolinks' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.7' @@ -32,10 +37,20 @@ gem 'sdoc', '~> 0.4.0', group: :doc # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +# API GEMS +gem 'httparty' + + + group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' gem 'better_errors' + gem 'dotenv-rails' + + gem 'minitest-vcr' + gem 'webmock' + end group :development do @@ -45,3 +60,7 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end + +group :test do + gem 'minitest-reporters' +end diff --git a/Gemfile.lock b/Gemfile.lock index c1dccfc10..99a0bc6f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,11 +36,22 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + addressable (2.4.0) + ansi (1.5.0) arel (6.0.3) + babel-source (5.8.35) + babel-transpiler (0.7.0) + babel-source (>= 4.0, < 6) + execjs (~> 2.0) + better_errors (2.1.1) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) byebug (9.0.6) + coderay (1.1.1) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) @@ -49,11 +60,24 @@ GEM execjs coffee-script-source (1.10.0) concurrent-ruby (1.0.2) + crack (0.4.3) + safe_yaml (~> 1.0.0) debug_inspector (0.0.2) + dotenv (2.1.1) + dotenv-rails (2.1.1) + dotenv (= 2.1.1) + railties (>= 4.0, < 5.1) erubis (2.7.0) execjs (2.7.0) + foundation-rails (6.2.4.0) + railties (>= 3.1.0) + sass (>= 3.3.0, < 3.5) + sprockets-es6 (>= 0.9.0) globalid (0.3.7) activesupport (>= 4.1.0) + hashdiff (0.3.0) + httparty (0.14.0) + multi_xml (>= 0.5.2) i18n (0.7.0) jbuilder (2.6.0) activesupport (>= 3.0.0, < 5.1) @@ -62,6 +86,9 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + jquery-turbolinks (2.1.0) + railties (>= 3.1.0) + turbolinks json (1.8.3) loofah (2.0.3) nokogiri (>= 1.5.9) @@ -71,8 +98,20 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) + minispec-metadata (2.0.0) + minitest minitest (5.9.1) + minitest-reporters (1.1.12) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + minitest-vcr (1.4.0) + minispec-metadata (~> 2.0) + minitest (>= 4.7.5) + vcr (>= 2.9) multi_json (1.12.1) + multi_xml (0.5.5) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) rack (1.6.4) @@ -105,6 +144,8 @@ GEM rake (11.3.0) rdoc (4.2.2) json (~> 1.4) + ruby-progressbar (1.8.1) + safe_yaml (1.0.4) sass (3.4.22) sass-rails (5.0.6) railties (>= 4.0.0, < 6) @@ -120,6 +161,10 @@ GEM sprockets (3.7.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) + sprockets-es6 (0.9.2) + babel-source (>= 5.8.11) + babel-transpiler + sprockets (>= 3.0.0) sprockets-rails (3.2.0) actionpack (>= 4.0) activesupport (>= 4.0) @@ -135,20 +180,32 @@ GEM thread_safe (~> 0.1) uglifier (3.0.3) execjs (>= 0.3.0, < 3) + vcr (3.0.3) web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) + webmock (2.1.0) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff PLATFORMS ruby DEPENDENCIES + better_errors byebug coffee-rails (~> 4.1.0) + dotenv-rails + foundation-rails + httparty jbuilder (~> 2.0) jquery-rails + jquery-turbolinks + minitest-reporters + minitest-vcr rails (= 4.2.7) sass-rails (~> 5.0) sdoc (~> 0.4.0) @@ -157,6 +214,7 @@ DEPENDENCIES turbolinks uglifier (>= 1.3.0) web-console (~> 2.0) + webmock BUNDLED WITH 1.13.6 diff --git a/README.md b/README.md index 3666ab78e..afd643dd4 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,6 @@ Once you've explored the API docs, this project: - Provide checkboxes or other controls to limit the search to options such as: - Peanut Free - Soy Free - - High Protien + - High Protein - Etc diff --git a/app/assets/images/attibution_edamam.png b/app/assets/images/attibution_edamam.png new file mode 100644 index 000000000..68a62660b Binary files /dev/null and b/app/assets/images/attibution_edamam.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e07c5a830..038d8d7ec 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,5 +12,15 @@ // //= require jquery //= require jquery_ujs +//= require foundation //= require turbolinks //= require_tree . + +$(function(){ $(document).foundation(); }); + +//= require foundation +$(document).foundation(); + +$(document).on('turbolinks:load', function() { + $(function(){ $(document).foundation(); }); +}); diff --git a/app/assets/javascripts/home.coffee b/app/assets/javascripts/home.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/home.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/recipes.coffee b/app/assets/javascripts/recipes.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/recipes.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/_settings.scss b/app/assets/stylesheets/_settings.scss new file mode 100644 index 000000000..703053eb9 --- /dev/null +++ b/app/assets/stylesheets/_settings.scss @@ -0,0 +1,574 @@ +// Foundation for Sites Settings +// ----------------------------- +// +// Table of Contents: +// +// 1. Global +// 2. Breakpoints +// 3. The Grid +// 4. Base Typography +// 5. Typography Helpers +// 6. Abide +// 7. Accordion +// 8. Accordion Menu +// 9. Badge +// 10. Breadcrumbs +// 11. Button +// 12. Button Group +// 13. Callout +// 14. Close Button +// 15. Drilldown +// 16. Dropdown +// 17. Dropdown Menu +// 18. Flex Video +// 19. Forms +// 20. Label +// 21. Media Object +// 22. Menu +// 23. Meter +// 24. Off-canvas +// 25. Orbit +// 26. Pagination +// 27. Progress Bar +// 28. Reveal +// 29. Slider +// 30. Switch +// 31. Table +// 32. Tabs +// 33. Thumbnail +// 34. Title Bar +// 35. Tooltip +// 36. Top Bar + +@import 'util/util'; + +// 1. Global +// --------- + +$global-font-size: 100%; +$global-width: rem-calc(1200); +$global-lineheight: 1.5; +$foundation-palette: ( + primary: #2199e8, + secondary: #777, + success: #3adb76, + warning: #ffae00, + alert: #ec5840, +); +$light-gray: #e6e6e6; +$medium-gray: #cacaca; +$dark-gray: #8a8a8a; +$black: #0a0a0a; +$white: #fefefe; +$body-background: $white; +$body-font-color: $black; +$body-font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; +$body-antialiased: true; +$global-margin: 1rem; +$global-padding: 1rem; +$global-weight-normal: normal; +$global-weight-bold: bold; +$global-radius: 0; +$global-text-direction: ltr; +$global-flexbox: false; +$print-transparent-backgrounds: true; + +@include add-foundation-colors; + +// 2. Breakpoints +// -------------- + +$breakpoints: ( + small: 0, + medium: 640px, + large: 1024px, + xlarge: 1200px, + xxlarge: 1440px, +); +$breakpoint-classes: (small medium large); + +// 3. The Grid +// ----------- + +$grid-row-width: $global-width; +$grid-column-count: 12; +$grid-column-gutter: ( + small: 20px, + medium: 30px, +); +$grid-column-align-edge: true; +$block-grid-max: 8; + +// 4. Base Typography +// ------------------ + +$header-font-family: $body-font-family; +$header-font-weight: $global-weight-normal; +$header-font-style: normal; +$font-family-monospace: Consolas, 'Liberation Mono', Courier, monospace; +$header-sizes: ( + small: ( + 'h1': 24, + 'h2': 20, + 'h3': 19, + 'h4': 18, + 'h5': 17, + 'h6': 16, + ), + medium: ( + 'h1': 48, + 'h2': 40, + 'h3': 31, + 'h4': 25, + 'h5': 20, + 'h6': 16, + ), +); +$header-color: inherit; +$header-lineheight: 1.4; +$header-margin-bottom: 0.5rem; +$header-text-rendering: optimizeLegibility; +$small-font-size: 80%; +$header-small-font-color: $medium-gray; +$paragraph-lineheight: 1.6; +$paragraph-margin-bottom: 1rem; +$paragraph-text-rendering: optimizeLegibility; +$code-color: $black; +$code-font-family: $font-family-monospace; +$code-font-weight: $global-weight-normal; +$code-background: $light-gray; +$code-border: 1px solid $medium-gray; +$code-padding: rem-calc(2 5 1); +$anchor-color: $primary-color; +$anchor-color-hover: scale-color($anchor-color, $lightness: -14%); +$anchor-text-decoration: none; +$anchor-text-decoration-hover: none; +$hr-width: $global-width; +$hr-border: 1px solid $medium-gray; +$hr-margin: rem-calc(20) auto; +$list-lineheight: $paragraph-lineheight; +$list-margin-bottom: $paragraph-margin-bottom; +$list-style-type: disc; +$list-style-position: outside; +$list-side-margin: 1.25rem; +$list-nested-side-margin: 1.25rem; +$defnlist-margin-bottom: 1rem; +$defnlist-term-weight: $global-weight-bold; +$defnlist-term-margin-bottom: 0.3rem; +$blockquote-color: $dark-gray; +$blockquote-padding: rem-calc(9 20 0 19); +$blockquote-border: 1px solid $medium-gray; +$cite-font-size: rem-calc(13); +$cite-color: $dark-gray; +$keystroke-font: $font-family-monospace; +$keystroke-color: $black; +$keystroke-background: $light-gray; +$keystroke-padding: rem-calc(2 4 0); +$keystroke-radius: $global-radius; +$abbr-underline: 1px dotted $black; + +// 5. Typography Helpers +// --------------------- + +$lead-font-size: $global-font-size * 1.25; +$lead-lineheight: 1.6; +$subheader-lineheight: 1.4; +$subheader-color: $dark-gray; +$subheader-font-weight: $global-weight-normal; +$subheader-margin-top: 0.2rem; +$subheader-margin-bottom: 0.5rem; +$stat-font-size: 2.5rem; + +// 6. Abide +// -------- + +$abide-inputs: true; +$abide-labels: true; +$input-background-invalid: map-get($foundation-palette, alert); +$form-label-color-invalid: map-get($foundation-palette, alert); +$input-error-color: map-get($foundation-palette, alert); +$input-error-font-size: rem-calc(12); +$input-error-font-weight: $global-weight-bold; + +// 7. Accordion +// ------------ + +$accordion-background: $white; +$accordion-plusminus: true; +$accordion-item-color: foreground($accordion-background, $primary-color); +$accordion-item-background-hover: $light-gray; +$accordion-item-padding: 1.25rem 1rem; +$accordion-content-background: $white; +$accordion-content-border: 1px solid $light-gray; +$accordion-content-color: foreground($accordion-content-background, $body-font-color); +$accordion-content-padding: 1rem; + +// 8. Accordion Menu +// ----------------- + +$accordionmenu-arrows: true; +$accordionmenu-arrow-color: $primary-color; + +// 9. Badge +// -------- + +$badge-background: $primary-color; +$badge-color: foreground($badge-background); +$badge-padding: 0.3em; +$badge-minwidth: 2.1em; +$badge-font-size: 0.6rem; + +// 10. Breadcrumbs +// --------------- + +$breadcrumbs-margin: 0 0 $global-margin 0; +$breadcrumbs-item-font-size: rem-calc(11); +$breadcrumbs-item-color: $primary-color; +$breadcrumbs-item-color-current: $black; +$breadcrumbs-item-color-disabled: $medium-gray; +$breadcrumbs-item-margin: 0.75rem; +$breadcrumbs-item-uppercase: true; +$breadcrumbs-item-slash: true; + +// 11. Button +// ---------- + +$button-padding: 0.85em 1em; +$button-margin: 0 0 $global-margin 0; +$button-fill: solid; +$button-background: $primary-color; +$button-background-hover: scale-color($button-background, $lightness: -15%); +$button-color: $white; +$button-color-alt: $black; +$button-radius: $global-radius; +$button-sizes: ( + tiny: 0.6rem, + small: 0.75rem, + default: 0.9rem, + large: 1.25rem, +); +$button-opacity-disabled: 0.25; +$button-background-hover-lightness: -20%; +$button-hollow-hover-lightness: -50%; + +// 12. Button Group +// ---------------- + +$buttongroup-margin: 1rem; +$buttongroup-spacing: 1px; +$buttongroup-child-selector: '.button'; +$buttongroup-expand-max: 6; + +// 13. Callout +// ----------- + +$callout-background: $white; +$callout-background-fade: 85%; +$callout-border: 1px solid rgba($black, 0.25); +$callout-margin: 0 0 1rem 0; +$callout-padding: 1rem; +$callout-font-color: $body-font-color; +$callout-font-color-alt: $body-background; +$callout-radius: $global-radius; +$callout-link-tint: 30%; + +// 14. Close Button +// ---------------- + +$closebutton-position: right top; +$closebutton-offset-horizontal: 1rem; +$closebutton-offset-vertical: 0.5rem; +$closebutton-size: 2em; +$closebutton-lineheight: 1; +$closebutton-color: $dark-gray; +$closebutton-color-hover: $black; + +// 15. Drilldown +// ------------- + +$drilldown-transition: transform 0.15s linear; +$drilldown-arrows: true; +$drilldown-arrow-color: $primary-color; +$drilldown-background: $white; + +// 16. Dropdown +// ------------ + +$dropdown-padding: 1rem; +$dropdown-border: 1px solid $medium-gray; +$dropdown-font-size: 1rem; +$dropdown-width: 300px; +$dropdown-radius: $global-radius; +$dropdown-sizes: ( + tiny: 100px, + small: 200px, + large: 400px, +); + +// 17. Dropdown Menu +// ----------------- + +$dropdownmenu-arrows: true; +$dropdownmenu-arrow-color: $anchor-color; +$dropdownmenu-min-width: 200px; +$dropdownmenu-background: $white; +$dropdownmenu-border: 1px solid $medium-gray; + +// 18. Flex Video +// -------------- + +$flexvideo-margin-bottom: rem-calc(16); +$flexvideo-ratio: 4 by 3; +$flexvideo-ratio-widescreen: 16 by 9; + +// 19. Forms +// --------- + +$fieldset-border: 1px solid $medium-gray; +$fieldset-padding: rem-calc(20); +$fieldset-margin: rem-calc(18 0); +$legend-padding: rem-calc(0 3); +$form-spacing: rem-calc(16); +$helptext-color: $black; +$helptext-font-size: rem-calc(13); +$helptext-font-style: italic; +$input-prefix-color: $black; +$input-prefix-background: $light-gray; +$input-prefix-border: 1px solid $medium-gray; +$input-prefix-padding: 1rem; +$form-label-color: $black; +$form-label-font-size: rem-calc(14); +$form-label-font-weight: $global-weight-normal; +$form-label-line-height: 1.8; +$select-background: $white; +$select-triangle-color: $dark-gray; +$select-radius: $global-radius; +$input-color: $black; +$input-placeholder-color: $medium-gray; +$input-font-family: inherit; +$input-font-size: rem-calc(16); +$input-background: $white; +$input-background-focus: $white; +$input-background-disabled: $light-gray; +$input-border: 1px solid $medium-gray; +$input-border-focus: 1px solid $dark-gray; +$input-shadow: inset 0 1px 2px rgba($black, 0.1); +$input-shadow-focus: 0 0 5px $medium-gray; +$input-cursor-disabled: not-allowed; +$input-transition: box-shadow 0.5s, border-color 0.25s ease-in-out; +$input-number-spinners: true; +$input-radius: $global-radius; +$button-radius: $global-radius; + +// 20. Label +// --------- + +$label-background: $primary-color; +$label-color: foreground($label-background); +$label-font-size: 0.8rem; +$label-padding: 0.33333rem 0.5rem; +$label-radius: $global-radius; + +// 21. Media Object +// ---------------- + +$mediaobject-margin-bottom: $global-margin; +$mediaobject-section-padding: $global-padding; +$mediaobject-image-width-stacked: 100%; + +// 22. Menu +// -------- + +$menu-margin: 0; +$menu-margin-nested: 1rem; +$menu-item-padding: 0.7rem 1rem; +$menu-item-color-active: $white; +$menu-item-background-active: map-get($foundation-palette, primary); +$menu-icon-spacing: 0.25rem; + +// 23. Meter +// --------- + +$meter-height: 1rem; +$meter-radius: $global-radius; +$meter-background: $medium-gray; +$meter-fill-good: $success-color; +$meter-fill-medium: $warning-color; +$meter-fill-bad: $alert-color; + +// 24. Off-canvas +// -------------- + +$offcanvas-size: 250px; +$offcanvas-background: $light-gray; +$offcanvas-zindex: -1; +$offcanvas-transition-length: 0.5s; +$offcanvas-transition-timing: ease; +$offcanvas-fixed-reveal: true; +$offcanvas-exit-background: rgba($white, 0.25); +$maincontent-class: 'off-canvas-content'; +$maincontent-shadow: 0 0 10px rgba($black, 0.5); + +// 25. Orbit +// --------- + +$orbit-bullet-background: $medium-gray; +$orbit-bullet-background-active: $dark-gray; +$orbit-bullet-diameter: 1.2rem; +$orbit-bullet-margin: 0.1rem; +$orbit-bullet-margin-top: 0.8rem; +$orbit-bullet-margin-bottom: 0.8rem; +$orbit-caption-background: rgba($black, 0.5); +$orbit-caption-padding: 1rem; +$orbit-control-background-hover: rgba($black, 0.5); +$orbit-control-padding: 1rem; +$orbit-control-zindex: 10; + +// 26. Pagination +// -------------- + +$pagination-font-size: rem-calc(14); +$pagination-margin-bottom: $global-margin; +$pagination-item-color: $black; +$pagination-item-padding: rem-calc(3 10); +$pagination-item-spacing: rem-calc(1); +$pagination-radius: $global-radius; +$pagination-item-background-hover: $light-gray; +$pagination-item-background-current: $primary-color; +$pagination-item-color-current: foreground($pagination-item-background-current); +$pagination-item-color-disabled: $medium-gray; +$pagination-ellipsis-color: $black; +$pagination-mobile-items: false; +$pagination-mobile-current-item: false; +$pagination-arrows: true; + +// 27. Progress Bar +// ---------------- + +$progress-height: 1rem; +$progress-background: $medium-gray; +$progress-margin-bottom: $global-margin; +$progress-meter-background: $primary-color; +$progress-radius: $global-radius; + +// 28. Reveal +// ---------- + +$reveal-background: $white; +$reveal-width: 600px; +$reveal-max-width: $global-width; +$reveal-padding: $global-padding; +$reveal-border: 1px solid $medium-gray; +$reveal-radius: $global-radius; +$reveal-zindex: 1005; +$reveal-overlay-background: rgba($black, 0.45); + +// 29. Slider +// ---------- + +$slider-width-vertical: 0.5rem; +$slider-transition: all 0.2s ease-in-out; +$slider-height: 0.5rem; +$slider-background: $light-gray; +$slider-fill-background: $medium-gray; +$slider-handle-height: 1.4rem; +$slider-handle-width: 1.4rem; +$slider-handle-background: $primary-color; +$slider-opacity-disabled: 0.25; +$slider-radius: $global-radius; + +// 30. Switch +// ---------- + +$switch-background: $medium-gray; +$switch-background-active: $primary-color; +$switch-height: 2rem; +$switch-height-tiny: 1.5rem; +$switch-height-small: 1.75rem; +$switch-height-large: 2.5rem; +$switch-radius: $global-radius; +$switch-margin: $global-margin; +$switch-paddle-background: $white; +$switch-paddle-offset: 0.25rem; +$switch-paddle-radius: $global-radius; +$switch-paddle-transition: all 0.25s ease-out; + +// 31. Table +// --------- + +$table-background: $white; +$table-color-scale: 5%; +$table-border: 1px solid smart-scale($table-background, $table-color-scale); +$table-padding: rem-calc(8 10 10); +$table-hover-scale: 2%; +$table-row-hover: darken($table-background, $table-hover-scale); +$table-row-stripe-hover: darken($table-background, $table-color-scale + $table-hover-scale); +$table-striped-background: smart-scale($table-background, $table-color-scale); +$table-stripe: even; +$table-head-background: smart-scale($table-background, $table-color-scale / 2); +$table-head-row-hover: darken($table-head-background, $table-hover-scale); +$table-foot-background: smart-scale($table-background, $table-color-scale); +$table-foot-row-hover: darken($table-foot-background, $table-hover-scale); +$table-head-font-color: $body-font-color; +$table-foot-font-color: $body-font-color; +$show-header-for-stacked: false; + +// 32. Tabs +// -------- + +$tab-margin: 0; +$tab-background: $white; +$tab-background-active: $light-gray; +$tab-item-font-size: rem-calc(12); +$tab-item-background-hover: $white; +$tab-item-padding: 1.25rem 1.5rem; +$tab-expand-max: 6; +$tab-content-background: $white; +$tab-content-border: $light-gray; +$tab-content-color: foreground($tab-background, $primary-color); +$tab-content-padding: 1rem; + +// 33. Thumbnail +// ------------- + +$thumbnail-border: solid 4px $white; +$thumbnail-margin-bottom: $global-margin; +$thumbnail-shadow: 0 0 0 1px rgba($black, 0.2); +$thumbnail-shadow-hover: 0 0 6px 1px rgba($primary-color, 0.5); +$thumbnail-transition: box-shadow 200ms ease-out; +$thumbnail-radius: $global-radius; + +// 34. Title Bar +// ------------- + +$titlebar-background: $black; +$titlebar-color: $white; +$titlebar-padding: 0.5rem; +$titlebar-text-font-weight: bold; +$titlebar-icon-color: $white; +$titlebar-icon-color-hover: $medium-gray; +$titlebar-icon-spacing: 0.25rem; + +// 35. Tooltip +// ----------- + +$has-tip-font-weight: $global-weight-bold; +$has-tip-border-bottom: dotted 1px $dark-gray; +$tooltip-background-color: $black; +$tooltip-color: $white; +$tooltip-padding: 0.75rem; +$tooltip-font-size: $small-font-size; +$tooltip-pip-width: 0.75rem; +$tooltip-pip-height: $tooltip-pip-width * 0.866; +$tooltip-radius: $global-radius; + +// 36. Top Bar +// ----------- + +$topbar-padding: 0.5rem; +$topbar-background: $light-gray; +$topbar-submenu-background: $topbar-background; +$topbar-title-spacing: 1rem; +$topbar-input-width: 200px; +$topbar-unstack-breakpoint: medium; + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.scss similarity index 94% rename from app/assets/stylesheets/application.css rename to app/assets/stylesheets/application.scss index f9cd5b348..c8b8e576f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.scss @@ -12,4 +12,6 @@ * *= require_tree . *= require_self + *= require foundation_and_overrides + */ diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss new file mode 100644 index 000000000..458eb4faf --- /dev/null +++ b/app/assets/stylesheets/foundation_and_overrides.scss @@ -0,0 +1,52 @@ +@charset 'utf-8'; + +@import 'settings'; +@import 'foundation'; + +// If you'd like to include motion-ui the foundation-rails gem comes prepackaged with it, uncomment the 3 @imports, if you are not using the gem you need to install the motion-ui sass package. +// +@import 'motion-ui/motion-ui'; + +// We include everything by default. To slim your CSS, remove components you don't use. + +@include foundation-global-styles; +@include foundation-grid; +@include foundation-typography; +@include foundation-button; +@include foundation-forms; +@include foundation-visibility-classes; +@include foundation-float-classes; +@include foundation-accordion; +@include foundation-accordion-menu; +@include foundation-badge; +@include foundation-breadcrumbs; +@include foundation-button-group; +@include foundation-callout; +@include foundation-close-button; +@include foundation-drilldown-menu; +@include foundation-dropdown; +@include foundation-dropdown-menu; +@include foundation-flex-video; +@include foundation-label; +@include foundation-media-object; +@include foundation-menu; +@include foundation-menu-icon; +@include foundation-off-canvas; +@include foundation-orbit; +@include foundation-pagination; +@include foundation-progress-bar; +@include foundation-slider; +@include foundation-sticky; +@include foundation-reveal; +@include foundation-switch; +@include foundation-table; +@include foundation-tabs; +@include foundation-thumbnail; +@include foundation-title-bar; +@include foundation-tooltip; +@include foundation-top-bar; + +// If you'd like to include motion-ui the foundation-rails gem comes prepackaged with it, uncomment the 3 @imports, if you are not using the gem you need to install the motion-ui sass package. +// +@include motion-ui-transitions; +@include motion-ui-animations; diff --git a/app/assets/stylesheets/home.scss b/app/assets/stylesheets/home.scss new file mode 100644 index 000000000..8f3b702f4 --- /dev/null +++ b/app/assets/stylesheets/home.scss @@ -0,0 +1,6 @@ +// Place all the styles related to the home controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +div.results { + height: 22em; +} diff --git a/app/assets/stylesheets/recipes.scss b/app/assets/stylesheets/recipes.scss new file mode 100644 index 000000000..1e10ffa50 --- /dev/null +++ b/app/assets/stylesheets/recipes.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the recipes controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 000000000..6e81b3963 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,5 @@ +class HomeController < ApplicationController + + def index; end + +end diff --git a/app/controllers/recipes_controller.rb b/app/controllers/recipes_controller.rb new file mode 100644 index 000000000..b18983d1c --- /dev/null +++ b/app/controllers/recipes_controller.rb @@ -0,0 +1,52 @@ +# require 'EdamamApiWrapper' +# require 'recipe' + +class RecipesController < ApplicationController + + def search + if params["q"] != "" + # SUCCESS + search_string = recipe_params[:q] + @page = (recipe_params[:page] || 1).to_i + @recipes = Recipe.search_results(search_string, @page) + # We have control over Recipe search results (in /lib) + + # raise + # This will return an empty list if there are no search results from the API methods. + # @todo Implement redirect to root for [] + render :index + return + + # else + end + flash[:notice] = "Please enter a valid search term" + redirect_to root_path + end + + def show + show_params = recipe_params[:uri] + # Will stop some invalid recipes rather than showing an empty list + @recipe = EdamamApiWrapper.get_recipe(show_params) + end + + def more + @page = (recipe_params[:page] || 1).to_i + more_direction = recipe_params[:page_direction].to_i + # the Recipe class stops invalid page changes + @recipes = Recipe.change_page(more_direction) + if (@page + more_direction)>1 + @page += more_direction + params[:page] = @page + end + + render :index + end + +private + +def recipe_params + params.permit(:q, :page, :uri, :page_direction) +end + + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945..a2f487023 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,3 @@ module ApplicationHelper + end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 000000000..23de56ac6 --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,2 @@ +module HomeHelper +end diff --git a/app/helpers/recipes_helper.rb b/app/helpers/recipes_helper.rb new file mode 100644 index 000000000..f32adbb37 --- /dev/null +++ b/app/helpers/recipes_helper.rb @@ -0,0 +1,11 @@ +module RecipesHelper + def link_selector(recipe) + if recipe.url + return recipe.url + elsif recipe.uri + return recipe.uri + else + return recipes_path + end + end +end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 000000000..0092c411c --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,21 @@ + <% if flash[:notice] %> +
+ <%= flash[:notice] %> + <% flash[:notice] = nil %> +
+ <% else %> +

Welcome to the Muncher!

+ <% end %> +
+
+ <%= form_tag(search_path, method: "get") do %> + <%= label_tag(:q, "Search for:") %> + <%= text_field_tag(:q) %> + <%= submit_tag("Go!") %> + <% end %> +
+
+ +

+ This is the home#index page +

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 237dbba45..45ae08f74 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,14 +1,24 @@ - - - ApiMuncher - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> - <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> - <%= csrf_meta_tags %> - - - -<%= yield %> - - + + + + + + <%= content_for?(:title) ? yield(:title) : "Untitled" %> + + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application", 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + + + <%= yield %> + + diff --git a/app/views/recipes/index.html.erb b/app/views/recipes/index.html.erb new file mode 100644 index 000000000..6599f89cf --- /dev/null +++ b/app/views/recipes/index.html.erb @@ -0,0 +1,32 @@ + +
+ <% if @recipes != nil %> +
+
+
+ <% @recipes.each do |recipe| %> +
+

<%= link_to(image_tag(recipe.image), image_path(recipe_path(recipe.uri)) ) %>

+

<%= link_to "#{recipe.title}", recipe_path(recipe.uri) %>

+
+ <% end %> +
+ <% end %> +
+
+

+ <% page_number = params[:page].to_i %> + <% if page_number > 1 %> + <%= link_to "First Page", search_path(q: "cilantro") %> + <% if page_number > 2 %> + <%= link_to "<<", recipes_more_path({page_direction: "-2"}) %> + <% end %> + <%= link_to "<", recipes_more_path({page_direction: "-1"}) %> + <% end %> + <%= link_to ">", recipes_more_path({page_direction: "1"}) %> + <%= link_to ">>", recipes_more_path({page_direction: "2"}) %> +

+
+ diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb new file mode 100644 index 000000000..97d004c5c --- /dev/null +++ b/app/views/recipes/show.html.erb @@ -0,0 +1,26 @@ +
+
+

<%= link_to "#{@recipe.title}", @recipe.url %>

+
+
+

<%= link_to(image_tag(@recipe.image), image_path(recipe_path(@recipe.uri)) ) %>

+
+

Ingredients Needed:

+ <% @recipe.ingredients.each do |ingred| %> +

<%= ingred %>

+ <% end %> +
+
+
+

Dietary Information:

+

+ <% @recipe.diet_info.each do |info| %> + <%= info %> + <% end %> +

+
+
+ +

+ This is the recipe#show page +

diff --git a/config/application.rb b/config/application.rb index 20568697a..37e26bf37 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,5 +22,10 @@ class Application < Rails::Application # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true + +# DONT FORGET to add the lib + # Automatically load all code from /lib + config.autoload_paths << Rails.root.join('lib') + end end diff --git a/config/routes.rb b/config/routes.rb index 3f66539d5..12f74ae39 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,16 @@ Rails.application.routes.draw do + + root 'home#index' + + get '/recipes/more' => 'recipes#more' + +# Make note that all new /recipes/something routes must go above + get '/recipes/*uri' => 'recipes#show', as: 'recipe', constraints: {uri: /.+/} + + get '/recipes' => 'recipes#search', as: 'search' + + # get '/:id' => 'recipes#show' + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/config/secrets.yml b/config/secrets.yml index 0568244a4..4518a4614 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -11,6 +11,7 @@ # if you're sharing your code publicly. development: + secret_key_base: 99a98298ee291a57ba658df7ba646710149956d7dd820679c01c388bc89c959a5d6e4b5300197595e453f0c2884cb6deb2db8b92c5253fb814d04f6a08c55b49 test: diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 000000000..4dfbb1680 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,16 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 0) do + +end diff --git a/lib/edamam_api_wrapper.rb b/lib/edamam_api_wrapper.rb new file mode 100644 index 000000000..8d34b0d24 --- /dev/null +++ b/lib/edamam_api_wrapper.rb @@ -0,0 +1,64 @@ +require 'httparty' + +class EdamamApiWrapper + BASE_URL = "https://api.edamam.com/search" + THE_KEY = ENV["EDAMAM_KEY"] + THE_ID = ENV["EDAMAM_ID"] + + attr_reader :data + + def self.list_recipes(search_string, page=1) + # clean up string + clean_string = query_sanitation(search_string) + if clean_string.empty? + return [] + end + #gives us the first ten + + listing = (page*10) - 10 + + page_string = "&from=#{listing}" + url = BASE_URL + "?q=#{clean_string}" + page_string + "&app_id=#{THE_ID}&app_key=#{THE_KEY}" + # url = BASE_URL + "?q=chicken" + "&app_id=#{THE_ID}&app_key=#{THE_KEY}" + # puts "list_recipes URL: #{url}" + @data = HTTParty.get(url) #.parsed_response + search_results = [] + if @data["hits"] + @data["hits"].each do |hit| + wrapper = Recipe.new(listing, hit["recipe"]["label"], hit["recipe"]["image"], hit["recipe"]["uri"], hit["recipe"]["url"], hit["recipe"]["ingredientLines"], hit["recipe"]["dietLabels"]) + # label is recipe title + # image is image of recipe item + # uri is uri for recipe on edamam + # url is url for original recipe + # "ingredientLines" is the array of ingredients + # "dietLabels" is the array of dietary information + search_results << wrapper + end + end + return search_results + end + +# not implemented +# restrictions on search queries imposed by Edamam @todo + def self.query_sanitation(search_string) + # puts "Requesting #{search_string} from Edamam database" + # Need to clean the string up + if search_string.nil? + return '' + end + clean_string = search_string.gsub(/[^a-zA-Z ]/, '') + # Used by the recipe controller action + return clean_string + end + + def self.get_recipe(recipe_uri) + url = BASE_URL + "?r=#{URI.encode(recipe_uri)}" + "&app_id=#{THE_ID}&app_key=#{THE_KEY}" + @data = HTTParty.get(url).parsed_response + if @data.empty? + return nil + else + return Recipe.new(0, @data[0]['label'], @data[0]['image'], @data[0]['uri'], @data[0]['url'], @data[0]['ingredientLines'], @data[0]['dietLabels'] ) + end + end + +end diff --git a/lib/recipe.rb b/lib/recipe.rb new file mode 100644 index 000000000..d3825af03 --- /dev/null +++ b/lib/recipe.rb @@ -0,0 +1,37 @@ +# tests first +class Recipe + attr_reader :title, :image, :uri, :url, :ingredients, :diet_info, :listing_set + + def initialize(listing, title, image, uri, url, ingredients, dietary_info) + @listing_set = listing + @title = title + @image = image + @uri = uri + @url = url + @ingredients = ingredients + @diet_info = dietary_info + end + + def self.search_results(search_query, page=1) + # cleaned up in wrapper + @search_query = search_query + @page = page + return @recipes = EdamamApiWrapper.list_recipes(search_query, page) + end + + def self.change_page(page_direction) + if ((@page + page_direction) < 1) + return @recipes + else + @page += page_direction + return @recipes = EdamamApiWrapper.list_recipes(@search_query, @page) + end + end + + +# Method makes sure two recipe objects with the same content are the same + def ==(another_recipe) + return self.title == another_recipe.title && self.image == another_recipe.image && self.uri == another_recipe.uri && self.url == another_recipe.url && self.ingredients == another_recipe.ingredients && self.diet_info == another_recipe.diet_info + end + +end diff --git a/test/controllers/home_controller_test.rb b/test/controllers/home_controller_test.rb new file mode 100644 index 000000000..873c71e99 --- /dev/null +++ b/test/controllers/home_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class HomeControllerTest < ActionController::TestCase + test "should get the index" do + get :index + assert_response :success + end +end diff --git a/test/controllers/recipes_controller_test.rb b/test/controllers/recipes_controller_test.rb new file mode 100644 index 000000000..a924d6125 --- /dev/null +++ b/test/controllers/recipes_controller_test.rb @@ -0,0 +1,91 @@ +require 'test_helper' + +class RecipesControllerTest < ActionController::TestCase + + test "search form should have a successful search if search_query is valid" do + VCR.use_cassette("recipes") do + params = {"q" => "cilantro"} + get :search, params + assert_response 200 + assert :index + end + end + + test "search form should render root if empty" do + VCR.use_cassette("recipes") do + params = {"q" => ""} + get :search, params + assert_redirected_to root_path + end + end + + test "search should render the correct page" do + VCR.use_cassette("recipes") do + params = {"q" => "tilapia", "page" => 2} + get :search, params + assert_response 200 + assert :index + end + end + + test "should get show" do + VCR.use_cassette("recipes") do + params = {"uri" => "http://www.edamam.com/ontologies/edamam.owl#recipe_55a8fd184bca071fefbbdc01325f88ef"} + get :show, params + assert_response :success + assert_response 200 # also works + assert :show + end + end + + test "more should render index with a new page number" do + VCR.use_cassette("recipes") do + params = {"q" => "cilantro"} + get :search, params + + #more (one page forward) + params["page_direction"] = "1" + get :more, params + + assert_equal("2", params[:page]) + + #more (one more page forward) + params["page_direction"] = "1" + get :more, params + + assert_equal("3", params[:page]) + + assert_response 200 + assert :index + end + end + + test "more should not change @page to less than one" do + VCR.use_cassette("recipes") do + # this is page one by default + params = {"q" => "cilantro"} + get :search, params + + #more attempt backwards to zero + params["page_direction"] = "-1" + get :more, params + + assert("1", params[:page]) + + params["page_direction"] = "-100" + get :more, params + + assert("1", params[:page]) + end + end + +# # parsing error in get_recipe that I dont know how to solve +# test "should not get show for invalid uri params" do +# VCR.use_cassette("recipe") do +# params = {"uri" => 'myrecipes.com'} +# get :show, params +# assert :show +# end +# end + +end diff --git a/test/helpers/recipes_helper_test.rb b/test/helpers/recipes_helper_test.rb new file mode 100644 index 000000000..294d2d0a5 --- /dev/null +++ b/test/helpers/recipes_helper_test.rb @@ -0,0 +1,11 @@ +require 'test_helper' + +# Not sure this is included in rake, it gives lots of errors + + # test "link_selector view helper method should not be nil" do + # VCR.use_cassette("recipes") do + # recipe = recipes.first + # recipe.url = nil + # assert_not_nil link_selector(recipe) + # end + # end diff --git a/test/lib/edamam_api_wrapper_test.rb b/test/lib/edamam_api_wrapper_test.rb new file mode 100644 index 000000000..2e18cd301 --- /dev/null +++ b/test/lib/edamam_api_wrapper_test.rb @@ -0,0 +1,84 @@ +class EdamamApiWrapperTest < ActiveSupport::TestCase + +#slack equivalent listchannels +# this is for the greyed out version of list_recipes +# this test passes when search_query is inserted into list_recipes + test "list_recipes returns array of recipes when it has a search string" do + VCR.use_cassette("recipes") do + clean_string = "cilantro" + recipes = EdamamApiWrapper.list_recipes(clean_string) + assert_kind_of Array, recipes + recipes.each do |recipe| + assert_kind_of Recipe, recipe + end + end + end + + test "list_recipes returns an empty array if the query has no results back from the API" do + VCR.use_cassette("recipes") do + query = "automobile" + recipes = EdamamApiWrapper.list_recipes(query) + assert_equal([], recipes) + end + end + + test "get_recipe should successfully return correct recipe" do + VCR.use_cassette("recipes") do + uri = 'http://www.edamam.com/ontologies/edamam.owl#recipe_c468dc28f8b64bb711125cc150b15c25' + actual_recipe = EdamamApiWrapper.get_recipe(uri) + + expected_recipe = Recipe.new(0, 'Grilled Deviled Chickens Under a Brick', 'https://www.edamam.com/web-img/5f5/5f51c89f832d50da84e3c05bef3f66f9.jpg', uri, 'http://www.marthastewart.com/recipe/grilled-deviled-chickens-under-a-brick', ['4 baby chickens (poussins) or cornish hens (about 1 1/4 pounds each), or 4 chicken breast halves', '3 lemons, plus wedges for garnish', '4 cloves garlic, peeled and smashed', '1 tablespoon crushed red-pepper flakes, or to taste', '1 tablespoon finely chopped fresh thyme', '1 tablespoon finely chopped fresh rosemary', '1/2 cup olive oil', 'Salt, to taste'], ['Low-Carb']) + + assert_equal(actual_recipe, expected_recipe) + + end + end + + test "list_recipes page should return the listings from that page" do + VCR.use_cassette("recipes") do + search_string = "tilapia" + page = 2 + recipes = EdamamApiWrapper.list_recipes(search_string, page) + assert_equal('http://www.edamam.com/ontologies/edamam.owl#recipe_55a8fd184bca071fefbbdc01325f88ef', recipes.first.uri) + end + end + + test "get_recipe should return nil for unexpected uri requests" do + VCR.use_cassette("recipes") do + uri = 'http://www.edamam.com/ontologies/edamam.owl#recipe_myownuri' + unexpected_uri_response = EdamamApiWrapper.get_recipe(uri) + + assert_nil unexpected_uri_response + + end + end + + # test "get_recipe should return nil if the request to the API was unsuccessful" do + # VCR.use_cassette("recipes") do + # assert false + # end + # end + + + # # not implemented + # # query_sanitation should return the recipes matching the first word in the string typed in + # test "Can send a search query and get a valid response" do + # VCR.use_cassette("hits") do + # search_string = "cilantro" + # response = EdamamApiWrapper.query_sanitation(search_string) + # assert_equal(response, "cilantro") # because cilantro is the sanitized version of itself + # end + # end + +# dont know what to assert here to ensure it works + # test "an argument value for listing will return a successful API request" do + # VCR.use_cassette("hits") do + # clean_string = "cilantro" + # listing = 30 + # response = EdamamApiWrapper.list_recipes(clean_string, listing) + # puts "#{response}" + # assert response[200] + # end + # end + +end diff --git a/test/lib/recipe_test.rb b/test/lib/recipe_test.rb new file mode 100644 index 000000000..b66d8f353 --- /dev/null +++ b/test/lib/recipe_test.rb @@ -0,0 +1,78 @@ +require 'test_helper' + +class RecipeTest < ActiveSupport::TestCase + + test "Recipe.search_results should return an array of recipes" do + VCR.use_cassette("hits") do + clean_string = "cilantro" + recipes = Recipe.search_results(clean_string) + assert_kind_of Array, recipes + assert_not recipes.empty? + recipes.each do |recipe| + assert_kind_of Recipe, recipe + end + end + end + + test "search_results should return an empty array if the search_query is not valid" do + numbers_string = "1234" + empty_string = "" + nil_that_should_be_a_string = nil + + assert_equal([], Recipe.search_results(numbers_string)) + assert_equal([], Recipe.search_results(empty_string)) + assert_equal([], Recipe.search_results(nil_that_should_be_a_string)) + end + + test "change_page can be called after self.search_results and should return an array of recipes" do + VCR.use_cassette("hits") do + # we already asserted this works + clean_string = "cilantro" + recipes = Recipe.search_results(clean_string) + + # test that this works to request the next set of recipes + next_set_recipes = Recipe.change_page(1) + assert_kind_of Array, next_set_recipes + assert_not next_set_recipes.empty? + next_set_recipes.each do |recipe| + assert_kind_of Recipe, recipe + end + assert_not_equal(recipes, next_set_recipes) + + # test that this works to request the previous set of recipes (as in, the first 'recipes' in this test) + previous_set_recipes = Recipe.change_page((-1)) + + assert_kind_of Array, previous_set_recipes + # assert_not previous_set_recipes.empty? + # previous_set_recipes.each do |recipe| + # assert_kind_of Recipe, recipe + # end + assert_equal(recipes, previous_set_recipes) + assert_not_equal(next_set_recipes, previous_set_recipes) + end + end + + test "change_page should not allow page <1 and instead return current page" do + VCR.use_cassette("hits") do + # we already asserted this works + clean_string = "cilantro" + recipes = Recipe.search_results(clean_string) + + invalid_recipe_request = Recipe.change_page((-200)) + assert_equal(recipes, invalid_recipe_request) + end + end + +# not implemented: will currently return: [] + # test "change_page should not allow page higher than total number of pages (listings total)%10" do + # assert false + # end + + test "two different recipe objects with the same data should be equal" do + recipe_a = Recipe.new(0, "Chocolate Ham", "ham.jpg", "http_string", "https_string", ["jam", "cheese"], ["Saturday night", "not for kids"]) + recipe_b = Recipe.new(0, "Chocolate Ham", "ham.jpg", "http_string", "https_string", ["jam", "cheese"], ["Saturday night", "not for kids"]) + + assert_equal(recipe_a, recipe_b) + end + +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 92e39b2d7..1754bd676 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,22 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require "minitest/reporters" + +# For API set-up +require 'vcr' +require 'webmock/minitest' + + +VCR.configure do |config| + config.cassette_library_dir = 'test/cassettes' # folder where casettes will be located + config.hook_into :webmock # tie into this other tool called webmock + config.default_cassette_options = { + :record => :new_episodes, # record new data when we don't have it yet + :match_requests_on => [:method, :uri, :body] # The http method, URI and body of a request all need to match + } +end + class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all