Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. # Rails
  2.  
  3. ## Setup
  4.  
  5. ####Terminal
  6. - `$ rails new house-salad -T -d postgresql`
  7. - `cd house-salad`
  8.  
  9. #### Gemfile
  10. ```ruby
  11. gem 'faraday'
  12. gem 'bootstrap-sass'
  13.  
  14. group :development, :test do
  15. gem 'pry'
  16. gem 'rspec-rails'
  17. gem 'capybara'
  18. end
  19. ```
  20. #### Terminal
  21.  
  22. ``` ruby
  23. $ bundle
  24. $ rails g rspec:install
  25. $ rails db:create
  26. $ rails db:migrate
  27. ```
  28.  
  29. ## TDD
  30.  
  31. #### Feature Test Example
  32.  
  33. ```ruby
  34. require 'rails_helper'
  35.  
  36. feature "user can search for house members" do
  37.  
  38. scenario "user submits valid state name" do
  39. # As a user
  40. # When I visit "/"
  41. visit '/'
  42.  
  43. select "Colorado", from: :state
  44. # And I select "Colorado" from the dropdown
  45. click_on "Locate Members of the House"
  46. # And I click on "Locate Members from the House"
  47. expect(current_path).to eq(search_path)
  48. # Then my path should be "/search" with "state=CO" in the parameters
  49. expect(page).to have_content("7 Results")
  50. # And I should see a message "7 Results"
  51. expect(page).to have_css(".member", count: 7)
  52. # And I should see a list of 7 the members of the house for Colorado
  53.  
  54. within(first(".member")) do
  55. expect(page).to have_css(".name")
  56. expect(page).to have_css(".role")
  57. expect(page).to have_css(".party")
  58. expect(page).to have_css(".district")
  59. end
  60. # And they should be ordered by seniority from most to least
  61. # And I should see a name, role, party, and district for each member
  62.  
  63. end
  64. end
  65. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement