Sha256: e98f667461fbc8750ee7645ab163bb5590b2ca5cabd21aee1808e138c03f8db3

Contents?: true

Size: 1.02 KB

Versions: 61

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'open_classes/kernel'

describe Kernel do
  context :hash_to_attributes do
    class PersonForHashToAttributes
      attr_accessor :name, :age
    end

    cases = [
      {
        case_no: 1,
        case_title: 'valid hash case',
        hash: {
          name: 'hoge',
          age: 33,
        },
        expected_name: 'hoge',
        expected_age: 33,
      },
    ]

    cases.each do |c|
      it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
        begin
          case_before c

          # -- given --
          person = PersonForHashToAttributes.new

          # -- when --
          person.hash_to_attributes c[:hash]

          # -- then --
          expect(person.name).to eq(c[:expected_name])
          expect(person.age).to eq(c[:expected_age])
        ensure
          case_after c
        end
      end

      def case_before(c)
        # implement each case before
      end

      def case_after(c)
        # implement each case after
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.90 spec/open_classes/kernel/hash_to_attributes_spec.rb