Skip to content

Commit

Permalink
test(current_example): add specs when gem is not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Olha-30 committed Dec 19, 2022
1 parent a98406c commit 2ed22d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

example_group "class methods" do
describe ".stubbed_results" do
context "when `Rspec.current_example` is nil" do
context "when RSpec current example is NOT set" do
before do
allow(ConvenientService::Support::Gems::RSpec).to receive(:current_example).and_return(nil)
end
Expand All @@ -43,7 +43,7 @@
end
end

context "when `Rspec.current_example` is present" do
context "when RSpec is loaded and current example is set" do
it "returns cache scoped by self" do
expect(service_class.stubbed_results).to eq(ConvenientService::Support::Cache.new.scope(service_class))
end
Expand Down
16 changes: 16 additions & 0 deletions spec/lib/convenient_service/support/gems/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
end
end
end

describe "current_example" do
it "returns current_example" do |example|
expect(described_class.current_example).to eq(example)
end

context "when `RSpec` is NOT loaded" do
before do
allow(described_class).to receive(:loaded?).and_return(false)
end

it "returns nil" do
expect(described_class.current_example).to be_nil
end
end
end
end
end
# rubocop:enable RSpec/NestedGroups

0 comments on commit 2ed22d2

Please sign in to comment.