From b9bf09a4ea959f8d37dabddc68fa50ea32979dda Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Sun, 20 Sep 2020 22:50:11 +0300 Subject: [PATCH] Add tests for Worker#files_to_example_ids --- .../files_to_examples/spec/bar_spec.rb | 3 ++ .../files_to_examples/spec/foo_spec.rb | 15 +++++++ .../spec/bar_spec.rb | 3 ++ .../spec/foo_spec.rb | 15 +++++++ test/test_worker.rb | 41 +++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 test/sample_suites/files_to_examples/spec/bar_spec.rb create mode 100644 test/sample_suites/files_to_examples/spec/foo_spec.rb create mode 100644 test/sample_suites/files_to_examples_fallback/spec/bar_spec.rb create mode 100644 test/sample_suites/files_to_examples_fallback/spec/foo_spec.rb create mode 100644 test/test_worker.rb diff --git a/test/sample_suites/files_to_examples/spec/bar_spec.rb b/test/sample_suites/files_to_examples/spec/bar_spec.rb new file mode 100644 index 0000000..b9e2e51 --- /dev/null +++ b/test/sample_suites/files_to_examples/spec/bar_spec.rb @@ -0,0 +1,3 @@ +RSpec.describe "baz" do + it { expect(1).to eq 2 } +end diff --git a/test/sample_suites/files_to_examples/spec/foo_spec.rb b/test/sample_suites/files_to_examples/spec/foo_spec.rb new file mode 100644 index 0000000..6c408b9 --- /dev/null +++ b/test/sample_suites/files_to_examples/spec/foo_spec.rb @@ -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 diff --git a/test/sample_suites/files_to_examples_fallback/spec/bar_spec.rb b/test/sample_suites/files_to_examples_fallback/spec/bar_spec.rb new file mode 100644 index 0000000..b9e2e51 --- /dev/null +++ b/test/sample_suites/files_to_examples_fallback/spec/bar_spec.rb @@ -0,0 +1,3 @@ +RSpec.describe "baz" do + it { expect(1).to eq 2 } +end diff --git a/test/sample_suites/files_to_examples_fallback/spec/foo_spec.rb b/test/sample_suites/files_to_examples_fallback/spec/foo_spec.rb new file mode 100644 index 0000000..b85d64b --- /dev/null +++ b/test/sample_suites/files_to_examples_fallback/spec/foo_spec.rb @@ -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 diff --git a/test/test_worker.rb b/test/test_worker.rb new file mode 100644 index 0000000..146fc82 --- /dev/null +++ b/test/test_worker.rb @@ -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