From 064cfaf16ed2f6ca8500ca85ddf8a291933e12f7 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Tue, 7 Jun 2022 22:13:01 +0300 Subject: [PATCH] Ruby: Add specs for KernAux::File --- pkgs/ruby/lib/kernaux/file.rb | 20 +++++++++++--------- pkgs/ruby/spec/lib/kernaux/file_spec.rb | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 pkgs/ruby/spec/lib/kernaux/file_spec.rb diff --git a/pkgs/ruby/lib/kernaux/file.rb b/pkgs/ruby/lib/kernaux/file.rb index b2c9ee8..426c6e0 100644 --- a/pkgs/ruby/lib/kernaux/file.rb +++ b/pkgs/ruby/lib/kernaux/file.rb @@ -2,18 +2,20 @@ # rubocop:disable Lint/EmptyClass -module KernAux - ## - # File simulator. - # - class File +if defined? KernAux::File + module KernAux ## - # @!method initialize(out) - # Create a file. + # File simulator. # - # @param out [Proc] writing method + class File + ## + # @!method initialize(out) + # Create a file. + # + # @param out [Proc] writing method - # @!parse [ruby] + # @!parse [ruby] + end end end diff --git a/pkgs/ruby/spec/lib/kernaux/file_spec.rb b/pkgs/ruby/spec/lib/kernaux/file_spec.rb new file mode 100644 index 0000000..f21903a --- /dev/null +++ b/pkgs/ruby/spec/lib/kernaux/file_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +defined? KernAux::File and RSpec.describe KernAux::File do + subject(:our_file) { described_class.new method :out } + + def out(str) + (@buffer ||= +'') << String(str) + end + + specify do + expect(our_file.instance_variable_get(:@out)).to eq method :out + end +end