Last active
December 26, 2015 07:09
-
-
Save crguezl/7113648 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
require 'rack/showexceptions' | |
require './lib/rps' | |
builder = Rack::Builder.new do | |
use(Rack::Session::Cookie, {:key => 'rack session', | |
#:domain => 'localhost', | |
#:path => '/', #:expire_after => 2592000, | |
:secret => 'change_me'}) | |
#:key => 'rack.session', | |
# :domain => 'foo.com', | |
# :path => '/', :expire_after => 2592000, | |
use Rack::Static, :urls => ['/public'] | |
use Rack::ShowExceptions | |
use Rack::Lint | |
run RockPaperScissors::App.new | |
end | |
Rack::Handler::Thin.run builder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test/unit" | |
require "rack/test" | |
require './lib/rps' | |
class TestRockPaperScissorsApp < Test::Unit::TestCase | |
include Rack::Test::Methods | |
def app | |
Rack::Builder.new do | |
run RockPaperScissors::App.new | |
end.to_app | |
end | |
def test_index | |
get "/?choice=scissors" | |
#puts last_response.inspect | |
assert last_response.ok?, "checking status" | |
end | |
def test_body | |
get "/?choice=scissors" | |
match = (last_response.body =~ / (Ouch;\s+rock\s+beats\s+scissors | |
| You\s+tied\s+with\s+the\s+computer | |
| "Nicely\s+done;\s+scissors\s+beats\s+paper") | |
/x) | |
puts "\n\tTesting body. MATCH: #{$1 || 'no match'}" | |
#puts "\n******\n#{last_response.body}\n********\n" | |
assert match | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment