Skip to content

Commit

Permalink
mock test for nil template
Browse files Browse the repository at this point in the history
  • Loading branch information
AdfPizarro committed Oct 31, 2022
1 parent 51e3f9a commit f29ddfd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec/bugcrowd_templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
require 'spec_helper'

describe BugcrowdTemplates do


describe '#VERSION' do
subject { described_class::VERSION }

Expand Down Expand Up @@ -44,6 +46,7 @@
let(:subcategory) { '' }
let(:item) { '' }
let(:file_name) { '' }
let!(:mock_path) {Pathname.new(Gem::Specification.find_by_name('bugcrowd_templates').gem_dir).join('spec').join('fixture')}

context 'with correct params' do
context 'with methodology type' do
Expand All @@ -54,6 +57,7 @@
let!(:item) { '' }
let!(:file_name) { 'information' }


it 'returns the bugcrowd template value as string' do
is_expected.to include('# Information gathering')
end
Expand Down Expand Up @@ -202,6 +206,7 @@
let!(:file_name) { 'template' }

it 'returns the nil' do
allow(BugcrowdTemplates).to receive(:current_directory).and_return( mock_path )
is_expected.to be_nil
end
end
Expand All @@ -213,8 +218,7 @@
let!(:file_name) { 'template' }

it 'returns the template defined in the category folder' do
allow(BugcrowdTemplates).to receive(:current_directory).and_return(
Pathname.new(Gem::Specification.find_by_name('bugcrowd_templates').gem_dir).join('spec').join('fixture'))
allow(BugcrowdTemplates).to receive(:current_directory).and_return( mock_path )

is_expected.to include('# Fixture Category')
end
Expand All @@ -227,8 +231,7 @@
let!(:file_name) {}

it 'returns the nil' do
allow(BugcrowdTemplates).to receive(:current_directory).and_return(
Pathname.new(Gem::Specification.find_by_name('bugcrowd_templates').gem_dir).join('spec').join('fixture'))
allow(BugcrowdTemplates).to receive(:current_directory).and_return( mock_path )
is_expected.to be_nil
end
end
Expand Down

0 comments on commit f29ddfd

Please sign in to comment.