Skip to content

Commit

Permalink
Write specs for all lib/**/*.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin21 committed May 25, 2017
1 parent 1cfe7b4 commit 6aaf859
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
19 changes: 19 additions & 0 deletions spec/space2dot/cli_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

describe Space2dot::Cli do
describe '#start' do
subject { -> { described_class.new(argv).start } }

context 'when arguments is empty' do
let(:argv) { %w(this is class) }

it { is_expected.to output(".this.is.class\n").to_stdout }
end

context 'when arguments is empty' do
let(:argv) { Array.new }

it { is_expected.not_to output(".this.is.class\n").to_stdout }
end
end
end
22 changes: 22 additions & 0 deletions spec/space2dot/dot_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# coding: utf-8

require 'spec_helper'

describe Space2dot::Dot do
let(:sentence) { %w(this is class) }
let(:expected) { '.this.is.class' }

subject { described_class.instance.convert(sentence) }

context 'when an argument is an array' do
let(:sentence) { ['this is class'] }

it { is_expected.to eq expected }
end

context 'when an argument is multiple arrayies' do
let(:sentence) { %w(this is class) }

it { is_expected.to eq expected }
end
end
10 changes: 10 additions & 0 deletions spec/space2dot/usage_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require 'spec_helper'

describe Space2dot::Usage do
subject { described_class.instance.text }

it { is_expected.to be_a String }
it { is_expected.not_to be_empty }
end
15 changes: 0 additions & 15 deletions spec/space2dot_spec.rb

This file was deleted.

4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
require 'space2dot'
require 'simplecov'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
])

SimpleCov.start do
add_filter '/vendor/'
Expand Down

0 comments on commit 6aaf859

Please sign in to comment.