-
Notifications
You must be signed in to change notification settings - Fork 19
/
notify_me_test.rb
35 lines (27 loc) · 902 Bytes
/
notify_me_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'bundler'
Bundler.require :default, :test
require 'minitest/autorun'
require 'rack/test'
require_relative './notify_me'
set :environment, :test
class NotifyMeTest < MiniTest::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_root_path_renders_message_and_form
get '/'
assert last_response.body.include?('Acme Widget will be launching soon!')
assert last_response.body.include?('form')
end
def test_subscribe_path_without_email_renders_error
post '/subscribe'
assert last_response.ok?
assert last_response.body.include?('Email is required to subscribe!')
end
def test_subscribe_path_with_email_renders_success_message
post '/subscribe', :email => "[email protected]"
assert last_response.ok?
assert last_response.body.include?("We'll notify [email protected] when Acme Widget launches!")
end
end