Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-couple BetweenMeals::Repo class conformance tests #132

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions spec/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
require 'between_meals/repo/git'
require 'between_meals/repo.rb'
require 'logger'
require_relative 'repo_subclass_conformance'

describe BetweenMeals::Repo::Git do
context 'conforms to BetweenMeals::Repo interfaces' do
it_behaves_like 'Repo subclass conformance', BetweenMeals::Repo::Git
end
let(:logger) do
Logger.new('/dev/null')
end
Expand Down
4 changes: 4 additions & 0 deletions spec/hg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
require 'between_meals/repo/hg'
require 'between_meals/repo.rb'
require 'logger'
require_relative 'repo_subclass_conformance'

describe BetweenMeals::Repo::Hg do
context 'conforms to BetweenMeals::Repo interfaces' do
it_behaves_like 'Repo subclass conformance', BetweenMeals::Repo::Git
end
let(:logger) do
Logger.new('/dev/null')
end
Expand Down
22 changes: 6 additions & 16 deletions spec/repo_spec.rb → spec/repo_subclass_conformance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,15 @@
# limitations under the License.

require 'between_meals/repo'
require 'between_meals/repo/git'
require 'between_meals/repo/svn'

describe 'BetweenMeals::Repo' do
shared_examples 'Repo subclass conformance' do |klass|
let(:class_interface) { BetweenMeals::Repo.public_methods.sort }
let(:instance_interface) { BetweenMeals::Repo.instance_methods.sort }

# Misc Repos should not expose anything more than parent class,
# which default to 'Not implemented'
[
BetweenMeals::Repo::Git,
BetweenMeals::Repo::Svn,
BetweenMeals::Repo::Hg,
].each do |klass|
it "#{klass} should conform to BetweenMeals::Repo class interface" do
expect(klass.public_methods.sort).to eq(class_interface)
end
it "#{klass} should conform to BetweenMeals::Repo instance interface" do
expect(klass.instance_methods.sort).to eq(instance_interface)
end
it "#{klass} should conform to BetweenMeals::Repo class interface" do
expect(klass.public_methods.sort).to eq(class_interface)
end
it "#{klass} should conform to BetweenMeals::Repo instance interface" do
expect(klass.instance_methods.sort).to eq(instance_interface)
end
end
4 changes: 4 additions & 0 deletions spec/svn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
require 'between_meals/repo/svn'
require 'between_meals/repo.rb'
require 'logger'
require_relative 'repo_subclass_conformance'

describe BetweenMeals::Repo::Svn do
context 'conforms to BetweenMeals::Repo interfaces' do
it_behaves_like 'Repo subclass conformance', BetweenMeals::Repo::Svn
end
let(:logger) do
Logger.new('/dev/null')
end
Expand Down
Loading