This repo is a small, but working POC (Proof of Concept) of how we might accomplish "Blackbox testing"
https://www.coursera.org/learn/ruby-on-rails-intro/lecture/RbJIe/blackbox-testing
How do we blackbox-test a webapp (Rails or any webapp really) using Ruby? (And why should we use Ruby for this?)
Enter RSpec + Capybara ruby gems. When these 2 frameworks come together, you can write very intuitive and expressive tests.
For example, can you tell what the following test does?
describe "Recipes App" do
it "displays chocolate by default" do
visit "/"
expect(page).to have_content 'Chocolate Tea'
end
it "displays beef when keyword is beef" do
visit "?keyword=beef"
expect(page).to have_content 'Delicious Scalloped Potato'
end
end
##How do I get started?
- Install PhantomJS (http://phantomjs.org/)
- Run the following inside your terminal:
$ gem install rspec
$ gem install selenium-webdriver
$ gem install capybara
$ gem install poltergeist
-
(If you are using
rbenv
, also run$rbenv rehash
) -
Pull down this repo
-
Run the following in your terminal (right outside of
spec
dir):$ rspec
or even better
$ rspec -f d
to see the magic.
# Capybara.default_driver = :selenium
# Headless
Capybara.default_driver = :poltergeist