-
Notifications
You must be signed in to change notification settings - Fork 354
Home
Important note: The course was designed to work with Rails 4.2.3. If you're encountering trouble submitting your application, please make sure you're not using Rails 5.0. You can create a 4.2.3 app with:
rails _4.2.3_ new application_name
Please make sure that you are using Ruby 2.2.3 (or a more recent version in the 2.2 series). Ruby 2.3 is not officially supported while Ruby 2.4 is confirmed to be incompatible with Rails 4.2.3.
- "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?
- I am unable to install
gem 'pg'
- Why am I getting a
Malformed feedback
message from the grader? - How can I find out if my application has been generated using Rails 5?
- hello.html.erb does not work
- Why am I seeing Cliver::Dependency::NotFound after running rspec?
- SQLITE Error?
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
echo 'export FOOD2FORK_KEY = "Your API Key"' >> ~/.profile
For OSX
echo 'export FOOD2FORK_KEY = "Your API Key"' >> ~/.bash_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 status
The 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.
Notice that usually, you would not have to have the server up and running separately, but because we are using blackbox testing here - you do.
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
RecipesController
index
action 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.
- Create a heroku app
heroku create recipefinder-<a-random-number>
- 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"
-
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 don't really need pg
gem to be installed in your local environment (since you are running in development mode and working with sqlite
). The gem is used in production by Heroku, that is not going to have a problem installing it.
You can just
bundle install --without production
A1: You get this error message if you have puts
or print
statements in your code. Remove those statements and then resubmit.
A2: Your application may have been generated using Rails 5, which is incompatible with the grader.
A: Rails 5 will be referenced in the Gemfile that is generated as part of the application, replacing this file with the Gemfile given for the assignment (using Rails 4.2) will not work, as the rest of the application is still incompatible with Rails 4. There will also be extra files like config/initializers/new_framework_defaults.rb
.
I am getting some kind of a sqlite installation error
A: The new version of sqlite is hard to install on some platforms. Therefore, after creating your Rails app, update your Gemfile
to say
gem 'sqlite3', '1.3.13'
instead of just
gem 'sqlite'
Then, run bundle update
.
I modified my hello.html.erb exactly like it appears in the video and tried to run
http://localhost:3000/greeter/hello
to see it, but I get the following error:
Showing C:/Sites/my_first_app/app/views/layouts/application.html.erb where line #5 raised:
TypeError: unsupported property or method in object.
Rails.root: C:/Sites/my_first_app
What am I doing wrong?
A: Install Node.js and restart your computer and the problem should be fixed
I get the following error when I run rspec:
"Cliver::Dependency::NotFound:
Could not find an executable at given path 'c:/Program Files/phantomjs-2.1.1-windows/bin/phantomjs.EXE'.If this path was not specified explicitly, it is probably a bug in Cliver."
A: Make sure that the folder for phantomjs folder is under a folder which doesn't have spaces in it. For example, c:/phantomjs/phantomjs-2.1.1-windows/bin is OK.
A: No. The error WebMock::NetConnectNotAllowedError
is in fact related to the request being made to Food2Fork using wrong parameters and/or path.
When you get that error, check two things:
- The query argument
According to the API Documentation, one of the accepted parameters is named q
(not query
). This means that, "HTTP GET request must have the "q=keyword" query argument" (Technical Requirement #4).
- The argument passed to
base_uri
In the same Technical Requirement #4, it says that the query should be to the "/search" route. The tests were designed in a way that "/search" should be passed to the GET request, and not to base uri
.
One of the tests will concatenate the base_uri + '/search'
, so it would cause the test to have http://food2fork.com/api/search/search
and it would no be valid.
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
A: Yes. See the following https://building.coursera.org/developer-program 🎆