Skip to content

Commit 1469313

Browse files
committed
Move tests into server_test.rb
1 parent 739fba6 commit 1469313

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

test/ruby_lsp_rails/runner_client_test.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class RunnerClientTest < ActiveSupport::TestCase
1616
assert_predicate @client, :stopped?
1717
end
1818

19+
# This is an integration test which starts the server. For the more fine-grained tests, see `server_test.rb`.
1920
test "#model returns information for the requested model" do
2021
# These columns are from the schema in the dummy app: test/dummy/db/schema.rb
2122
columns = [
@@ -30,18 +31,6 @@ class RunnerClientTest < ActiveSupport::TestCase
3031
assert_equal(columns, response.fetch(:columns))
3132
assert_match(%r{db/schema\.rb$}, response.fetch(:schema_file))
3233
end
33-
34-
test "returns nil if model doesn't exist" do
35-
assert_nil @client.model("Foo")
36-
end
37-
38-
test "returns nil if class is not a model" do
39-
assert_nil @client.model("Time")
40-
end
41-
42-
test "returns nil if class is an abstract model" do
43-
assert_nil @client.model("ApplicationRecord")
44-
end
4534
end
4635
end
4736
end

test/ruby_lsp_rails/server_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
require "ruby_lsp/ruby_lsp_rails/server"
66

77
class ServerTest < ActiveSupport::TestCase
8+
test "returns nil if model doesn't exist" do
9+
response = RubyLsp::Rails::Server.new.resolve_database_info_from_model("Foo")
10+
assert_nil(response.fetch(:result))
11+
end
12+
13+
test "returns nil if class is not a model" do
14+
response = RubyLsp::Rails::Server.new.resolve_database_info_from_model("Time")
15+
assert_nil(response.fetch(:result))
16+
end
17+
18+
test "returns nil if class is an abstract model" do
19+
response = RubyLsp::Rails::Server.new.resolve_database_info_from_model("ApplicationRecord")
20+
assert_nil(response.fetch(:result))
21+
end
822
test "handles older Rails version which don't have `schema_dump_path`" do
923
ActiveRecord::Tasks::DatabaseTasks.send(:alias_method, :old_schema_dump_path, :schema_dump_path)
1024
ActiveRecord::Tasks::DatabaseTasks.undef_method(:schema_dump_path)

0 commit comments

Comments
 (0)