forked from spatten/ruby_koans
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathversioning_spec.rb
More file actions
29 lines (22 loc) · 739 Bytes
/
versioning_spec.rb
File metadata and controls
29 lines (22 loc) · 739 Bytes
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
def version_ints(version)
version.split(".").map { |v| v.to_i }
end
def at_least_ruby_version(version)
vints = version_ints(version)
ruby_vints = version_ints(RUBY_VERSION)
vints.zip(ruby_vints).all? { |v, rv| v.nil? || rv.nil? || v >= rv }
end
require 'rspec/given'
describe "#version_ints" do
Then { version_ints("1.2") == [1, 2] }
Then { version_ints("2.1.20") == [2, 1, 20] }
end
describe "at_least_ruby_version" do
Then { at_least_ruby_version("2") }
Then { at_least_ruby_version("2.0") }
Then { at_least_ruby_version("2.0.1") }
Then { at_least_ruby_version("2.1") }
Then { at_least_ruby_version("2.1.3.4.1") }
Then { ! at_least_ruby_version("1.9") }
Then { ! at_least_ruby_version("1.9.9.9.9") }
end