Sha256: bcb9dfae4e427e4cb51528a546966c9f704b60868ebd7a98fd04ea9c9cde7c73

Contents?: true

Size: 792 Bytes

Versions: 3

Compression:

Stored size: 792 Bytes

Contents

$:.unshift(File.join("..", "lib"))

require "cuba"
require "cuba/test"

form = <<EOS
  <form action="/login" method="post">
    <input name="user">
    <input type="submit" value="Login">
  </form>
EOS

Cuba.define do
  on get do
    on path("login") do
      res.write "Enter your username"
      res.write form
    end

    on default do
      res.redirect "/login"
    end
  end

  on post, path("login") do
    on param("user") do |user|
      res.write "Got #{user}"
    end
  end
end

Cuba.test "Sample Site" do
  story "As a user I want to be able to login" do
    scenario "A user submits good info" do
      visit "/"

      assert_contain "Enter your username"

      fill_in "user", :with => "Michel"
      click_button "Login"

      assert_contain "Got Michel"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cuba-0.0.3 test/cuba_test.rb
cuba-0.0.2 test/cuba_test.rb
cuba-0.0.1 test/cuba_test.rb