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
|
Description: Adapt specs to RSpec2
Do require 'spec', the deprecated version of RSpec.
Change be_close to be_within to avoid warnings
Author: Cédric Boutillier <boutil@debian.org>
Bug: https://github.com/clbustos/minimization/pull/1
Last-Update: 2012-12-10
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,12 +1,6 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'minimization.rb'
-require 'spec'
-require 'spec/autorun'
-
-Spec::Runner.configure do |config|
-
-end
class String
def deindent
--- a/spec/minimization_unidimensional_spec.rb
+++ b/spec/minimization_unidimensional_spec.rb
@@ -14,10 +14,10 @@
@min.iterate
end
it "#x_minimum be close to expected" do
- @min.x_minimum.should be_close(@p1,@min.epsilon)
+ @min.x_minimum.should be_within(@min.epsilon).of(@p1)
end
it "#f_minimum ( f(x)) be close to expected" do
- @min.f_minimum.should be_close(@p2,@min.epsilon)
+ @min.f_minimum.should be_within(@min.epsilon).of(@p2)
end
context "#log" do
subject {@min.log}
@@ -32,10 +32,10 @@
@min = Minimization::GoldenSection.minimize(-1000,1000, &@func)
end
it "#x_minimum be close to expected" do
- @min.x_minimum.should be_close(@p1,@min.epsilon)
+ @min.x_minimum.should be_within(@min.epsilon).of(@p1)
end
it "#f_minimum ( f(x)) be close to expected" do
- @min.f_minimum.should be_close(@p2,@min.epsilon)
+ @min.f_minimum.should be_within(@min.epsilon).of(@p2)
end
context "#log" do
subject {@min.log}
@@ -48,10 +48,10 @@
@min = Minimization::Brent.minimize(-1000,1000, &@func)
end
it "should x be correct" do
- @min.x_minimum.should be_close(@p1,@min.epsilon)
+ @min.x_minimum.should be_within(@min.epsilon).of(@p1)
end
it "should f(x) be correct" do
- @min.f_minimum.should be_close(@p2,@min.epsilon)
+ @min.f_minimum.should be_within(@min.epsilon).of(@p2)
end
context "#log" do
subject {@min.log}
|