learn-co-curriculum / basic-sinatra-forms-lab Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
"When creating your form, your "Submit" button will need to be identified by
either an id attribute or a name attribute with value of "Submit"."
This statement is misleading. It says that the form should have EITHER an id attribute OR a name attribute with the value of "submit", but the only way to make the tests pass is if BOTH the type AND the id are set to "submit".
I got uninitialized constant Capybara::DSL (NameError)
until I put require 'capybara/dsl'
at the top of spec_helper.rb.
Had error loading the 'require "capybara/poltergeist"'
Got tests to pass after modifying the 'spec_helper.rb' file to this
ENV["SINATRA_ENV"] = "test"
require_relative '../config/environment'
require 'rack/test'
# require 'capybara/poltergeist'
require 'capybara/rspec'
require 'capybara/dsl'
# Capybara.javascript_driver = :poltergeist
RSpec.configure do |config|
config.include Capybara::DSL
config.include Rack::Test::Methods
config.order = 'default'
end
def app
Rack::Builder.parse_file('config.ru').first
end
Capybara.app = app
spec/spec_helper needs to require 'capybara/rspec' in order to run rspec
shooting guard appears twice in the tests
Attribute is duplicated, please see below!
When creating your form, your "Submit" button will need to be identified by an id attribute attribute with value of "Submit". We're telling this to you now because our test frame work, Capybara, requires buttons to be findable by an id, title, or value attribute.
In your instructions for this lab, it says that capybara is looking for a name or id of "Submit". In the tests however, it is looking for a name of label of "submit". Lower case s. If it is uppercase, as in the instructions, the test will fail. I recommend changing the instructions or test to reflect each other.
They should find the form (Feel free to tell them how to id
the form) and then fill it out. That way you don't have to just do the manual post stuff and can actually "use" their app
There is a paragraph in the instructions of this lab that states, "When creating your form, your "Submit" button will need to be identified by either an id attribute or a name attribute with value of "Submit"." I have found two issues with this instruction. For both of the issues below I receive the same error.
Capybara::ElementNotFound: Unable to find visible button "submit"
Instructions say GET /team and POST /newteam. Rspec wants GET/newteam and POST/team.
Hi. I found a few issues with the tests. The most important one is that there is a test missing for the Small Forward in the describe 'POST /team'
block. I think it needs to look something like this:
it "displays the small forward's name in the browser" do
visit '/newteam'
fill_in(:sf, :with => "Ian")
click_button "Submit"
expect(page).to have_text("Small Forward: Ian")
end
The second issue is that the tests are in a different order than the output shown in the README.
Lastly, there's a small typo in the it "displays the shooting gaurd's name in the browser"
block (Line 65, as of now). "gaurd" should be "guard".
Thanks for looking into this! As I said, the first issue here is the most important one; the other two don't need to be high priorities (in my opinion).
---Sdcrouse
The spec checks Shooting guard twice and never checks small forward.
basic_sinatra_forms_spec.rb
check lines 49 - 56
and
check lines 67 -74
The link to "Ashley William's GitHub - Citibike Sinatra" is incorrect. It should be https://github.com/ashleygwilliams/citibike-sinatra.
Never mind - I didn't realize there were two separate links in each line :)
In the solution file, app.rb seems funny:
There is never a call to erb :team
so the team.erb
file is never in play
The instance variables are from the previous lesson and in the wrong place, and there is leftover code from previous lesson where we reversed a string using a form.
Here is what I think it sould look like:
require 'sinatra/base'
class App < Sinatra::Base
get '/newteam' do
erb :newteam
end
post '/team' do
@name = params["name"]
@coach = params["coach"]
@pg = params["pg"]
@sg = params["sg"]
@sf = params["sf"]
@pf = params["pf"]
@c = params["c"]
erb :team
end
end
Not using restful conventions.
Your application will have a basic HTML form, and will display the data from the form after it has been submitted by the user.
if there is no spelling error please explain what it means!!!
Hi,
From previous lessons, it was not apparent that capybara's test suite needs to have the submit button have an id of "submit"
Team name:
Coach:
Point guard:
Shooting Guard:
Power Forward:
Small Forward:
Center:
The above works, but it also works with:
which is confusing since the app works and does what is expected, but the tests don't pass..?
The post request should be from /newteam, not /team. This is how it's explained in the prior lessons and is the only way to make the tests pass. The form information comes from /newteam and gets passed to the /team page through post /newteam. Please see below and note that the solution code needs to be edited as well.
Original: "Create a route that responds to a POST request at /team"
Corrected: "Create a route that responds to a POST request at /newteam"
*changed "/team" to "/newteam"
This is no longer necessary nor is it consistent with other labs in the same section.
I was getting the following error:
Failure/Error: click_button "submit" Capybara::ElementNotFound: Unable to find button "submit"
I got it to pass by setting an id value of submit for the button.
submit button has correct format and works, tests cannot find the button
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.