test/unit/context_info_tests.rb in assert-2.18.2 vs test/unit/context_info_tests.rb in assert-2.18.3
- old
+ new
@@ -6,47 +6,48 @@
class Assert::ContextInfo
class UnitTests < Assert::Context
desc "Assert::ContextInfo"
setup do
@caller = caller
- @klass = Assert::Context
- @info = Assert::ContextInfo.new(@klass, nil, @caller.first)
end
- subject{ @info }
+ subject { info1 }
+ let(:context1) { Assert::Context }
+ let(:info1) { Assert::ContextInfo.new(context1, nil, @caller.first) }
+
should have_readers :called_from, :klass, :file
should have_imeths :test_name
should "set its klass on init" do
- assert_equal @klass, subject.klass
+ assert_that(subject.klass).equals(context1)
end
should "set its called_from to the called_from or first caller on init" do
- info = Assert::ContextInfo.new(@klass, @caller.first, nil)
- assert_equal @caller.first, info.called_from
+ info = Assert::ContextInfo.new(context1, @caller.first, nil)
+ assert_that(info.called_from).equals(@caller.first)
- info = Assert::ContextInfo.new(@klass, nil, @caller.first)
- assert_equal @caller.first, info.called_from
+ info = Assert::ContextInfo.new(context1, nil, @caller.first)
+ assert_that(info.called_from).equals(@caller.first)
end
should "set its file from caller info on init" do
- assert_equal @caller.first.gsub(/\:[0-9]+.*$/, ""), subject.file
+ assert_that(subject.file).equals(@caller.first.gsub(/\:[0-9]+.*$/, ""))
end
should "not have any file info if no caller is given" do
- info = Assert::ContextInfo.new(@klass)
- assert_nil info.file
+ info = Assert::ContextInfo.new(context1)
+ assert_that(info.file).is_nil
end
should "know how to build the contextual test name for a given name" do
desc = Factory.string
name = Factory.string
- assert_equal name, subject.test_name(name)
- assert_equal "", subject.test_name("")
- assert_equal "", subject.test_name(nil)
+ assert_that(subject.test_name(name)).equals(name)
+ assert_that(subject.test_name("")).equals("")
+ assert_that(subject.test_name(nil)).equals("")
Assert.stub(subject.klass, :description){ desc }
- assert_equal "#{desc} #{name}", subject.test_name(name)
+ assert_that(subject.test_name(name)).equals("#{desc} #{name}")
end
end
end