datacatalog 0.4.15 → 0.4.16

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.
data/spec/comment_spec.rb CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
  include DataCatalog
3
3
 
4
4
  describe Comment do
5
-
5
+
6
6
  before do
7
7
  setup_api
8
8
  clean_slate
@@ -14,14 +14,14 @@ describe Comment do
14
14
  :url => "http://fcc.gov/somedata.csv",
15
15
  :source_type => "dataset")
16
16
  end
17
-
17
+
18
18
  describe ".create" do
19
19
  it "should create a new comment when valid params are passed in" do
20
20
  DataCatalog.with_key(@user.primary_api_key) do
21
21
  @comment = Comment.create(:source_id => @source.id, :text => "The first comment.")
22
22
  end
23
23
  @comment.should be_an_instance_of(Comment)
24
-
24
+
25
25
  refreshed_source = Source.get(@source.id)
26
26
  refreshed_source.comments.first.text.should == "The first comment."
27
27
  refreshed_source.comments.first.user.name.should == "Ted Smith"
@@ -40,7 +40,7 @@ describe Comment do
40
40
  comment.should be_an_instance_of(Comment)
41
41
  comment.text.should == "The first comment."
42
42
  end
43
-
43
+
44
44
  it "should raise NotFound if no comment exists" do
45
45
  executing do
46
46
  Comment.get(mangle(@comment.id))
@@ -78,12 +78,12 @@ describe Comment do
78
78
  @comment = Comment.create(:source_id => @source.id, :text => "The first comment.")
79
79
  end
80
80
  end
81
-
81
+
82
82
  it "should update an existing comment with valid params" do
83
83
  DataCatalog.with_key(@user.primary_api_key) do
84
84
  Comment.update(@comment.id, :text => "The first comment, updated.")
85
85
  end
86
-
86
+
87
87
  refreshed_source = Source.get(@source.id)
88
88
  refreshed_source.comments.first.text.should == "The first comment, updated."
89
89
  refreshed_source.comments.first.user.name.should == "Ted Smith"
@@ -96,17 +96,17 @@ describe Comment do
96
96
  @comment = Comment.create(:source_id => @source.id, :text => "The first comment.")
97
97
  end
98
98
  end
99
-
99
+
100
100
  it "should destroy an existing comment as an admin" do
101
101
  Comment.destroy(@comment.id).should be_true
102
102
  end
103
-
103
+
104
104
  it "should destroy an existing comment as the user" do
105
105
  DataCatalog.with_key(@user.primary_api_key) do
106
106
  Comment.destroy(@comment.id).should be_true
107
107
  end
108
108
  end
109
-
109
+
110
110
  it "should raise NotFound when attempting to destroy non-existing comment" do
111
111
  executing do
112
112
  Comment.destroy(mangle(@comment.id))
@@ -25,13 +25,13 @@ describe DataCatalog do
25
25
  end
26
26
  DataCatalog.api_key.should == regular_key
27
27
  end
28
-
28
+
29
29
  it "should return the last value in the block" do
30
30
  DataCatalog.with_key("0000444400004444") do
31
31
  42
32
32
  end.should == 42
33
33
  end
34
-
34
+
35
35
  it "should still reset the API key when the block throws an exception" do
36
36
  regular_key = '4159179f32ff8fefd2c6d48b7e675e7736bf1357'
37
37
  DataCatalog.api_key = regular_key
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
  include DataCatalog
3
3
 
4
4
  describe Document do
5
-
5
+
6
6
  before do
7
7
  setup_api
8
8
  clean_slate
@@ -22,7 +22,7 @@ describe Document do
22
22
  )
23
23
  end
24
24
  end
25
-
25
+
26
26
  describe ".create" do
27
27
 
28
28
  it "should create a document when valid params are passed in" do
@@ -31,49 +31,49 @@ describe Document do
31
31
  refreshed_source.documents.first.text.should == "This is community documentation."
32
32
  end
33
33
  end
34
-
34
+
35
35
  end # describe ".create"
36
-
36
+
37
37
  describe ".get" do
38
-
38
+
39
39
  it "should return a document" do
40
40
  document = Document.get(@document.id)
41
41
  document.should be_an_instance_of(Document)
42
42
  document.source_id.should == @source.id
43
43
  end
44
-
44
+
45
45
  it "should raise NotFound if no document exists" do
46
46
  executing do
47
47
  Document.get(mangle(@document.id))
48
48
  end.should raise_error(NotFound)
49
49
  end
50
-
50
+
51
51
  end # describe ".get"
52
-
52
+
53
53
  describe ".all" do
54
-
54
+
55
55
  it "should return an enumeration of documents" do
56
56
  documents = Document.all(:source_id => @source.id)
57
57
  documents.each do |o|
58
58
  o.should be_an_instance_of(Document)
59
59
  end
60
60
  end
61
-
61
+
62
62
  end # describe ".all"
63
-
63
+
64
64
  describe ".update" do
65
-
65
+
66
66
  it "should update an existing document with valid params" do
67
67
  @document.previous_id.should be nil
68
68
  DataCatalog.with_key(@user.primary_api_key) do
69
69
  Document.update(@document.id, :text => "This is the updated document.")
70
70
  end
71
-
71
+
72
72
  refreshed_document = Document.get(@document.id)
73
73
  refreshed_document.text.should == "This is the updated document."
74
74
  refreshed_document.previous_id.should_not be nil
75
75
  end
76
-
76
+
77
77
  end # describe ".update"
78
78
 
79
79
  describe ".destroy" do
@@ -81,19 +81,19 @@ describe Document do
81
81
  it "should destroy an existing document as an admin" do
82
82
  Document.destroy(@document.id).should be_true
83
83
  end
84
-
84
+
85
85
  it "should not destroy an existing document as the user" do
86
86
  DataCatalog.with_key(@user.primary_api_key) do
87
87
  executing { Document.destroy(@document.id) }.should raise_error(Unauthorized)
88
88
  end
89
89
  end
90
-
90
+
91
91
  it "should raise NotFound when attempting to destroy non-existing document" do
92
92
  executing do
93
93
  Document.destroy(mangle(@document.id))
94
94
  end.should raise_error(NotFound)
95
95
  end
96
-
96
+
97
97
  end # describe ".destroy"
98
-
98
+
99
99
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
  include DataCatalog
3
3
 
4
4
  describe Download do
5
-
5
+
6
6
  before do
7
7
  setup_api
8
8
  clean_slate
@@ -17,33 +17,33 @@ describe Download do
17
17
  )
18
18
  @download = Download.create(
19
19
  :source_id => @source.id,
20
- :format => "CSV",
20
+ :format => "CSV",
21
21
  :url => "http://somedata.gov/test.csv",
22
22
  :preview => "1,2,3,4,5"
23
23
  )
24
24
  end
25
-
25
+
26
26
  describe ".create" do
27
27
  it "should create a download when valid params are passed in" do
28
28
  refreshed_source = Source.get(@source.id)
29
29
  refreshed_source.downloads.first.url.should == "http://somedata.gov/test.csv"
30
30
  end
31
31
  end
32
-
32
+
33
33
  describe ".get" do
34
34
  it "should return a download" do
35
35
  download = Download.get(@download.id)
36
36
  download.should be_an_instance_of(Download)
37
37
  download.source_id.should == @source.id
38
38
  end
39
-
39
+
40
40
  it "should raise NotFound if no download exists" do
41
41
  executing do
42
42
  Download.get(mangle(@download.id))
43
43
  end.should raise_error(NotFound)
44
44
  end
45
45
  end
46
-
46
+
47
47
  describe ".all" do
48
48
  it "should return an enumeration of downloads" do
49
49
  downloads = Download.all(:source_id => @source.id)
@@ -52,10 +52,10 @@ describe Download do
52
52
  end
53
53
  end
54
54
  end
55
-
55
+
56
56
  describe ".update" do
57
57
  it "should update an existing download with valid params" do
58
- Download.update(@download.id, :preview => "10,11,12,13")
58
+ Download.update(@download.id, :preview => "10,11,12,13")
59
59
  refreshed_download = Download.get(@download.id)
60
60
  refreshed_download.preview.should == "10,11,12,13"
61
61
  end
@@ -65,12 +65,12 @@ describe Download do
65
65
  it "should destroy an existing download as an admin" do
66
66
  Download.destroy(@download.id).should be_true
67
67
  end
68
-
68
+
69
69
  it "should raise NotFound when attempting to destroy non-existing download" do
70
70
  executing do
71
71
  Download.destroy(mangle(@download.id))
72
72
  end.should raise_error(NotFound)
73
73
  end
74
74
  end
75
-
75
+
76
76
  end
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ include DataCatalog
3
+
4
+ describe "Test Emptiness" do
5
+
6
+ before do
7
+ setup_api
8
+ clean_slate
9
+ end
10
+
11
+ def expect_none_of(klass)
12
+ klass.all.should be_empty
13
+ end
14
+
15
+ describe ".all" do
16
+ it "no comments" do
17
+ expect_none_of Comment
18
+ end
19
+
20
+ it "no documents" do
21
+ expect_none_of Document
22
+ end
23
+
24
+ it "no downloads" do
25
+ expect_none_of Download
26
+ end
27
+
28
+ it "no favorites" do
29
+ expect_none_of Favorite
30
+ end
31
+
32
+ it "no imports" do
33
+ expect_none_of Import
34
+ end
35
+
36
+ it "no importers" do
37
+ expect_none_of Importer
38
+ end
39
+
40
+ it "no notes" do
41
+ expect_none_of Note
42
+ end
43
+
44
+ it "no organizations" do
45
+ expect_none_of Organization
46
+ end
47
+
48
+ it "no ratings" do
49
+ expect_none_of Rating
50
+ end
51
+
52
+ it "no reports" do
53
+ expect_none_of Report
54
+ end
55
+
56
+ it "no sources" do
57
+ expect_none_of Source
58
+ end
59
+ end
60
+
61
+ end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
  include DataCatalog
3
3
 
4
4
  describe Favorite do
5
-
5
+
6
6
  before do
7
7
  setup_api
8
8
  clean_slate
@@ -19,32 +19,32 @@ describe Favorite do
19
19
  @favorite = Favorite.create(:source_id => @source.id)
20
20
  end
21
21
  end
22
-
22
+
23
23
  describe ".create" do
24
24
 
25
25
  it "should create a favorite when valid params are passed in" do
26
26
  refreshed_user = User.get(@user.id)
27
27
  refreshed_user.favorites.first.title.should == "Some FCC Data"
28
28
  end
29
-
29
+
30
30
  end # describe ".create"
31
-
31
+
32
32
  describe ".get" do
33
-
33
+
34
34
  it "should return a favorite" do
35
35
  favorite = Favorite.get(@favorite.id)
36
36
  favorite.should be_an_instance_of(Favorite)
37
37
  favorite.user_id.should == @user.id
38
38
  end
39
-
39
+
40
40
  it "should raise NotFound if no favorite exists" do
41
41
  executing do
42
42
  Favorite.get(mangle(@favorite.id))
43
43
  end.should raise_error(NotFound)
44
44
  end
45
-
45
+
46
46
  end # describe ".get"
47
-
47
+
48
48
  describe ".all" do
49
49
 
50
50
  it "should return an enumeration of favorites" do
@@ -53,28 +53,28 @@ describe Favorite do
53
53
  o.should be_an_instance_of(Favorite)
54
54
  end
55
55
  end
56
-
56
+
57
57
  end # describe ".all"
58
58
 
59
-
59
+
60
60
  describe ".destroy" do
61
61
 
62
62
  it "should destroy an existing favorite as an admin" do
63
63
  Favorite.destroy(@favorite.id).should be_true
64
64
  end
65
-
65
+
66
66
  it "should destroy an existing favorite as the user" do
67
67
  DataCatalog.with_key(@user.primary_api_key) do
68
68
  Favorite.destroy(@favorite.id).should be_true
69
69
  end
70
70
  end
71
-
71
+
72
72
  it "should raise NotFound when attempting to destroy non-existing favorite" do
73
73
  executing do
74
74
  Favorite.destroy(mangle(@favorite.id))
75
75
  end.should raise_error(NotFound)
76
76
  end
77
-
77
+
78
78
  end # describe ".destroy"
79
-
79
+
80
80
  end
data/spec/import_spec.rb CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
  include DataCatalog
3
3
 
4
4
  describe Import do
5
-
5
+
6
6
  before do
7
7
  setup_api
8
8
  clean_slate
@@ -68,7 +68,7 @@ describe Import do
68
68
  end.should raise_error(BadRequest)
69
69
  end
70
70
  end
71
-
71
+
72
72
  describe ".all" do
73
73
  it "should return an enumeration of 2 imports" do
74
74
  imports = Import.all
@@ -100,7 +100,7 @@ describe Import do
100
100
  it "should destroy an existing import as an admin" do
101
101
  Import.destroy(@imports[0].id).should be_true
102
102
  end
103
-
103
+
104
104
  it "should not destroy an existing import as a basic user" do
105
105
  DataCatalog.with_key(@user.primary_api_key) do
106
106
  executing do
@@ -108,12 +108,12 @@ describe Import do
108
108
  end.should raise_error(Unauthorized)
109
109
  end
110
110
  end
111
-
111
+
112
112
  it "should raise NotFound when attempting to destroy non-existing import" do
113
113
  executing do
114
114
  Import.destroy(mangle(@imports[0].id))
115
115
  end.should raise_error(NotFound)
116
116
  end
117
117
  end
118
-
118
+
119
119
  end