-
Notifications
You must be signed in to change notification settings - Fork 349
Home
- "API Key: None" when signing into API Admin section of Food2Fork site?
- How to set an environment variable?
- My app works, but the tests say the environment variables are not set
- My app works on the browser, but does not pass the tests
- I can see "Kahúla-Spiked" on the page, but the test does not pass
- How to deploy 'Recipe Finder' to Heroku?
- Why am I getting 'uninitialized constant Capybara' when running RSpec?
A: You have to create an account and sign in using that account. If you sign in with Facebook, your API Key will be None (which is kinda useless).
A: It depends on your OS. If you want to set a permanent environment variable:
For Windows 10:
- Click on the Windows key and type env; select "Edit the system environment variables"
- Click "Environment variables..."; select "New..." under System variables
- On Variable Name, enter the name of the variable (in this case, FOOD2FORK_KEY)
- On Variable Value, enter the value of your API key
For Linux and OSX:
echo 'export FOOD2FORK_KEY = "Your API Key"' >> ~/.profile
NOTE: there is no need to set the ENV['FOOD2FORK_SERVER_AND_PORT'], because this variable will be used only by the grader
A: According to the assignment instructions, the rspec command can be run from any location. However, the tests are looking for the strings "FOOF2FORK_KEY" and "FOOD2FORK_SERVER_AND_PORT" within ./app (relative path to app directory). That's why the tests have to be run from the root of your application (the folder that contains the app directory). Because of this, please copy the spec folder and .rspec file to be alongside the app directory prior to running the rspec command.
A: Take a look at the error messages you get when you run rspec. If you see something like the following:
Failures:
1) Recipes App displays 'Kahlúa-Spiked' when request parameter 'search' is mocha
(...) # left out to make it more readable
Request to 'http://localhost:3000?search=mocha' failed to reach server, check DNS and/or server statusThe message you are seeing is basically saying that your server is not running.
Make sure you leave your server running in one window (rails server) and run the RSpec tests from another terminal window.
A: If you start Rails server, search for "mocha" and see "Kahúla-Spiked" on the page, but the test does not pass, you need to check the URL for the search page. It has to be http://localhost:3000/?search=mocha. The URL tells you two things:
- The
RecipesControllerindexaction must be the root of the application - The parameter name has to be
search(notlooking_for)
A: First, you need to have a Heroku account. After signing up, download and install the Heroku Toolbelt appropriate to your Operating System. Open up the console and type heroku login. It will finish installing the toolbelt and ask you for your credentials. More details on Heroku Toolbelt page.
- Set an environment variable by running
heroku config:set FOOD2FORK_KEY=<your-api-key>
- Add the following to your
Gemfile:
group :production do
gem 'pg'
gem 'rails_12factor'
end
a. Find where gem 'sqlite3' is on Gemfile and move it to a group, like the following:
group :development, :test do gem 'sqlite3' end
b. Run bundle --without production
NOTE: You should not make changes on Gemfile before submitting your work to be graded. Consider deploying your app to Heroku after you pass the assignment.
- If you have not yet done so, initialize and commit to git:
git init
git add .
git commit -m "initial commit"
- Create a heroku app
heroku create recipefinder-<a-random-number>
-
Push to Heroku:
git push heroku master -
Migrate your database:
heroku run rake db:migrate -
Visit you application!
heroku open
More information on Heroku Dev Center
A: Together with the spec folder provided, there is also an .rspec file that contains --require spec_helper command which tells RSpec to include spec_helper.rb file located inside the spec folder. The spec_helper.rb includes the necessary Capybara files. If you are getting this error - the chances are you did not copy over the .rspec file.
A: You need to turn off the SSL verification by adding
default_options.update(verify: false)
inside Coursera class. You can check the app created for the lecture here: https://github.com/jhu-ep-coursera/fullstack-course1-module3/blob/master/app/models/coursera.rb#L4