Skip to content

Instantly share code, notes, and snippets.

@harryworld
Last active August 29, 2015 14:08
Show Gist options
  • Save harryworld/aa99e4bb043eff2d3a0f to your computer and use it in GitHub Desktop.
Save harryworld/aa99e4bb043eff2d3a0f to your computer and use it in GitHub Desktop.
BDD 5-min quiz
  1. What kinds of tests can we do in general?
User Acceptance Test
Integration Test
Unit Test
Stress Test
Profiling

  1. To implement Behaviour Driven Development:
  • Which gems did we use? capybara / rspec
  • What does each of those gems do?
    • capybara -> User Acceptance Test
    • rspec -> Unit Test
  1. What is the command to setup the BDD testing environment?
  • rails generate rspec:install
  1. Where do we put the spec files?
  • spec/features
  1. What is the naming convention of the testing files?
  • It should end with spec.rb
  1. What are the reserved keywords used in capybara?
  • How to visit a path? visit root_path
  • How to fill the information to input text field? fill_in 'Name', :with => 'Harry'
  • How to click a submit button? click_button 'Submit'
  • How to check the resulting page to have certain text? expect(page).to have_content 'Whatever'
  • How to check the existence of CSS in the resulting page? expect(page).to have_content 'container'

  1. Now, implement one test case in your own project.
@titaniumtails
Copy link

Answers:

  1. User Acceptance testing, Unit testing, Integration testing, stress test (focusing on the performance of the application).

  1. To implement BDD?
    • capybara - allows us to test web applications by simulating how a real user would interact with your app. It also gives us reserved words to be able to run tests for specific actions.
    • rspec - is a testing framework for Rails.
  2. What is the command to setup the BDD testing environment?
rails generate rspec:install

to run it:

bundle exec rspec

or just

rspec
  1. Where do we put the spec files?
    It is inside the home folder in the "spec" folder > "features".
  2. What is the naming convention of the testing files?
    filename_spec.rb
  3. What are the reserved keywords used in capybara?
    • How to visit a path?
page.has_xpath?
  • How to fill the information to input text field?
fill_in 'textfield', :with => 'Words'
  • How to click a submit button?
click_button
  • How to check the resulting page to have certain text?
page.has_content?('sometext')
  1. How to check the existence of CSS in the resulting page?
expect(page).to have_css('table tr. something')

@harryworld
Copy link
Author

Thanks Talia

@harryworld
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment