Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipes - Sairagul - Muncher #48

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
All tests pass for Recipe.rb
sairagula committed Nov 9, 2017
commit a848459ee5b444f32b74e084348a044db3167402
5 changes: 0 additions & 5 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
5 changes: 0 additions & 5 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
18 changes: 18 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

end
8 changes: 4 additions & 4 deletions lib/recipe.rb
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@ def initialize(uri, title, image, options = {} )
@uri = uri
@image = image

@diet_labels = options[:diet_labels]
@source = options[:source]
@url = options[:url]
@ingredient_lines = options[:ingredient_lines]
@diet_labels = options["diet_labels"]
@source = options["source"]
@url = options["url"]
@ingredient_lines = options["ingredient_lines"]
end

def id
14 changes: 7 additions & 7 deletions test/controllers/munchers_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "test_helper"

describe MunchersController do
# it "must be a real test" do
# flunk "Need real tests"
# end
end
# require "test_helper"
#
# describe MunchersController do
# # it "must be a real test" do
# # flunk "Need real tests"
# # end
# end
43 changes: 43 additions & 0 deletions test/lib/recipe_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'test_helper'
describe Recipe do

describe "initialize" do
it "Cannot be initialized without required parameters" do
proc {
Recipe.new
}.must_raise ArgumentError

proc {
Recipe.new "title"
}.must_raise ArgumentError
end

it "should initialize instance variables properly" do
recipe = Recipe.new("uri", "title","image")
recipe.title.must_equal "title"
recipe.uri.must_equal "uri"
recipe.image.must_equal "image"
end

it "responds to optional fields" do
options = {
"diet_labels": ["diet_labels"],
"source": ["source"],
"url": ["url"]
}
recipe = Recipe.new( ["Low-Fat"], [ "Vegan", "Vegetarian"], "Self", "http://www.self.com/challenge/2011/nutrition/recipe/dinners/soup-and-salad-combo")

recipe.diet_labels.must_equal options["diet_labels"]
recipe.source.must_equal options["source"]
recipe.url.must_equal options["url"]
recipe.ingredient_lines.must_equal options["ingredient_lines"]
end
end # end of initialize

describe "id" do
it "should return the id of a uri" do
recipe = Recipe.new("http://www.edamam.com/ontologies/edamam.owl#recipe_df05891dd71023b6271cb0fc67a88289", "Title","image")
recipe.id.must_equal "df05891dd71023b6271cb0fc67a88289"
end
end
end # end of Recipe
16 changes: 16 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
require "rails/test_help"
require "minitest/rails"
require "minitest/reporters" # for Colorized output
require 'vcr'
require 'webmock/minitest'

# For colorful output!
Minitest::Reporters.use!(
@@ -11,7 +13,21 @@
Minitest.backtrace_filter
)

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
}
config.filter_sensitive_data("<API_KEY>") do
ENV['API_KEY']
end
config.filter_sensitive_data("<APP_ID>") do
ENV['APP_ID']
end

end
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
# to the test group in the Gemfile and uncomment the following:
# require "minitest/rails/capybara"