Skip to content

Commit

Permalink
Add tests for Worker#files_to_example_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
agis committed Sep 21, 2020
1 parent 50d09c4 commit c89c87b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/sample_suites/files_to_examples/spec/bar_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RSpec.describe "baz" do
it { expect(1).to eq 2 }
end
15 changes: 15 additions & 0 deletions test/sample_suites/files_to_examples/spec/foo_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RSpec.describe "foo" do
it "works" do
expect(true).to be true
end

context "hmm" do
it "or not" do
expect(true).to be true
end

it "well, maybe" do
expect(true).to be true
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RSpec.describe "baz" do
it { expect(1).to eq 2 }
end
15 changes: 15 additions & 0 deletions test/sample_suites/files_to_examples_fallback/spec/foo_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
IdontExistz1337.describe "foo" do
it "works" do
expect(true).to be true
end

context "hmm" do
it "or not" do
expect(true).to be true
end

it "well, maybe" do
expect(true).to be true
end
end
end
41 changes: 41 additions & 0 deletions test/test_worker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require "test_helpers"

class TestWorker < RSpecQTest
def test_files_to_example_ids
worker = new_worker("files_to_examples")

expected = [
"./test/sample_suites/files_to_examples/spec/foo_spec.rb[1:1]",
"./test/sample_suites/files_to_examples/spec/foo_spec.rb[1:2:1]",
"./test/sample_suites/files_to_examples/spec/foo_spec.rb[1:2:2]",
"./test/sample_suites/files_to_examples/spec/bar_spec.rb[1:1]",
]

actual = worker.files_to_example_ids(
[
"./test/sample_suites/files_to_examples/spec/foo_spec.rb",
"./test/sample_suites/files_to_examples/spec/bar_spec.rb",
]
)

assert_equal expected, actual
end

def test_files_to_example_ids_failure_fallback
worker = new_worker("files_to_examples_fallback")

expected = [
"./test/sample_suites/files_to_examples_fallback/spec/foo_spec.rb",
"./test/sample_suites/files_to_examples_fallback/spec/bar_spec.rb"
]

actual = worker.files_to_example_ids(
[
"./test/sample_suites/files_to_examples_fallback/spec/foo_spec.rb",
"./test/sample_suites/files_to_examples_fallback/spec/bar_spec.rb",
]
)

assert_equal expected, actual
end
end

0 comments on commit c89c87b

Please sign in to comment.