CHIPS 7.7: Intro to BDD and Cucumber

Due: 2026-10-21 11:59 PM PT
Released: 2026-10-13

Drive RottenPotatoes features from user stories, using Cucumber acceptance tests. This is part of Module 7.

CHIPS 7.7 is an individual assignment β€” you work on it and submit it on your own.

Goals

  • Express requirements as user stories and turn them into executable Cucumber scenarios (Given/When/Then).
  • Understand the difference between imperative and declarative scenario styles, and when each is appropriate.
  • Practice the outer loop of Behavior-Driven Design: red scenario β†’ implement β†’ green scenario.

What you’ll do

You’ll write Cucumber scenarios for the happy paths of the filtering and sorting features you added to RottenPotatoes in CHIPS 5.3, then write the step definitions that make them pass. The starter code includes a β€œcanonical” solution to CHIPS 5.3 to test against, plus the scaffolding for the first couple of scenarios (see features/).

Before you start

Watch Module 7 Β§7.1–7.6 and read the matching textbook sections. It helps to have finished CHIPS 5.3, since you’ll be testing the same features.

Logistics

  • Getting the code: see Getting the Code below β€” you clone the public starter repo and push it to a private repo of your own.
  • Autograding: submit to Gradescope; you may submit as many times as you like before the deadline. The autograder is a way for you to check your work and your understanding. Run the tests locally first β€” see Running Code and Tests.
  • Extensions: everyone automatically gets a 2-day no-penalty extension; see the extension policy.
  • Collaboration: this CHIPS is individual β€” you may discuss high-level approaches with anyone, but write and submit your own code. Sharing code is academic misconduct. See the AI Use Policy below before using AI tools.

AI Use Policy

This assignment follows the course AI Policy, which will be published on this site before it is needed. Until then, the rule from the Syllabus applies: you must be able to explain everything you submit.

Getting the Code

Public starter repo: saasbook/hw-bdd-cucumber — https://github.com/saasbook/hw-bdd-cucumber

GitHub makes it challenging to have a private fork of a public repository. These steps allow you to create a private space for you own work but still update from the starter code.

Clone the starter repo, then use gh (see Local Development) to create a private copy under your own GitHub account and push the code to it. Replace YOUR_GITHUB_USERNAME with your GitHub username:

git clone https://github.com/saasbook/hw-bdd-cucumber.git
cd hw-bdd-cucumber
git remote rename origin upstream
gh repo create YOUR_GITHUB_USERNAME/hw-bdd-cucumber --private --source=. --remote=origin --push
git remote set-url --push upstream DISABLED

After this, origin is your private repo and upstream is the public starter repo. The last command disables pushing to upstream, so git push always goes to your own copy β€” never to the public starter repo.

Keeping your repo up to date

Your private repo is a snapshot: it does not follow the starter repo. If we fix or add something in saasbook/hw-bdd-cucumber after you copy it, you have to pull those changes in yourself. The upstream remote you set up above is how you do that:

git fetch upstream

git fetch only downloads β€” it changes nothing in your working copy. Review what you are about to take before merging it:

git diff --name-only HEAD upstream/main   # just the names of the files that differ
git diff --stat HEAD upstream/main       # the same list, plus how much changed in each
git diff HEAD upstream/main -- spec      # the actual changes, limited to one file or directory

Then merge the upstream changes into your branch and push them to your private repo:

git merge upstream/main
git push origin main

If you and we edited the same lines, git stops and reports a conflict: open each file it lists, keep the correct combination of both sides, delete the <<<<<<< / ======= / >>>>>>> markers, then git add those files and git commit. Ask on Ed if a merge leaves you stuck β€” don't start over and lose your work.

These commands assume the starter repo's default branch is main. If git branch -r shows upstream/master instead, use that name in the commands above.

View this assignment on bCourses.

Running Code and Tests

Run everything below from the root of your clone (see Getting the Code). If Ruby isn't installed yet, work through Local Development first.

Install the dependencies

bundle install

Run this once after cloning, and again whenever the Gemfile changes. Prefix the commands below with bundle exec so you run the same gem versions the autograder does.

Boot the project

Create the database (once, and after any new migration), then start the Rails server:

bin/rails db:migrate
bin/rails server

The app is then at http://localhost:3000; Control-C stops the server. To try one thing without clicking through the UI, use the console, which loads your app and its models:

bin/rails console

Run the tests

Run the RSpec suite the way the Gradescope autograder will β€” get it green locally before you submit:

bundle exec rspec                           # the whole suite
bundle exec rspec spec/YOUR_FILE_spec.rb    # one spec file
bundle exec rspec spec/YOUR_FILE_spec.rb:42 # one example, by line number
bundle exec rspec --format documentation    # every example's description

Each failure prints the file and line of the failing example along with what it expected β€” start there rather than at the top of the output.

Run the Cucumber features

Cucumber runs the .feature files β€” the acceptance tests that describe the app's behavior from the user's point of view:

bundle exec cucumber                           # all features
bundle exec cucumber features/YOUR.feature     # one feature file
bundle exec cucumber features/YOUR.feature:12  # one scenario, by line

Submission

When you are done, submit your work to Gradescope. You may submit more than once before the deadline; only the final submission will be graded. It is your responsibility to check that the autograder on Gradescope runs as expected after you upload your submission.

Back to Top

Accessibility Nondiscrimination

Copyright Β©2026, Regents of the University of California and respective authors.

This site is built following the Berkeley Class Site template, which is generously based on the Just the Class, and Just the Docs templates.

View all course offerings