Giter Site home page Giter Site logo

basic-sinatra-forms-lab-v-000's Introduction

Sinatra Forms Lab

Overview

In this lab, you'll practice building forms in Sinatra by creating a basketball team sign-up sheet. Your application will have a basic HTML form, and will display the data from the form after it has been submitted by the user.

Instructions

  1. Run bundle install

  2. Run shotgun

  3. Make a form

    Create a route that responds to a GET request at /newteam. Add a form to the newteam.erb template and render it in the GET /newteam route.

    The form should have fields for: Team name ('name') Coach ('coach') Point Guard ('pg') Shooting Guard ('sg') Power Forward ('pf') Small Forward ('sf') Center ('c')

It should look something like this:

form for basketball team

When creating your form, your "Submit" button will need to be identified by an id 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.

  1. Handle form submission

    Create a route that responds to a POST request at /team Have the form send a POST request to this route. Upon submission, pass the submitted data to the team.erb template.

  2. Final Output

    Update the team.erb template so when you post to this form, it displays the name of the team and each member of the team.

    Your view should display something like this:

    completed form

  3. Deliverables

Pass the tests! Make sure you read the test output carefully!

Resources

View Sinatara Forms Lab on Learn.co and start learning to code for free.

basic-sinatra-forms-lab-v-000's People

Contributors

annjohn avatar danielseehausen avatar dependabot[bot] avatar dfenjves avatar ipc103 avatar jmburges avatar maxwellbenton avatar mendelb avatar pletcher avatar rishter avatar sgharms avatar snsavage avatar sylwiavargas avatar victhevenot avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

basic-sinatra-forms-lab-v-000's Issues

Problem with shooting guard test

The test for the shooting guard in the spec file is incorrect. Currently, it's:
fill_in(:pg, :with => "Ralph")

It should be:
fill_in(:sg, :with => "Ralph")

The spec_helper.rb file is missing a require statement

The following error was a result of missing require 'capybara/dsl'
/basic-sinatra-forms-lab-v-000/spec/spec_helper.rb:9:inblock in <top (required)>': uninitialized constant Capybara::DSL (NameError)
`

Once added learn worked again

Solution missing from App.rb

Wanted to check my submission against solution however it looks like the app.rb portion of the solution was removed some time ago and never replaced.

Submit button not found?

I was getting the following error:

Failure/Error: click_button "submit" Capybara::ElementNotFound: Unable to find button "submit"

Kind of strange. My button definitely was there.

I got it to pass by setting an id value of submit for the button.

The LINK language in the readme about Capybara & Submit Buttons is Wrong, and Causing Confusion

Hi,

I had to come back to this lab, as there was something gnawing at me about Capybara and how it identifies "button" values in a later lab.
Here's the issue... the sentence containing the link to the explanation about how Capybara can see which button to hit for its click_button function is WRONG.
Here's the sentence from the lesson's README:
We're telling this to you now because our test frame work, Capybara, requires buttons to be findable either by an id or name attribute.

It's the name attribute that is incorrect.
If I assign name="" to my button in question, I'll fail every Capybara test that is looking at that button.

If you click the link in that sentence in the lesson, the page you go to even tells you how Capybara identifies which button to press:
All buttons can be found by their id, value, or title.
No mention of the "name" attribute anywhere, and I've confirmed it doesn't work in different labs now.

Can you fix that sentence asap?
I can see from the other issues raised in this lab, I'm not the only one who was confused at first.

Thanks!

A couple of issues with this lab

Hello,

  1. Looks like there is a discrepancy between the readme and the tests... the test is expecting GET /newteam to render the form, but the readme says to use GET /team
  2. I think somewhere in here there should be a note that capybara requires submit buttons to have an id = "submit" so it can find it, similar to how text input requires a name... that took me a while to figure out to get my tests to pass
  3. In the test in POST /team, the shooting guard test has an error:
    it "displays the shooting gaurd's name in the browser" do
      visit '/newteam'

      fill_in(:pg, :with => "Joe")
      click_button "submit"

      expect(page).to have_text("Shooting Guard: Joe")
    end

fill_in :pg should be :sg

thanks!

Update from Capybara v 2.17.0 to 2.18.0 forces use of <button> over <input>

In newteam.erb, creating a form with <input type="submit" id="Submit"> produces error Capybara::ElementNotFound: Unable to find visible button "Submit"
This forces use of <button type="submit">, which is not stated explicitly in README.md.
All prior lessons and examples show using <input type="submit"> rather than <button type="submit">, leading to confusion. The fact that running shotgun and checking result in browser returns a working model displaying correct HTML compounds confusion.

Regression to Capybara v. 2.17.0 has tests passing using standard <input type="submit"> element.

Suggest updating Gemfile to gem 'capybara', '2.17.0' or updating README.md to include instruction on using button element.

Additionally, using id="Submit" can mislead students such as myself to enter type="Submit" as attribute for either button or input elements. Chrome defaults to type="submit" when an invalid type is used, but is not reflected in Capybara, leading to a working model in browser, but non-passing tests.

solution will not pass tests

get '/newteam' do
@team_members = %w(name coach pg sg pf sf c)
erb :newteam
end

post '/team' do
original_string = params['string']
@reversed_string = original_string.reverse
erb :newteam

Discrepancy with `submit` button

Local tests don't properly recognize submit button with either id or name attributes. However, it is properly recognized if labeled with the title attribute.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.