Skip to content

Commit

Permalink
test(examples): add specs for gemfile format
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Nov 20, 2022
1 parent e5997bf commit 197f1e1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/convenient_service/examples/standard/gemfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
require_relative "gemfile/services"

##
# Usage example:
# @internal
# Usage example:
#
# result = ConvenientService::Examples::Standard::Gemfile.format(path: "Gemfile")
# result = ConvenientService::Examples::Standard::Gemfile.format(path: "spec/cli/gemfile/format/fixtures/Gemfile")
# result = ConvenientService::Examples::Standard::Gemfile.format(path: "Gemfile")
# result = ConvenientService::Examples::Standard::Gemfile.format(path: "spec/cli/gemfile/format/fixtures/Gemfile")
#
module ConvenientService
module Examples
module Standard
module Gemfile
class << self
def format
def format(path)
Services::Format[path: path]
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module Services
class Format
include ConvenientService::Standard::Config

attr_reader :path

step Services::ReadFileContent, in: :path, out: :content
step Services::StripComments, in: :content, out: :content_without_comments
step Services::ParseContent, in: {content: :content_without_comments}, out: :parsed_content
Expand Down
23 changes: 23 additions & 0 deletions spec/lib/convenient_service/examples/standard/gemfile_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require "spec_helper"

require "convenient_service"

RSpec.describe ConvenientService::Examples::Standard::Gemfile do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "class methods" do
describe ".format" do
let(:file) { Tempfile.new }
let(:path) { file.path }

specify do
expect { described_class.format(path) }
.to delegate_to(described_class::Services::Format, :result)
.with_arguments(path: path)
.and_return_its_value
end
end
end
end

0 comments on commit 197f1e1

Please sign in to comment.