-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.rb
37 lines (28 loc) · 778 Bytes
/
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
36
37
ENV['RACK_ENV'] = 'test'
require 'minitest/autorun'
require 'rack/test'
require_relative 'number_cruncher.rb'
include Rack::Test::Methods
def app
Sinatra::Application
end
describe "Number Cruncher" do
it "should return the factors of 6" do
6.factors.must_equal [1,2,3,6]
end
it "should say that 2 is prime" do
assert 2.prime?
end
it "should say that 10 is not prime" do
refute 10.prime?
end
it "should return json" do
get '/6'
last_response.headers['Content-Type'].must_equal 'application/json'
end
it "should return the correct info about 6 as json" do
get '/6'
six_info = { number: 6, factors: 6.factors, odd: 6.odd?, even: 6.even?, prime: 6.prime? }
six_info.to_json.must_equal last_response.body
end
end