parse_resource 1.7.2 → 1.7.3

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.
Files changed (41) hide show
  1. data/.travis.yml +6 -0
  2. data/Gemfile +5 -1
  3. data/Gemfile.lock +11 -1
  4. data/README.md +21 -8
  5. data/VERSION +1 -1
  6. data/fixtures/vcr_cassettes/test_all.yml +161 -0
  7. data/fixtures/vcr_cassettes/test_attribute_getters.yml +57 -0
  8. data/fixtures/vcr_cassettes/test_attribute_setters.yml +57 -0
  9. data/fixtures/vcr_cassettes/test_authenticate.yml +155 -0
  10. data/fixtures/vcr_cassettes/test_chained_wheres.yml +161 -0
  11. data/fixtures/vcr_cassettes/test_count.yml +411 -0
  12. data/fixtures/vcr_cassettes/test_create.yml +57 -0
  13. data/fixtures/vcr_cassettes/test_created_at.yml +57 -0
  14. data/fixtures/vcr_cassettes/test_destroy.yml +157 -0
  15. data/fixtures/vcr_cassettes/test_destroy_all.yml +207 -0
  16. data/fixtures/vcr_cassettes/test_each.yml +269 -0
  17. data/fixtures/vcr_cassettes/test_find.yml +107 -0
  18. data/fixtures/vcr_cassettes/test_find_all_by.yml +157 -0
  19. data/fixtures/vcr_cassettes/test_find_by.yml +157 -0
  20. data/fixtures/vcr_cassettes/test_first.yml +107 -0
  21. data/fixtures/vcr_cassettes/test_id.yml +57 -0
  22. data/fixtures/vcr_cassettes/test_limit.yml +864 -0
  23. data/fixtures/vcr_cassettes/test_map.yml +269 -0
  24. data/fixtures/vcr_cassettes/test_save.yml +111 -0
  25. data/fixtures/vcr_cassettes/test_skip.yml +843 -0
  26. data/fixtures/vcr_cassettes/test_update.yml +111 -0
  27. data/fixtures/vcr_cassettes/test_updated_at.yml +111 -0
  28. data/fixtures/vcr_cassettes/test_username_should_be_unique.yml +109 -0
  29. data/fixtures/vcr_cassettes/test_where.yml +107 -0
  30. data/lib/parse_resource/base.rb +66 -69
  31. data/lib/parse_resource/parse_user.rb +1 -1
  32. data/lib/parse_resource/query.rb +9 -9
  33. data/parse_resource.gemspec +41 -7
  34. data/parse_resource.yml +12 -0
  35. data/test/active_model_lint_test.rb +5 -6
  36. data/test/helper.rb +8 -0
  37. data/test/test_parse_resource.rb +183 -117
  38. data/test/test_parse_user.rb +39 -32
  39. data/test/test_query_options.rb +43 -17
  40. metadata +149 -26
  41. data/test/test_associations.rb +0 -105
@@ -52,7 +52,7 @@ class ParseUser < ParseResource::Base
52
52
  resource = RestClient::Resource.new(base_uri, app_id, master_key)
53
53
 
54
54
  begin
55
- resp = resource.post(:email => email)
55
+ resp = resource.post({:email => email}.to_json, :content_type => 'application/json')
56
56
  true
57
57
  rescue
58
58
  false
@@ -23,18 +23,18 @@ class Query
23
23
  self
24
24
  end
25
25
 
26
- def order(attribute)
27
- attribute = attribute.to_sym if attribute.is_a?(String)
28
- criteria[:order] = attribute
29
- self
30
- end
31
-
32
- #TODO: make this work
33
- #def skip(skip)
34
- # criteria[:skip] = skip
26
+ # deprecating until it works
27
+ #def order(attribute)
28
+ # attribute = attribute.to_sym if attribute.is_a?(String)
29
+ # criteria[:order] = attribute
35
30
  # self
36
31
  #end
37
32
 
33
+ def skip(skip)
34
+ criteria[:skip] = skip
35
+ self
36
+ end
37
+
38
38
  def count(count=1)
39
39
  criteria[:count] = count
40
40
  #self
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "parse_resource"
8
- s.version = "1.7.2"
8
+ s.version = "1.7.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alan deLevie"]
12
- s.date = "2012-07-18"
12
+ s.date = "2012-09-20"
13
13
  s.description = ""
14
14
  s.email = "adelevie@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -18,12 +18,37 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ ".travis.yml",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
24
25
  "README.md",
25
26
  "Rakefile",
26
27
  "VERSION",
28
+ "fixtures/vcr_cassettes/test_all.yml",
29
+ "fixtures/vcr_cassettes/test_attribute_getters.yml",
30
+ "fixtures/vcr_cassettes/test_attribute_setters.yml",
31
+ "fixtures/vcr_cassettes/test_authenticate.yml",
32
+ "fixtures/vcr_cassettes/test_chained_wheres.yml",
33
+ "fixtures/vcr_cassettes/test_count.yml",
34
+ "fixtures/vcr_cassettes/test_create.yml",
35
+ "fixtures/vcr_cassettes/test_created_at.yml",
36
+ "fixtures/vcr_cassettes/test_destroy.yml",
37
+ "fixtures/vcr_cassettes/test_destroy_all.yml",
38
+ "fixtures/vcr_cassettes/test_each.yml",
39
+ "fixtures/vcr_cassettes/test_find.yml",
40
+ "fixtures/vcr_cassettes/test_find_all_by.yml",
41
+ "fixtures/vcr_cassettes/test_find_by.yml",
42
+ "fixtures/vcr_cassettes/test_first.yml",
43
+ "fixtures/vcr_cassettes/test_id.yml",
44
+ "fixtures/vcr_cassettes/test_limit.yml",
45
+ "fixtures/vcr_cassettes/test_map.yml",
46
+ "fixtures/vcr_cassettes/test_save.yml",
47
+ "fixtures/vcr_cassettes/test_skip.yml",
48
+ "fixtures/vcr_cassettes/test_update.yml",
49
+ "fixtures/vcr_cassettes/test_updated_at.yml",
50
+ "fixtures/vcr_cassettes/test_username_should_be_unique.yml",
51
+ "fixtures/vcr_cassettes/test_where.yml",
27
52
  "lib/.DS_Store",
28
53
  "lib/parse_resource.rb",
29
54
  "lib/parse_resource/base.rb",
@@ -33,6 +58,7 @@ Gem::Specification.new do |s|
33
58
  "lib/parse_resource/parse_user_validator.rb",
34
59
  "lib/parse_resource/query.rb",
35
60
  "parse_resource.gemspec",
61
+ "parse_resource.yml",
36
62
  "rdoc/ParseResource.html",
37
63
  "rdoc/created.rid",
38
64
  "rdoc/index.html",
@@ -40,7 +66,6 @@ Gem::Specification.new do |s|
40
66
  "rdoc/rdoc.css",
41
67
  "test/active_model_lint_test.rb",
42
68
  "test/helper.rb",
43
- "test/test_associations.rb",
44
69
  "test/test_parse_resource.rb",
45
70
  "test/test_parse_user.rb",
46
71
  "test/test_query.rb",
@@ -49,7 +74,7 @@ Gem::Specification.new do |s|
49
74
  s.homepage = "http://github.com/adelevie/parse_resource"
50
75
  s.licenses = ["MIT"]
51
76
  s.require_paths = ["lib"]
52
- s.rubygems_version = "1.8.10"
77
+ s.rubygems_version = "1.8.24"
53
78
  s.summary = "An ActiveResource-like wrapper for the Parse REST api."
54
79
 
55
80
  if s.respond_to? :specification_version then
@@ -59,36 +84,45 @@ Gem::Specification.new do |s|
59
84
  s.add_runtime_dependency(%q<rest-client>, [">= 0"])
60
85
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
61
86
  s.add_runtime_dependency(%q<activemodel>, [">= 0"])
62
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
87
+ s.add_runtime_dependency(%q<json>, [">= 0"])
88
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.5"])
63
89
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
64
90
  s.add_development_dependency(%q<rcov>, [">= 0"])
65
91
  s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
66
92
  s.add_development_dependency(%q<rest-client>, [">= 0"])
67
93
  s.add_development_dependency(%q<activesupport>, [">= 0"])
68
94
  s.add_development_dependency(%q<activemodel>, [">= 0"])
95
+ s.add_development_dependency(%q<vcr>, [">= 0"])
96
+ s.add_development_dependency(%q<webmock>, [">= 0"])
69
97
  else
70
98
  s.add_dependency(%q<rest-client>, [">= 0"])
71
99
  s.add_dependency(%q<activesupport>, [">= 0"])
72
100
  s.add_dependency(%q<activemodel>, [">= 0"])
73
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
101
+ s.add_dependency(%q<json>, [">= 0"])
102
+ s.add_dependency(%q<bundler>, ["~> 1.1.5"])
74
103
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
75
104
  s.add_dependency(%q<rcov>, [">= 0"])
76
105
  s.add_dependency(%q<reek>, ["~> 1.2.8"])
77
106
  s.add_dependency(%q<rest-client>, [">= 0"])
78
107
  s.add_dependency(%q<activesupport>, [">= 0"])
79
108
  s.add_dependency(%q<activemodel>, [">= 0"])
109
+ s.add_dependency(%q<vcr>, [">= 0"])
110
+ s.add_dependency(%q<webmock>, [">= 0"])
80
111
  end
81
112
  else
82
113
  s.add_dependency(%q<rest-client>, [">= 0"])
83
114
  s.add_dependency(%q<activesupport>, [">= 0"])
84
115
  s.add_dependency(%q<activemodel>, [">= 0"])
85
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
116
+ s.add_dependency(%q<json>, [">= 0"])
117
+ s.add_dependency(%q<bundler>, ["~> 1.1.5"])
86
118
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
87
119
  s.add_dependency(%q<rcov>, [">= 0"])
88
120
  s.add_dependency(%q<reek>, ["~> 1.2.8"])
89
121
  s.add_dependency(%q<rest-client>, [">= 0"])
90
122
  s.add_dependency(%q<activesupport>, [">= 0"])
91
123
  s.add_dependency(%q<activemodel>, [">= 0"])
124
+ s.add_dependency(%q<vcr>, [">= 0"])
125
+ s.add_dependency(%q<webmock>, [">= 0"])
92
126
  end
93
127
  end
94
128
 
@@ -0,0 +1,12 @@
1
+ development:
2
+ app_id: <%= ENV["PARSE_RESOURCE_APPLICATION_ID"] %>
3
+ master_key: <%= ENV["PARSE_RESOURCE_MASTER_KEY"] %>
4
+
5
+ test:
6
+ app_id: <%= ENV["PARSE_RESOURCE_APPLICATION_ID"] %>
7
+ master_key: <%= ENV["PARSE_RESOURCE_MASTER_KEY"] %>
8
+
9
+
10
+ production:
11
+ app_id: <%= ENV["PARSE_RESOURCE_APPLICATION_ID"] %>
12
+ master_key: <%= ENV["PARSE_RESOURCE_MASTER_KEY"] %>
@@ -1,12 +1,11 @@
1
1
  require 'helper'
2
2
  require 'parse_resource'
3
3
 
4
- path = "parse_resource.yml"
5
- settings = YAML.load(ERB.new(File.new(path).read).result)['test']
4
+ #path = "parse_resource.yml"
5
+ #settings = YAML.load(ERB.new(File.new(path).read).result)['test']
6
+ ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
6
7
 
7
- ParseResource.load!(settings['app_id'], settings['master_key'])
8
-
9
- class Post < ParseResource
8
+ class Bowl < ParseResource
10
9
  fields :title, :body, :author
11
10
  validates_presence_of :title
12
11
  end
@@ -14,6 +13,6 @@ class ActiveModelLintTest < ActiveModel::TestCase
14
13
  include ActiveModel::Lint::Tests
15
14
 
16
15
  def setup
17
- @model = Post.new
16
+ @model = Bowl.new
18
17
  end
19
18
  end
@@ -8,6 +8,14 @@ rescue Bundler::BundlerError => e
8
8
  exit e.status_code
9
9
  end
10
10
  require 'test/unit'
11
+ require 'vcr'
12
+ require 'webmock/test_unit'
13
+
14
+ VCR.configure do |c|
15
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
16
+ c.hook_into :webmock # or :fakeweb
17
+ c.allow_http_connections_when_no_cassette = true
18
+ end
11
19
 
12
20
  #$LOAD_PATH.unshift(File.dirname(__FILE__))
13
21
  #$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -1,10 +1,11 @@
1
1
  require 'helper'
2
2
  require 'parse_resource'
3
3
 
4
- path = "parse_resource.yml"
5
- settings = YAML.load(ERB.new(File.new(path).read).result)['test']
4
+ #path = "parse_resource.yml"
5
+ #settings = YAML.load(ERB.new(File.new(path).read).result)['test']
6
+ #ParseResource::Base.load!(settings['app_id'], settings['master_key'])
6
7
 
7
- ParseResource::Base.load!(settings['app_id'], settings['master_key'])
8
+ ParseResource::Base.load!(ENV["PARSE_RESOURCE_APPLICATION_ID"], ENV["PARSE_RESOURCE_MASTER_KEY"])
8
9
 
9
10
  class Post < ParseResource::Base
10
11
  fields :title, :body, :author
@@ -12,113 +13,156 @@ class Post < ParseResource::Base
12
13
  end
13
14
 
14
15
  class Author < ParseResource::Base
15
- has_many :posts
16
16
  field :name
17
17
  end
18
18
 
19
+ class Spoon < ParseResource::Base
20
+ fields :width, :length
21
+ end
22
+
23
+ class Fork < ParseResource::Base
24
+ fields :points
25
+ end
26
+
27
+ class Knife < ParseResource::Base
28
+ fields :is_shiny
29
+ end
30
+
31
+ class Straw < ParseResource::Base
32
+ fields :title, :body
33
+ end
34
+
19
35
  class TestParseResource < Test::Unit::TestCase
20
36
 
21
- def setup
22
- Post.destroy_all
23
- Author.destroy_all
24
- end
37
+ #def setup
38
+ # Post.destroy_all
39
+ # Author.destroy_all
40
+ # Spoon.destroy_all
41
+ # Fork.destroy_all
42
+ # Straw.destroy_all
43
+ #end
25
44
 
26
- def teardown
27
- Post.destroy_all
28
- Author.destroy_all
29
- end
45
+ #def teardown
46
+ # Post.destroy_all
47
+ # Author.destroy_all
48
+ # Spoon.destroy_all
49
+ # Fork.destroy_all
50
+ # Straw.destroy_all
51
+ #end
30
52
 
31
53
  def test_initialize_without_args
32
54
  assert Post.new.is_a?(Post)
33
55
  end
34
56
 
35
57
  def test_count
36
- Author.destroy_all
37
- p1 = Author.create(:name => "bar")
38
- p2 = Author.create(:name => "jab")
39
- assert_equal Author.count, 2
40
- assert_equal Author.where(:name => "jab").count, 1
41
- p1.destroy
42
- p2.destroy
43
- assert_equal Author.count, 0
58
+ VCR.use_cassette('test_count', :record => :new_episodes) do
59
+ Author.destroy_all
60
+ p1 = Author.create(:name => "bar")
61
+ p2 = Author.create(:name => "jab")
62
+ assert_equal Author.count, 2
63
+ assert_equal Author.where(:name => "jab").count, 1
64
+ p1.destroy
65
+ p2.destroy
66
+ assert_equal Author.count, 0
67
+ end
44
68
  end
45
69
 
46
70
  def test_initialize_with_args
47
- @post = Post.new(:title => "title1", :body => "ipso")
48
- assert @post.is_a?(Post)
49
- assert_equal @post.title, "title1"
50
- assert_equal @post.body, "ipso"
71
+ @spoon = Spoon.new(:length => "title1", :width => "ipso")
72
+ assert @spoon.is_a?(Spoon)
73
+ assert_equal @spoon.length, "title1"
74
+ assert_equal @spoon.width, "ipso"
51
75
  end
52
76
 
53
77
  def test_create
54
- p = Post.create(:title => "1234567890created!")
55
- assert p.is_a?(Post)
56
- @find_id = p.id
57
- assert p.id
58
- assert p.created_at
78
+ VCR.use_cassette('test_create', :record => :new_episodes) do
79
+ s = Spoon.create(:length => "1234567890created!")
80
+ assert s.is_a?(Spoon)
81
+ assert s.id
82
+ assert s.created_at
83
+ end
59
84
  end
60
85
 
61
86
  def test_find
62
- p1 = Post.create(:title => "Welcome")
63
- p2 = Post.find(p1.id)
64
- assert_equal p2.id, p2.id
87
+ VCR.use_cassette('test_find', :record => :new_episodes) do
88
+ p1 = Spoon.create(:length => "Welcome")
89
+ p2 = Spoon.find(p1.id)
90
+ assert_equal p2.id, p2.id
91
+ end
65
92
  end
66
93
 
67
94
  def test_find_should_throw_an_exception_if_object_is_nil
68
- assert_raise RecordNotFound do
69
- Post.find("")
70
- end
95
+ VCR.use_cassette('test_find_should_throw_an_exception_if_object_is_nil', :record => :new_episodes) do
96
+ assert_raise RecordNotFound do
97
+ Post.find("")
98
+ end
99
+ end
71
100
  end
72
101
 
73
102
  def test_first
74
- Post.create(:title => "firsttt")
75
- p = Post.first
76
- assert p.is_a?(Post)
103
+ VCR.use_cassette('test_first', :record => :new_episodes) do
104
+ f = Fork.create(:points => "firsttt")
105
+ p = Fork.first
106
+ assert p.is_a?(Fork)
107
+ assert f.id, p.id
108
+ assert f.points, p.points
109
+ end
77
110
  end
78
111
 
79
112
  def test_find_by
80
- p1 = Post.create(:title => "Welcome111")
81
- where = Post.where(:title => "Welcome111").first
82
- find = Post.find_by_title("Welcome111")
83
- assert_equal where.id, find.id
113
+ VCR.use_cassette('test_find_by', :record => :new_episodes) do
114
+ p1 = Post.create(:title => "Welcome111")
115
+ where = Post.where(:title => "Welcome111").first
116
+ find = Post.find_by_title("Welcome111")
117
+ assert_equal where.id, find.id
118
+ end
84
119
  end
85
120
 
86
121
  def test_find_all_by
87
- p1 = Post.create(:title => "Welcome111")
88
- where = Post.where(:title => "Welcome111").all
89
- find = Post.find_all_by_title("Welcome111")
90
- assert_equal where.first.id, find.first.id
91
- assert_equal find.class, Array
122
+ VCR.use_cassette('test_find_all_by', :record => :new_episodes) do
123
+ p1 = Post.create(:title => "Welcome111")
124
+ where = Post.where(:title => "Welcome111").all
125
+ find = Post.find_all_by_title("Welcome111")
126
+ assert_equal where.first.id, find.first.id
127
+ assert_equal find.class, Array
128
+ end
92
129
  end
93
130
 
94
131
  def test_where
95
- p1 = Post.create(:title => "Welcome111")
96
- p2 = Post.where(:title => "Welcome111").first
97
- assert_equal p2.id, p1.id
132
+ VCR.use_cassette('test_where', :record => :new_episodes) do
133
+ p1 = Post.create(:title => "Welcome111")
134
+ p2 = Post.where(:title => "Welcome111").first
135
+ assert_equal p2.title, p1.title
136
+ end
98
137
  end
99
138
 
100
139
  def test_destroy_all
101
- p = Post.create(:title => "arbitrary")
102
- Post.destroy_all
103
- assert_equal Post.count, 0
140
+ VCR.use_cassette('test_destroy_all', :record => :new_episodes) do
141
+ p = Knife.create(:is_shiny => "arbitrary")
142
+ Knife.destroy_all
143
+ assert_equal Knife.count, 0
144
+ end
104
145
  end
105
146
 
106
147
  def test_chained_wheres
107
- Post.destroy_all
108
- p1 = Post.create(:title => "chained_wheres", :body => "testing")
109
- p2 = Post.create(:title => "chained_wheres", :body => "testing_2")
110
- query = Post.where(:title => "chained_wheres").where(:body => "testing")
111
- p3 = query.first
112
-
113
- assert_equal p3.id, p1.id
148
+ VCR.use_cassette('test_chained_wheres', :record => :new_episodes) do
149
+ p1 = Straw.create(:title => "chained_wheres", :body => "testing")
150
+ p2 = Straw.create(:title => "chained_wheres", :body => "testing_2")
151
+ query = Straw.where(:title => "chained_wheres").where(:body => "testing")
152
+ p3 = query.first
153
+
154
+ assert_equal p3.id, p1.id
155
+ end
114
156
  end
115
157
 
116
158
  def test_limit
117
- 15.times do |i|
118
- Post.create(:title => "foo_"+i.to_s)
159
+ VCR.use_cassette('test_limit', :record => :new_episodes) do
160
+ 15.times do |i|
161
+ Post.create(:title => "foo_"+i.to_s)
162
+ end
163
+ posts = Post.limit(5).all
164
+ assert_equal posts.length, 5
119
165
  end
120
- posts = Post.limit(5).all
121
- assert_equal posts.length, 5
122
166
  end
123
167
 
124
168
  #def test_skip
@@ -130,91 +174,113 @@ class TestParseResource < Test::Unit::TestCase
130
174
  #end
131
175
 
132
176
  def test_all
133
- Post.create(:title => "11222")
134
- Post.create(:title => "112ssd22")
135
- posts = Post.all
136
- assert posts.is_a?(Array)
137
- assert posts[0].is_a?(Post)
177
+ VCR.use_cassette('test_all', :record => :new_episodes) do
178
+ Post.create(:title => "11222")
179
+ Post.create(:title => "112ssd22")
180
+ posts = Post.all
181
+ assert posts.is_a?(Array)
182
+ assert posts[0].is_a?(Post)
183
+ end
138
184
  end
139
185
 
140
186
  def test_attribute_getters
141
- @post = Post.create(:title => "title1")
142
- assert_equal @post.attributes['title'], "title1"
143
- assert_equal @post.attributes['title'], @post.title
187
+ VCR.use_cassette('test_attribute_getters', :record => :new_episodes) do
188
+ @post = Post.create(:title => "title1")
189
+ assert_equal @post.attributes['title'], "title1"
190
+ assert_equal @post.attributes['title'], @post.title
191
+ end
144
192
  end
145
193
 
146
194
  def test_attribute_setters
147
- @post = Post.create(:title => "1")
148
- @post.body = "newerbody"
149
- assert_equal @post.body, "newerbody"
195
+ VCR.use_cassette('test_attribute_setters', :record => :new_episodes) do
196
+ @post = Post.create(:title => "1")
197
+ @post.body = "newerbody"
198
+ assert_equal @post.body, "newerbody"
199
+ end
150
200
  end
151
201
 
152
202
  def test_save
153
- @post = Post.create(:title => "testing save")
154
- @post.save
155
- assert @post.attributes['objectId']
156
- assert @post.attributes['updatedAt']
157
- assert @post.attributes['createdAt']
203
+ VCR.use_cassette('test_save', :record => :new_episodes) do
204
+ @post = Post.create(:title => "testing save")
205
+ @post.save
206
+ assert @post.attributes['objectId']
207
+ assert @post.attributes['updatedAt']
208
+ assert @post.attributes['createdAt']
209
+ end
158
210
  end
159
211
 
160
212
  def test_each
161
- Post.destroy_all
162
- 4.times do |i|
163
- #Post.create(:title => "each", :author => i.to_s)
164
- Post.create(:title => "each")
165
- end
166
- posts = Post.where(:title => "each")
167
- posts.each do |p|
168
- assert_equal p.title, "each"
213
+ VCR.use_cassette('test_each', :record => :new_episodes) do
214
+ #Post.destroy_all
215
+ 4.times do |i|
216
+ #Post.create(:title => "each", :author => i.to_s)
217
+ Post.create(:title => "each")
218
+ end
219
+ posts = Post.where(:title => "each")
220
+ posts.each do |p|
221
+ assert_equal p.title, "each"
222
+ end
169
223
  end
170
224
  end
171
225
 
172
226
  def test_map
173
- Post.destroy_all
174
- 4.times do |i|
175
- Post.create(:title => "map")
227
+ VCR.use_cassette('test_map', :record => :new_episodes) do
228
+ #Post.destroy_all
229
+ 4.times do |i|
230
+ Post.create(:title => "map")
231
+ end
232
+ posts = Post.where(:title => "map")
233
+ assert_equal posts.map {|p| p}.class, Array
176
234
  end
177
- posts = Post.where(:title => "map")
178
- assert_equal posts.map {|p| p}.class, Array
179
235
  end
180
236
 
181
237
  def test_id
182
- @post = Post.create(:title => "testing id")
183
- assert @post.respond_to?(:id)
184
- assert @post.id
185
- assert @post.attributes['objectId'] = @post.id
238
+ VCR.use_cassette('test_id', :record => :new_episodes) do
239
+ @post = Post.create(:title => "testing id")
240
+ assert @post.respond_to?(:id)
241
+ assert @post.id
242
+ assert @post.attributes['objectId'] = @post.id
243
+ end
186
244
  end
187
245
 
188
246
  def test_created_at
189
- @post = Post.create(:title => "testing created_at")
190
- assert @post.respond_to?(:created_at)
191
- assert @post.created_at
192
- assert @post.attributes['createdAt']
247
+ VCR.use_cassette('test_created_at', :record => :new_episodes) do
248
+ @post = Post.create(:title => "testing created_at")
249
+ assert @post.respond_to?(:created_at)
250
+ assert @post.created_at
251
+ assert @post.attributes['createdAt']
252
+ end
193
253
  end
194
254
 
195
255
  def test_updated_at
196
- @post = Post.create(:title => "testing updated_at")
197
- @post.title = "something else"
198
- @post.save
199
- assert @post.updated_at
256
+ VCR.use_cassette('test_updated_at', :record => :new_episodes) do
257
+ @post = Post.create(:title => "testing updated_at")
258
+ @post.title = "something else"
259
+ @post.save
260
+ assert @post.updated_at
261
+ end
200
262
  end
201
263
 
202
264
  def test_update
203
- @post = Post.create(:title => "stale title")
204
- updated_once = @post.updated_at
205
- @post.update(:title => "updated title")
206
- assert_equal @post.title, "updated title"
207
- @post.title = "updated from setter"
208
- assert_equal @post.title, "updated from setter"
209
- assert_not_equal @post.updated_at, updated_once
265
+ VCR.use_cassette('test_update', :record => :new_episodes) do
266
+ @post = Post.create(:title => "stale title")
267
+ updated_once = @post.updated_at
268
+ @post.update(:title => "updated title")
269
+ assert_equal @post.title, "updated title"
270
+ @post.title = "updated from setter"
271
+ assert_equal @post.title, "updated from setter"
272
+ assert_not_equal @post.updated_at, updated_once
273
+ end
210
274
  end
211
275
 
212
276
  def test_destroy
213
- p = Post.create(:title => "hello1234567890abc!")
214
- id = p.id
215
- p.destroy
216
- assert_equal p.title, nil
217
- assert_equal 0, Post.where(:title => "hello1234567890abc!", :objectId => id).length
277
+ VCR.use_cassette('test_destroy', :record => :new_episodes) do
278
+ p = Post.create(:title => "hello1234567890abc!")
279
+ id = p.id
280
+ p.destroy
281
+ assert_equal p.title, nil
282
+ assert_equal 0, Post.where(:title => "hello1234567890abc!", :objectId => id).length
283
+ end
218
284
  end
219
285
 
220
286
  def test_validation