ultron 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/Rakefile +0 -1
- data/lib/ultron/connection.rb +3 -3
- data/lib/ultron/entities.rb +23 -6
- data/lib/ultron/version.rb +1 -1
- data/spec/cassettes/exceptions/should_throw_a_No_Results_exception.yml +34 -0
- data/spec/cassettes/exceptions/should_throw_a_Not_Found_exception.yml +32 -0
- data/spec/cassettes/sample/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml +1673 -0
- data/spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic.yml +1810 -0
- data/spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml +312 -0
- data/spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_offset_into_the_result_set.yml +1673 -0
- data/spec/cassettes/shuffle/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml +1673 -0
- data/spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_character.yml +585 -0
- data/spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_comic.yml +3035 -0
- data/spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml +312 -0
- data/spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_member_of_the_result_set.yml +1673 -0
- data/spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_offset_into_the_result_set.yml +1673 -0
- data/spec/ultron/exceptions_spec.rb +32 -0
- data/spec/ultron/sample_spec.rb +38 -0
- data/spec/ultron/searches_spec.rb +0 -19
- metadata +29 -1
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ultron
|
4
|
+
describe 'exceptions' do
|
5
|
+
before :each do
|
6
|
+
Timecop.freeze '2014-02-13T18:47:24+00:00'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should throw a Not Found exception', :vcr do
|
10
|
+
begin
|
11
|
+
comic = Comics.find 1000000 # there are not a million comics
|
12
|
+
rescue NotFoundException => e
|
13
|
+
e.code.should == 404
|
14
|
+
e.status.should == "We couldn't find that comic_issue"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should throw a No Results exception', :vcr do
|
19
|
+
begin
|
20
|
+
comics = Comics.where offset: 1000000
|
21
|
+
rescue NoResultsException => e
|
22
|
+
e.status.should == 'That search returned no results'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should throw a No Idea What This Param Is exception'
|
27
|
+
|
28
|
+
after :each do
|
29
|
+
Timecop.return
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ultron
|
4
|
+
describe 'sample' do
|
5
|
+
before :each do
|
6
|
+
Timecop.freeze '2014-02-13T18:47:24+00:00'
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'let us pick a random item' do
|
10
|
+
it 'should get a count of items for a lookup', :vcr do
|
11
|
+
total = Comics.by_character(1009610).metadata.total # All comics featuring Spider-Man
|
12
|
+
total.should == 2576
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should give us a random offset into the result set', :vcr do
|
16
|
+
set = Comics.by_character 1009610
|
17
|
+
set.stub(:random_offset).and_return(233)
|
18
|
+
set.random_offset.should == 233
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should give us a random comic', :vcr do
|
22
|
+
set = Comics.by_character 1009610
|
23
|
+
set.stub(:random_offset).and_return(512)
|
24
|
+
set.sample.title.should == 'Amazing Spider-Man (1999) #590'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should give us a random comic for a more complex search', :vcr do
|
28
|
+
set = Comics.by_creator_and_with 214, dateRange: '1980-01-01,1989-12-31'
|
29
|
+
set.stub(:random_offset).and_return(99)
|
30
|
+
set.sample.title.should == 'Dazzler (1981) #19'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
after :each do
|
35
|
+
Timecop.return
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -41,25 +41,6 @@ module Ultron
|
|
41
41
|
comics.count.should == 50
|
42
42
|
end
|
43
43
|
|
44
|
-
it 'should throw a Not Found exception', :vcr do
|
45
|
-
begin
|
46
|
-
comic = Comics.find 1000000 # there are not a million comics
|
47
|
-
rescue NotFoundException => e
|
48
|
-
e.code.should == 404
|
49
|
-
e.status.should == "We couldn't find that comic_issue"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should throw a No Results exception', :vcr do
|
54
|
-
begin
|
55
|
-
comics = Comics.where offset: 1000000
|
56
|
-
rescue NoResultsException => e
|
57
|
-
e.status.should == 'That search returned no results'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should let us pick a random item'
|
62
|
-
|
63
44
|
after :each do
|
64
45
|
Timecop.return
|
65
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pikesley
|
@@ -293,6 +293,12 @@ files:
|
|
293
293
|
- spec/cassettes/Ultron_Series/should_give_a_default_set_of_series.yml
|
294
294
|
- spec/cassettes/Ultron_Series/should_let_us_reuse_the_connection_safely.yml
|
295
295
|
- spec/cassettes/Ultron_Series/should_let_us_search_with_parameters.yml
|
296
|
+
- spec/cassettes/exceptions/should_throw_a_No_Results_exception.yml
|
297
|
+
- spec/cassettes/exceptions/should_throw_a_Not_Found_exception.yml
|
298
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml
|
299
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic.yml
|
300
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml
|
301
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_offset_into_the_result_set.yml
|
296
302
|
- spec/cassettes/searching/should_accept_with_as_a_synonym_for_where.yml
|
297
303
|
- spec/cassettes/searching/should_handle_an_empty_response_gracefully.yml
|
298
304
|
- spec/cassettes/searching/should_indicate_Not_Found.yml
|
@@ -304,6 +310,12 @@ files:
|
|
304
310
|
- spec/cassettes/searching/should_let_us_search_with_parameters.yml
|
305
311
|
- spec/cassettes/searching/should_throw_a_No_Results_exception.yml
|
306
312
|
- spec/cassettes/searching/should_throw_a_Not_Found_exception.yml
|
313
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml
|
314
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_character.yml
|
315
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_comic.yml
|
316
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml
|
317
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_member_of_the_result_set.yml
|
318
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_offset_into_the_result_set.yml
|
307
319
|
- spec/spec_helper.rb
|
308
320
|
- spec/support/vcr_setup.rb
|
309
321
|
- spec/ultron/auth_spec.rb
|
@@ -312,6 +324,8 @@ files:
|
|
312
324
|
- spec/ultron/config_spec.rb
|
313
325
|
- spec/ultron/creators_spec.rb
|
314
326
|
- spec/ultron/events_spec.rb
|
327
|
+
- spec/ultron/exceptions_spec.rb
|
328
|
+
- spec/ultron/sample_spec.rb
|
315
329
|
- spec/ultron/searches_spec.rb
|
316
330
|
- spec/ultron/series_spec.rb
|
317
331
|
- spec/ultron/ultron_spec.rb
|
@@ -354,6 +368,12 @@ test_files:
|
|
354
368
|
- spec/cassettes/Ultron_Series/should_give_a_default_set_of_series.yml
|
355
369
|
- spec/cassettes/Ultron_Series/should_let_us_reuse_the_connection_safely.yml
|
356
370
|
- spec/cassettes/Ultron_Series/should_let_us_search_with_parameters.yml
|
371
|
+
- spec/cassettes/exceptions/should_throw_a_No_Results_exception.yml
|
372
|
+
- spec/cassettes/exceptions/should_throw_a_Not_Found_exception.yml
|
373
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml
|
374
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic.yml
|
375
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml
|
376
|
+
- spec/cassettes/sample/let_us_pick_a_random_item/should_give_us_a_random_offset_into_the_result_set.yml
|
357
377
|
- spec/cassettes/searching/should_accept_with_as_a_synonym_for_where.yml
|
358
378
|
- spec/cassettes/searching/should_handle_an_empty_response_gracefully.yml
|
359
379
|
- spec/cassettes/searching/should_indicate_Not_Found.yml
|
@@ -365,6 +385,12 @@ test_files:
|
|
365
385
|
- spec/cassettes/searching/should_let_us_search_with_parameters.yml
|
366
386
|
- spec/cassettes/searching/should_throw_a_No_Results_exception.yml
|
367
387
|
- spec/cassettes/searching/should_throw_a_Not_Found_exception.yml
|
388
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_get_a_count_of_items_for_a_lookup.yml
|
389
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_character.yml
|
390
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_comic.yml
|
391
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_comic_for_a_more_complex_search.yml
|
392
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_member_of_the_result_set.yml
|
393
|
+
- spec/cassettes/shuffle/let_us_pick_a_random_item/should_give_us_a_random_offset_into_the_result_set.yml
|
368
394
|
- spec/spec_helper.rb
|
369
395
|
- spec/support/vcr_setup.rb
|
370
396
|
- spec/ultron/auth_spec.rb
|
@@ -373,6 +399,8 @@ test_files:
|
|
373
399
|
- spec/ultron/config_spec.rb
|
374
400
|
- spec/ultron/creators_spec.rb
|
375
401
|
- spec/ultron/events_spec.rb
|
402
|
+
- spec/ultron/exceptions_spec.rb
|
403
|
+
- spec/ultron/sample_spec.rb
|
376
404
|
- spec/ultron/searches_spec.rb
|
377
405
|
- spec/ultron/series_spec.rb
|
378
406
|
- spec/ultron/ultron_spec.rb
|