isbndb 1.5.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ describe ISBNdb::Result do
4
+ context 'initialize' do
5
+ it 'should set the @store instance variable' do
6
+ ISBNdb::Result.new.instance_variable_get('@store').should_not be_nil
7
+ end
8
+ end
9
+
10
+ context 'instance_methods' do
11
+ context 'when the hash uses symbols for keys' do
12
+ it 'should return an array of all methods' do
13
+ ISBNdb::Result.new({ :foo => 'bar', :zip => 'zap' }).instance_methods.should == ['foo', 'zip']
14
+ end
15
+ end
16
+
17
+ context 'when the hash is empty' do
18
+ it 'should return an empty array' do
19
+ ISBNdb::Result.new.instance_methods.should be_empty
20
+ end
21
+ end
22
+ end
23
+
24
+ context 'to_s' do
25
+ context 'with no instance_methods' do
26
+ it 'should return the correct string' do
27
+ ISBNdb::Result.new.to_s.should == '#<Result @num_singleton_methods=0>'
28
+ end
29
+ end
30
+
31
+ context 'with instance_methods' do
32
+ it 'should return the correct string' do
33
+ ISBNdb::Result.new({ :foo => 'bar', :zip => 'zap' }).to_s.should == '#<Result @num_singleton_methods=2>'
34
+ end
35
+ end
36
+ end
37
+
38
+ context 'inspect' do
39
+ context 'with no instance_methods' do
40
+ it 'should return the correct string' do
41
+ ISBNdb::Result.new.inspect.should == '#<Result >'
42
+ end
43
+ end
44
+
45
+ context 'with instance_methods' do
46
+ it 'should return the correct string' do
47
+ ISBNdb::Result.new({ :foo => 'bar', :zip => 'zap' }).inspect.should == '#<Result :foo => "bar", :zip => "zap">'
48
+ end
49
+ end
50
+ end
51
+
52
+ context 'build_result' do
53
+ before do
54
+ @result = ISBNdb::Result.new
55
+ end
56
+
57
+ context 'with cAmElCaSeD keys' do
58
+ it 'should covert them to underscored keys' do
59
+ @result.send(:build_result, { 'FooBar' => 'yep', 'ZipZap' => 'nope' }).should == { 'foo_bar' => 'yep', 'zip_zap' => 'nope' }
60
+ end
61
+ end
62
+
63
+ context 'with under_scored keys' do
64
+ it 'should not convert the keys' do
65
+ @result.send(:build_result, { 'foo_bar' => 'yep', 'zip_zap' => 'nope' }).should == { 'foo_bar' => 'yep', 'zip_zap' => 'nope' }
66
+ end
67
+ end
68
+
69
+ context 'with symbols for keys' do
70
+ it 'should convert the keys to strings' do
71
+ @result.send(:build_result, { :foo => 'bar', :zip => 'zap' }).should == { 'foo' => 'bar', 'zip' => 'zap' }
72
+ end
73
+ end
74
+
75
+ context 'with strings for keys' do
76
+ it 'not alter the keys' do
77
+ @result.send(:build_result, { 'foo' => 'bar', 'zip' => 'zap' }).should == { 'foo' => 'bar', 'zip' => 'zap' }
78
+ end
79
+ end
80
+
81
+ context 'with symbols as strings for keys' do
82
+ it 'should convert the keys to strings' do
83
+ @result.send(:build_result, { :'foo' => 'bar', :'zip' => 'zap' }).should == { 'foo' => 'bar', 'zip' => 'zap' }
84
+ end
85
+ end
86
+
87
+ context 'with an empty hash' do
88
+ it 'should return an empty hash' do
89
+ @result.send(:build_result, {}).should be_empty
90
+ end
91
+ end
92
+
93
+ context 'with a flat hash' do
94
+ it 'should return the correct hash' do
95
+ @result.send(:build_result, { :foo => 'bar', :zip => 'zap' }).should == { 'foo' => 'bar', 'zip' => 'zap' }
96
+ end
97
+ end
98
+
99
+ context 'with a nested hash' do
100
+ it 'should convert nested levels' do
101
+ @result.send(:build_result, { 'foo' => { :bar => 'zip', 'LeftRight' => 'blue', :'MonkeyPatch' => 'true' } }).should == { 'foo' => { 'bar' => 'zip', 'left_right' => 'blue', 'monkey_patch' => 'true' } }
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ describe String do
4
+ context 'is_plural?' do
5
+ it 'should return true if the string is plural' do
6
+ 'authors'.is_plural?.should be_true
7
+ 'books'.is_plural?.should be_true
8
+ 'subjects'.is_plural?.should be_true
9
+ 'categories'.is_plural?.should be_true
10
+ 'publishers'.is_plural?.should be_true
11
+ end
12
+
13
+ it 'should return false if the string is not plural' do
14
+ 'author'.is_plural?.should_not be_true
15
+ 'book'.is_plural?.should_not be_true
16
+ 'subject'.is_plural?.should_not be_true
17
+ 'category'.is_plural?.should_not be_true
18
+ 'publisher'.is_plural?.should_not be_true
19
+ end
20
+ end
21
+
22
+ context 'is_singular?' do
23
+ it 'should return true if the string is singular' do
24
+ 'author'.is_singular?.should be_true
25
+ 'book'.is_singular?.should be_true
26
+ 'subject'.is_singular?.should be_true
27
+ 'category'.is_singular?.should be_true
28
+ 'publisher'.is_singular?.should be_true
29
+ end
30
+
31
+ it 'should return false if the string is not singular' do
32
+ 'authors'.is_singular?.should_not be_true
33
+ 'books'.is_singular?.should_not be_true
34
+ 'subjects'.is_singular?.should_not be_true
35
+ 'categories'.is_singular?.should_not be_true
36
+ 'publishers'.is_singular?.should_not be_true
37
+ end
38
+ end
39
+
40
+ context 'titleize' do
41
+ it 'should capitalize the first letter' do
42
+ 'author'.titleize.should == 'Author'
43
+ 'book'.titleize.should == 'Book'
44
+ 'subject'.titleize.should == 'Subject'
45
+ 'category'.titleize.should == 'Category'
46
+ 'publisher'.titleize.should == 'Publisher'
47
+ end
48
+
49
+ it 'should do nothing if the letter is already capitalized' do
50
+ 'Author'.titleize.should == 'Author'
51
+ 'Book'.titleize.should == 'Book'
52
+ 'Subject'.titleize.should == 'Subject'
53
+ 'Category'.titleize.should == 'Category'
54
+ 'Publisher'.titleize.should == 'Publisher'
55
+ end
56
+ end
57
+
58
+ context 'singularize' do
59
+ it 'should return the singular form of a word' do
60
+ 'authors'.singularize.should == 'author'
61
+ 'books'.singularize.should == 'book'
62
+ 'subjects'.singularize.should == 'subject'
63
+ 'categories'.singularize.should == 'category'
64
+ 'publishers'.singularize.should == 'publisher'
65
+ end
66
+
67
+ it 'should not alter an already singular word' do
68
+ 'author'.singularize.should == 'author'
69
+ 'book'.singularize.should == 'book'
70
+ 'subject'.singularize.should == 'subject'
71
+ 'category'.singularize.should == 'category'
72
+ 'publisher'.singularize.should == 'publisher'
73
+ end
74
+ end
75
+
76
+ context 'pluralize' do
77
+ it 'should return the plural form of a word' do
78
+ 'author'.pluralize.should == 'authors'
79
+ 'book'.pluralize.should == 'books'
80
+ 'subject'.pluralize.should == 'subjects'
81
+ 'category'.pluralize.should == 'categories'
82
+ 'publisher'.pluralize.should == 'publishers'
83
+ end
84
+
85
+ it 'should not alter an already singular word' do
86
+ 'authors'.pluralize.should == 'authors'
87
+ 'books'.pluralize.should == 'books'
88
+ 'subjects'.pluralize.should == 'subjects'
89
+ 'categories'.pluralize.should == 'categories'
90
+ 'publishers'.pluralize.should == 'publishers'
91
+ end
92
+ end
93
+
94
+ context 'blank?' do
95
+ it 'should return true for the empty string' do
96
+ ''.blank?.should be_true
97
+ ' '.blank?.should be_true
98
+ end
99
+
100
+ it 'should not return true for non-empty strings' do
101
+ 'hello'.blank?.should_not be_true
102
+ end
103
+ end
104
+
105
+ context 'underscore' do
106
+ it 'should convert the camel cased word to underscores' do
107
+ 'HelloWorld'.underscore.should == 'hello_world'
108
+ 'Cookie'.underscore.should == 'cookie'
109
+ 'AReallyLongStringThatMightConfuseTheMethod'.underscore.should == 'a_really_long_string_that_might_confuse_the_method'
110
+ end
111
+
112
+ it 'should not change already underscored words' do
113
+ 'hello_world'.underscore.should == 'hello_world'
114
+ 'cookie'.underscore.should == 'cookie'
115
+ 'a_really_long_string_that_might_confuse_the_method'.underscore.should == 'a_really_long_string_that_might_confuse_the_method'
116
+ end
117
+ end
118
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isbndb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,138 +9,148 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-23 00:00:00.000000000Z
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activesupport
16
- requirement: &2154230480 !ruby/object:Gem::Requirement
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
21
+ version: 2.10.0
22
+ type: :development
23
23
  prerelease: false
24
- version_requirements: *2154230480
25
- - !ruby/object:Gem::Dependency
26
- name: i18n
27
- requirement: &2154229980 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
28
25
  none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - ~>
31
28
  - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *2154229980
29
+ version: 2.10.0
36
30
  - !ruby/object:Gem::Dependency
37
- name: rake
38
- requirement: &2154229200 !ruby/object:Gem::Requirement
31
+ name: shoulda
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
34
  requirements:
41
- - - ! '>='
35
+ - - ~>
42
36
  - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
37
+ version: 3.0.1
38
+ type: :development
45
39
  prerelease: false
46
- version_requirements: *2154229200
47
- - !ruby/object:Gem::Dependency
48
- name: rdoc
49
- requirement: &2154228380 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
50
41
  none: false
51
42
  requirements:
52
- - - ! '>='
43
+ - - ~>
53
44
  - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: *2154228380
45
+ version: 3.0.1
58
46
  - !ruby/object:Gem::Dependency
59
- name: libxml-ruby
60
- requirement: &2154227540 !ruby/object:Gem::Requirement
47
+ name: simplecov
48
+ requirement: !ruby/object:Gem::Requirement
61
49
  none: false
62
50
  requirements:
63
- - - ! '>='
51
+ - - ~>
64
52
  - !ruby/object:Gem::Version
65
- version: 1.1.4
66
- type: :runtime
53
+ version: 0.6.4
54
+ type: :development
67
55
  prerelease: false
68
- version_requirements: *2154227540
69
- - !ruby/object:Gem::Dependency
70
- name: shoulda
71
- requirement: &2154226720 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
72
57
  none: false
73
58
  requirements:
74
- - - ! '>='
59
+ - - ~>
75
60
  - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *2154226720
61
+ version: 0.6.4
80
62
  - !ruby/object:Gem::Dependency
81
- name: bundler
82
- requirement: &2154226020 !ruby/object:Gem::Requirement
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
83
65
  none: false
84
66
  requirements:
85
- - - ! '>='
67
+ - - ~>
86
68
  - !ruby/object:Gem::Version
87
- version: '0'
69
+ version: 1.8.7
88
70
  type: :development
89
71
  prerelease: false
90
- version_requirements: *2154226020
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.7
91
78
  - !ruby/object:Gem::Dependency
92
- name: jeweler
93
- requirement: &2154225440 !ruby/object:Gem::Requirement
79
+ name: httparty
80
+ requirement: !ruby/object:Gem::Requirement
94
81
  none: false
95
82
  requirements:
96
- - - ! '>='
83
+ - - ~>
97
84
  - !ruby/object:Gem::Version
98
- version: '0'
99
- type: :development
85
+ version: 0.8.3
86
+ type: :runtime
100
87
  prerelease: false
101
- version_requirements: *2154225440
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.8.3
102
94
  - !ruby/object:Gem::Dependency
103
- name: rcov
104
- requirement: &2154224760 !ruby/object:Gem::Requirement
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
105
97
  none: false
106
98
  requirements:
107
- - - ! '>='
99
+ - - ~>
108
100
  - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
101
+ version: 0.9.2.2
102
+ type: :runtime
111
103
  prerelease: false
112
- version_requirements: *2154224760
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.2.2
113
110
  description: Ruby ISBNdb is a amazingly fast and accurate gem that reads ISBNdb.com's
114
- XML API and gives you incredible flexibilty with the results! The gem uses libxml-ruby,
115
- the fastest XML parser for Ruby, so you get blazing fast results every time. Additionally,
116
- the newest version of the gem also features caching, so developers minimize API-key
117
- usage.
118
- email: seth.vargo@gmail.com
111
+ XML API and gives you incredible flexibilty with the results! The newest version
112
+ of the gem also features caching, so developers minimize API-key usage.
113
+ email: sethvargo@gmail.com
119
114
  executables: []
120
115
  extensions: []
121
- extra_rdoc_files:
122
- - LICENSE.txt
123
- - README.markdown
116
+ extra_rdoc_files: []
124
117
  files:
125
- - .document
126
- - ACKNOWLEDGEMENTS
118
+ - .gitignore
119
+ - .rspec
120
+ - .rvmrc
121
+ - .travis.yml
127
122
  - Gemfile
128
123
  - Gemfile.lock
129
- - LICENSE.txt
130
124
  - README.markdown
131
125
  - Rakefile
132
- - VERSION
126
+ - config/isbndb.example.yml
133
127
  - isbndb.gemspec
128
+ - lib/core_extensions/nil.rb
129
+ - lib/core_extensions/string.rb
134
130
  - lib/isbndb.rb
135
131
  - lib/isbndb/access_key_set.rb
136
132
  - lib/isbndb/exceptions.rb
133
+ - lib/isbndb/query.rb
137
134
  - lib/isbndb/result.rb
138
135
  - lib/isbndb/result_set.rb
139
- - test/helper.rb
140
- - test/test_isbndb.rb
136
+ - spec/responses/access_key_error.xml
137
+ - spec/responses/authors_seth.xml
138
+ - spec/responses/books_hello.xml
139
+ - spec/responses/categories_fiction.xml
140
+ - spec/responses/keystats.xml
141
+ - spec/responses/publishers_francis.xml
142
+ - spec/responses/search.xml
143
+ - spec/responses/subjects_ruby.xml
144
+ - spec/spec_helper.rb
145
+ - spec/support/helpers.rb
146
+ - spec/units/access_key_set_spec.rb
147
+ - spec/units/nil_spec.rb
148
+ - spec/units/query_spec.rb
149
+ - spec/units/result_set_spec.rb
150
+ - spec/units/result_spec.rb
151
+ - spec/units/string_spec.rb
141
152
  homepage: https://github.com/sethvargo/isbndb
142
- licenses:
143
- - MIT
153
+ licenses: []
144
154
  post_install_message:
145
155
  rdoc_options: []
146
156
  require_paths:
@@ -153,17 +163,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
163
  version: '0'
154
164
  segments:
155
165
  - 0
156
- hash: 3725550696331158843
166
+ hash: -215681729098382038
157
167
  required_rubygems_version: !ruby/object:Gem::Requirement
158
168
  none: false
159
169
  requirements:
160
170
  - - ! '>='
161
171
  - !ruby/object:Gem::Version
162
172
  version: '0'
173
+ segments:
174
+ - 0
175
+ hash: -215681729098382038
163
176
  requirements: []
164
177
  rubyforge_project:
165
- rubygems_version: 1.8.5
178
+ rubygems_version: 1.8.24
166
179
  signing_key:
167
180
  specification_version: 3
168
- summary: This gem provides an easy solution for connecting to ISBNdb.com's API
169
- test_files: []
181
+ summary: Connect with ISBNdb.com's API
182
+ test_files:
183
+ - spec/responses/access_key_error.xml
184
+ - spec/responses/authors_seth.xml
185
+ - spec/responses/books_hello.xml
186
+ - spec/responses/categories_fiction.xml
187
+ - spec/responses/keystats.xml
188
+ - spec/responses/publishers_francis.xml
189
+ - spec/responses/search.xml
190
+ - spec/responses/subjects_ruby.xml
191
+ - spec/spec_helper.rb
192
+ - spec/support/helpers.rb
193
+ - spec/units/access_key_set_spec.rb
194
+ - spec/units/nil_spec.rb
195
+ - spec/units/query_spec.rb
196
+ - spec/units/result_set_spec.rb
197
+ - spec/units/result_spec.rb
198
+ - spec/units/string_spec.rb