Class: Fbe::Graph::Fake
- Inherits:
-
Object
- Object
- Fbe::Graph::Fake
- Defined in:
- lib/fbe/github_graph.rb
Overview
Fake GitHub GraphQL client for testing.
This class mocks the GraphQL client interface and returns predictable test data without making actual API calls. It’s used when the application is in testing mode.
Instance Method Summary collapse
-
#issue_type_event(node_id) ⇒ Hash?
Returns mock issue type event data.
-
#query(_query) ⇒ Hash
Executes a GraphQL query (mock implementation).
-
#resolved_conversations(owner, name, _number) ⇒ Array<Hash>
Returns mock resolved conversation threads.
-
#total_commits(_owner, _name, _branch) ⇒ Integer
Returns mock total commit count.
-
#total_issues_and_pulls(_owner, _name) ⇒ Hash
Returns mock issue and pull request counts.
Instance Method Details
#issue_type_event(node_id) ⇒ Hash?
Returns mock issue type event data.
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/fbe/github_graph.rb', line 343 def issue_type_event(node_id) case node_id when 'ITAE_examplevq862Ga8lzwAAAAQZanzv' { 'type' => 'IssueTypeAddedEvent', 'created_at' => Time.parse('2025-05-11 18:17:16 UTC'), 'issue_type' => { 'id' => 'IT_exampleQls4BmRE0', 'name' => 'Bug', 'description' => 'An unexpected problem or behavior' }, 'prev_issue_type' => nil, 'actor' => { 'login' => 'yegor256', 'type' => 'User', 'id' => 526_301, 'name' => 'Yegor', 'email' => '[email protected]' } } when 'ITCE_examplevq862Ga8lzwAAAAQZbq9S' { 'type' => 'IssueTypeChangedEvent', 'created_at' => Time.parse('2025-05-11 20:23:13 UTC'), 'issue_type' => { 'id' => 'IT_kwDODJdQls4BmREz', 'name' => 'Task', 'description' => 'A specific piece of work' }, 'prev_issue_type' => { 'id' => 'IT_kwDODJdQls4BmRE0', 'name' => 'Bug', 'description' => 'An unexpected problem or behavior' }, 'actor' => { 'login' => 'yegor256', 'type' => 'User', 'id' => 526_301, 'name' => 'Yegor', 'email' => '[email protected]' } } when 'ITRE_examplevq862Ga8lzwAAAAQcqceV' { 'type' => 'IssueTypeRemovedEvent', 'created_at' => Time.parse('2025-05-11 22:09:42 UTC'), 'issue_type' => { 'id' => 'IT_kwDODJdQls4BmRE1', 'name' => 'Feature', 'description' => 'A request, idea, or new functionality' }, 'prev_issue_type' => nil, 'actor' => { 'login' => 'yegor256', 'type' => 'User', 'id' => 526_301, 'name' => 'Yegor', 'email' => '[email protected]' } } end end |
#query(_query) ⇒ Hash
Executes a GraphQL query (mock implementation).
289 290 291 |
# File 'lib/fbe/github_graph.rb', line 289 def query(_query) {} end |
#resolved_conversations(owner, name, _number) ⇒ Array<Hash>
Returns mock resolved conversation threads.
302 303 304 305 306 307 308 309 |
# File 'lib/fbe/github_graph.rb', line 302 def resolved_conversations(owner, name, _number) data = { zerocracy_baza: [ conversation('PRRT_kwDOK2_4A85BHZAR') ] } data[:"#{owner}_#{name}"] || [] end |
#total_commits(_owner, _name, _branch) ⇒ Integer
Returns mock total commit count.
332 333 334 |
# File 'lib/fbe/github_graph.rb', line 332 def total_commits(_owner, _name, _branch) 1484 end |
#total_issues_and_pulls(_owner, _name) ⇒ Hash
Returns mock issue and pull request counts.
319 320 321 322 323 324 |
# File 'lib/fbe/github_graph.rb', line 319 def total_issues_and_pulls(_owner, _name) { 'issues' => 23, 'pulls' => 19 } end |