-
Notifications
You must be signed in to change notification settings - Fork 4
/
prime_naive_spec.rb
78 lines (64 loc) · 1.57 KB
/
prime_naive_spec.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require 'prime_naive'
describe PrimeNaive do
subject { described_class.new.is_prime?(input) }
context "for input of 2" do
let(:input) { 2 }
it { is_expected.to be_truthy }
end
context "non-primes" do
context "for input of less than 2" do
let(:input) { 1 }
it { is_expected.to be_falsey }
end
context "for input that is even" do
context "4" do
let(:input) { 4 }
it { is_expected.to be_falsey }
end
context "18" do
let(:input) { 18}
it { is_expected.to be_falsey }
end
context "86" do
let(:input) { 86 }
it { is_expected.to be_falsey }
end
end
context "for input that is a non-even square" do
context "9" do
let(:input) { 9 }
it { is_expected.to be_falsey }
end
context "25" do
let(:input) { 25 }
it { is_expected.to be_falsey }
end
context "81" do
let(:input) { 81 }
it { is_expected.to be_falsey }
end
end
context "for input of 21" do
let(:input) { 21 }
it { is_expected.to be_falsey }
end
end
context "for primes" do
context "for input of 29" do
let(:input) { 29 }
it { is_expected.to be_truthy }
end
context "for input of 79" do
let(:input) { 79 }
it { is_expected.to be_truthy }
end
context "for input of 953" do
let(:input) { 953 }
it { is_expected.to be_truthy }
end
context "for input of 2309" do
let(:input) { 2309 }
it { is_expected.to be_truthy }
end
end
end