Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Rails
- ## Setup
- ####Terminal
- - `$ rails new house-salad -T -d postgresql`
- - `cd house-salad`
- #### Gemfile
- ```ruby
- gem 'faraday'
- gem 'bootstrap-sass'
- group :development, :test do
- gem 'pry'
- gem 'rspec-rails'
- gem 'capybara'
- end
- ```
- #### Terminal
- ``` ruby
- $ bundle
- $ rails g rspec:install
- $ rails db:create
- $ rails db:migrate
- ```
- ## TDD
- #### Feature Test Example
- ```ruby
- require 'rails_helper'
- feature "user can search for house members" do
- scenario "user submits valid state name" do
- # As a user
- # When I visit "/"
- visit '/'
- select "Colorado", from: :state
- # And I select "Colorado" from the dropdown
- click_on "Locate Members of the House"
- # And I click on "Locate Members from the House"
- expect(current_path).to eq(search_path)
- # Then my path should be "/search" with "state=CO" in the parameters
- expect(page).to have_content("7 Results")
- # And I should see a message "7 Results"
- expect(page).to have_css(".member", count: 7)
- # And I should see a list of 7 the members of the house for Colorado
- within(first(".member")) do
- expect(page).to have_css(".name")
- expect(page).to have_css(".role")
- expect(page).to have_css(".party")
- expect(page).to have_css(".district")
- end
- # And they should be ordered by seniority from most to least
- # And I should see a name, role, party, and district for each member
- end
- end
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement