-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(FIXUP) Add acceptance tests for
pdk test unit
- Loading branch information
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
require 'spec_helper_acceptance' | ||
require 'fileutils' | ||
|
||
describe 'Running unit tests' do | ||
context 'with a fresh module' do | ||
include_context 'in a new module', 'unit_test_module_new' | ||
|
||
describe command('pdk test unit') do | ||
its(:exit_status) { is_expected.to eq(0) } | ||
its(:stdout) { is_expected.to match(%r{no examples found}i) } | ||
its(:stderr) { is_expected.to match(%r{running unit tests}i) } | ||
end | ||
end | ||
|
||
context 'with passing tests' do | ||
include_context 'in a new module', 'unit_test_module_pass' | ||
|
||
before(:all) do | ||
FileUtils.mkdir_p('spec/unit') | ||
File.open('spec/unit/passing_spec.rb', 'w') do |f| | ||
f.puts <<-EOF | ||
require 'spec_helper' | ||
RSpec.describe 'test' do | ||
it 'should pass' do | ||
expect(true).to eq(true) | ||
end | ||
end | ||
EOF | ||
end | ||
end | ||
|
||
describe command('pdk test unit') do | ||
its(:exit_status) { is_expected.to eq(0) } | ||
its(:stderr) { is_expected.to match(%r{running unit tests.*1 tests.*0 errors.*0 failures}im) } | ||
end | ||
end | ||
|
||
context 'with failing tests' do | ||
include_context 'in a new module', 'unit_test_module_fail' | ||
|
||
before(:all) do | ||
FileUtils.mkdir_p('spec/unit') | ||
File.open('spec/unit/failing_spec.rb', 'w') do |f| | ||
f.puts <<-EOF | ||
require 'spec_helper' | ||
RSpec.describe 'failing test' do | ||
it 'should pass' do | ||
expect(false).to eq(true) | ||
end | ||
end | ||
EOF | ||
end | ||
end | ||
|
||
describe command('pdk test unit') do | ||
its(:exit_status) { is_expected.not_to eq(0) } | ||
its(:stdout) { is_expected.to match(%r{failed.*expected: true got: false}i) } | ||
its(:stderr) { is_expected.to match(%r{running unit tests.*1 tests.*0 errors.*1 failures}im) } | ||
end | ||
end | ||
|
||
context 'with pending tests' do | ||
include_context 'in a new module', 'unit_test_module_pending' | ||
|
||
before(:all) do | ||
FileUtils.mkdir_p('spec/unit') | ||
File.open('spec/unit/pending_spec.rb', 'w') do |f| | ||
f.puts <<-EOF | ||
require 'spec_helper' | ||
RSpec.describe 'pending test' do | ||
it 'should pass' do | ||
pending | ||
expect(false).to eq(true) | ||
end | ||
end | ||
EOF | ||
end | ||
end | ||
|
||
describe command('pdk test unit') do | ||
its(:exit_status) { is_expected.to eq(0) } | ||
its(:stderr) { is_expected.to match(%r{running unit tests.*1 tests.*0 errors.*0 failures.*1 pending}im) } | ||
end | ||
end | ||
end |