Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions test/kalshi/client_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require_relative '../helper'

describe Rubyists::Kalshi::Client do
let(:base_url) { Rubyists::Kalshi.config.base_url }

describe '#get' do
it 'raises Error on API error' do
stub_request(:get, "#{base_url}/error")
.to_return(status: 400, body: 'Bad Request')

client = Rubyists::Kalshi::Client.new
error = assert_raises(Rubyists::Kalshi::Error) do
client.get('error')
end
assert_match(/API Error: 400 - Bad Request/, error.message)
end
end
end

describe Rubyists::Kalshi do
describe '.client' do
it 'returns a client instance' do
assert_instance_of Rubyists::Kalshi::Client, Rubyists::Kalshi.client
end

it 'returns the same instance' do
assert_same Rubyists::Kalshi.client, Rubyists::Kalshi.client
end
end
end
18 changes: 18 additions & 0 deletions test/kalshi/contract_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require_relative '../helper'

describe Rubyists::Kalshi::Contract do
# rubocop:disable Lint/ConstantDefinitionInBlock
class TestContract < Rubyists::Kalshi::Contract
property :existing_prop
propertize :new_prop
end
# rubocop:enable Lint/ConstantDefinitionInBlock

it 'handles existing definitions' do
# This test just ensures the class definition above runs and exercises the code path
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test comment is redundant and states the obvious. Either remove the comment entirely or make it more informative by explaining why this edge case matters for coverage (e.g., "Ensures propertize handles properties that already exist via Reform's property method").

Suggested change
# This test just ensures the class definition above runs and exercises the code path
# Ensures propertize correctly adds properties on a class that already defines properties via property

Copilot uses AI. Check for mistakes.
assert_includes TestContract::Properties.members, :existing_prop
assert_includes TestContract::Properties.members, :new_prop
end
end
8 changes: 7 additions & 1 deletion test/kalshi/market/series_list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
assert_equal({ series: [] }, response)
end

it 'raises ArgumentError for invalid filters' do
it 'raises ArgumentError for invalid keys' do
assert_raises(ArgumentError) do
series_list.list(invalid_param: 'value')
end
end

it 'raises ArgumentError for invalid values' do
assert_raises(ArgumentError) do
series_list.list(status: 123)
end
end

it 'allows calling list on the class' do
stub_request(:get, "#{base_url}/series")
.to_return(status: 200, body: '{"series": []}', headers: { 'Content-Type' => 'application/json' })
Expand Down