|
81 | 81 | end |
82 | 82 | end |
83 | 83 |
|
| 84 | + # Tests capybara feature/scenario syntax |
| 85 | + # see https://github.com/teamcapybara/capybara |
| 86 | + it "discovers Capybara examples" do |
| 87 | + source = <<~RUBY |
| 88 | + feature "Sample test" do |
| 89 | + scenario "first test" do |
| 90 | + expect(true).to be(true) |
| 91 | + end |
| 92 | +
|
| 93 | + # Test a mixed syntax |
| 94 | + it "second test" do |
| 95 | + expect(true).to be(true) |
| 96 | + end |
| 97 | + end |
| 98 | +
|
| 99 | + RSpec.describe Foo do |
| 100 | + it "third test" do |
| 101 | + expect(true).to be(true) |
| 102 | + end |
| 103 | + end |
| 104 | + RUBY |
| 105 | + |
| 106 | + with_server(source, uri) do |server, uri| |
| 107 | + server.process_message( |
| 108 | + { |
| 109 | + id: 1, |
| 110 | + method: "rubyLsp/discoverTests", |
| 111 | + params: { |
| 112 | + textDocument: { uri: uri }, |
| 113 | + }, |
| 114 | + }, |
| 115 | + ) |
| 116 | + |
| 117 | + items = pop_result(server).response |
| 118 | + |
| 119 | + expect(items.length).to eq(2) |
| 120 | + |
| 121 | + first_group = items.first |
| 122 | + expect(first_group[:id]).to eq("./spec/fake_spec.rb:1") |
| 123 | + expect(first_group[:label]).to eq("Sample test") |
| 124 | + expect(first_group[:children].length).to eq(2) |
| 125 | + |
| 126 | + test_ids = first_group[:children].map { |i| i[:id] } |
| 127 | + expect(test_ids).to include("./spec/fake_spec.rb:1::./spec/fake_spec.rb:2") |
| 128 | + expect(test_ids).to include("./spec/fake_spec.rb:1::./spec/fake_spec.rb:6") |
| 129 | + |
| 130 | + test_labels = first_group[:children].map { |i| i[:label] } |
| 131 | + expect(test_labels).to include("first test") |
| 132 | + |
| 133 | + expect(test_labels).to include("second test") |
| 134 | + |
| 135 | + second_group = items[1] |
| 136 | + expect(second_group[:id]).to eq("./spec/fake_spec.rb:11") |
| 137 | + expect(second_group[:label]).to eq("Foo") |
| 138 | + expect(second_group[:children].length).to eq(1) |
| 139 | + |
| 140 | + test_ids = second_group[:children].map { |i| i[:id] } |
| 141 | + expect(test_ids).to include("./spec/fake_spec.rb:11::./spec/fake_spec.rb:12") |
| 142 | + end |
| 143 | + end |
| 144 | + |
84 | 145 | it "discovers nested example groups" do |
85 | 146 | source = <<~RUBY |
86 | 147 | RSpec.describe "Outer group" do |
|
0 commit comments