test/unit/view_helpers_tests.rb in assert-2.19.2 vs test/unit/view_helpers_tests.rb in assert-2.19.3

- old
+ new

@@ -10,13 +10,13 @@ require "assert/view" module Assert::ViewHelpers class UnitTests < Assert::Context desc "Assert::ViewHelpers" - subject { unit_class } + subject{ unit_class } - let(:unit_class) { + let(:unit_class) do test_opt_val = test_opt_val1 Class.new do include Assert::ViewHelpers option "test_opt", test_opt_val @@ -25,13 +25,13 @@ # use the assert config since it has tests, contexts, etc # also maybe use a fresh config that is empty @config ||= [Assert.config, Assert::Config.new].sample end end - } + end - let(:test_opt_val1) { Factory.string } + let(:test_opt_val1){ Factory.string } should have_imeths :option should "include the config helpers" do assert_that(subject).includes(Assert::ConfigHelpers) @@ -51,11 +51,11 @@ end end class InitTests < UnitTests desc "when init" - subject { unit_class.new } + subject{ unit_class.new } should have_imeths :captured_output, :re_run_test_cmd should have_imeths :tests_to_run_count_statement, :result_count_statement should have_imeths :to_sentence should have_imeths :all_pass_result_summary_msg, :result_summary_msg @@ -75,11 +75,13 @@ exp = "assert -t #{test_id.gsub(Dir.pwd, ".")}" assert_that(subject.re_run_test_cmd(test_id)).equals(exp) end should "know its tests-to-run count and result count statements" do - exp = "#{subject.tests_to_run_count} test#{"s" if subject.tests_to_run_count != 1}" + exp = + "#{subject.tests_to_run_count} "\ + "test#{"s" if subject.tests_to_run_count != 1}" assert_that(subject.tests_to_run_count_statement).equals(exp) exp = "#{subject.result_count} result#{"s" if subject.result_count != 1}" assert_that(subject.result_count_statement).equals(exp) end @@ -89,11 +91,11 @@ assert_that(subject.to_sentence(items)).equals(items.first) items = 2.times.map{ Factory.string } assert_that(subject.to_sentence(items)).equals(items.join(" and ")) - items = (Factory.integer(3)+2).times.map{ Factory.string } + items = (Factory.integer(3) + 2).times.map{ Factory.string } exp = [items[0..-2].join(", "), items.last].join(", and ") assert_that(subject.to_sentence(items)).equals(exp) end should "know its all pass result summary message" do @@ -101,11 +103,11 @@ assert_that(subject.all_pass_result_summary_msg).equals("uhh...") Assert.stub(subject, :result_count){ 1 } assert_that(subject.all_pass_result_summary_msg).equals("pass") - Assert.stub(subject, :result_count){ Factory.integer(10)+1 } + Assert.stub(subject, :result_count){ Factory.integer(10) + 1 } assert_that(subject.all_pass_result_summary_msg).equals("all pass") end should "know its result summary msg" do res_type = :pass @@ -113,11 +115,11 @@ exp = subject.all_pass_result_summary_msg assert_that(subject.result_summary_msg(res_type)).equals(exp) Assert.stub(subject, :all_pass?){ false } res_type = [:pass, :ignore, :fail, :skip, :error].sample - exp = "#{subject.send("#{res_type}_result_count")} #{res_type.to_s}" + exp = "#{subject.send("#{res_type}_result_count")} #{res_type}" assert_that(subject.result_summary_msg(res_type)).equals(exp) end should "know its results summary sentence" do items = @@ -137,11 +139,11 @@ end end class AnsiTests < UnitTests desc "Ansi" - subject { Ansi } + subject{ Ansi } should have_imeths :code_for should "know its codes" do assert_that(subject::CODES).is_not_empty @@ -160,14 +162,16 @@ end end class AnsiInitTests < UnitTests desc "when mixed in on a view" - subject { view1 } + subject{ view1 } - let(:view_class1) { Class.new(Assert::View){ include Ansi } } - let(:view1) { view_class1.new(Factory.modes_off_config, StringIO.new(+"", "w+")) } + let(:view_class1){ Class.new(Assert::View){ include Ansi } } + let(:view1) do + view_class1.new(Factory.modes_off_config, StringIO.new(+"", "w+")) + end should have_imeths :ansi_styled_msg should "know how to build ansi styled messages" do msg = Factory.string @@ -188,10 +192,13 @@ Assert.stub(subject, :is_tty?){ true } Assert.stub(subject, :styled){ true } Assert.stub(subject, "#{result_type}_styles"){ [] } assert_that(subject.ansi_styled_msg(msg, result_type)).equals(msg) - styles = Factory.integer(3).times.map{ Assert::ViewHelpers::Ansi::CODES.keys.sample } + styles = + Factory.integer(3).times.map do + Assert::ViewHelpers::Ansi::CODES.keys.sample + end Assert.stub(subject, "#{result_type}_styles"){ styles } exp_code = Assert::ViewHelpers::Ansi.code_for(*styles) exp = exp_code + msg + Assert::ViewHelpers::Ansi.code_for(:reset) assert_that(subject.ansi_styled_msg(msg, result_type)).equals(exp) end