From 09008a4001f18bfc4d49649ac39020f59902ac50 Mon Sep 17 00:00:00 2001 From: tominaga Date: Sat, 19 Sep 2020 22:24:02 +0900 Subject: [PATCH] add data type spec --- spec/basic/step03_data_type_spec.rb | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 spec/basic/step03_data_type_spec.rb diff --git a/spec/basic/step03_data_type_spec.rb b/spec/basic/step03_data_type_spec.rb new file mode 100644 index 0000000..02e7b83 --- /dev/null +++ b/spec/basic/step03_data_type_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' +require 'date' +require 'bigdecimal' + +describe 'Step03DataTypeSpec' do + context 'basic type' do + # What string is sea variable at the method end?
+ # (メソッド終了時の変数 sea の中身は?) + it 'spec datatype basic type' do + sea = "mystic" + land = 416 + piari = Date.new(2001, 9, 4) + bonvo = DateTime.new(2001, 9, 4, 12, 34, 56) + dstore = true + amba = BigDecimal("9.4") + + piari = piari + 1 + land = piari.year + bonvo = bonvo << 1 + land = bonvo.month + land -= 1 + if dstore + addedDecimal = amba + BigDecimal(land) + sea = addedDecimal.to_s + end + log(sea); # your answer? => + end + end + + context 'object' do + # Same as the previous method question. (前のメソッドの質問と同じ) + it 'spec datatype object' do + stage = St3ImmutableStage.new("hangar") + sea = stage.stage_name() + log(sea) # your answer? => + end + end + + class St3ImmutableStage + attr_reader :stage_name + + def initialize(stage_name) + @stage_name = stage_name + end + end +end +