somefixtures 0.0.1 → 0.1.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.
- data/README.md +17 -14
- data/Rakefile +1 -1
- data/lib/somefixtures/fixture.rb +24 -9
- data/somefixtures.gemspec +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -13,21 +13,24 @@ Install
|
|
13
13
|
|
14
14
|
Usage
|
15
15
|
-----
|
16
|
-
|
17
16
|
foo = Fixture.new(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
17
|
+
:save_to => "/Users/jbw/Desktop/",
|
18
|
+
:format => "json",
|
19
|
+
:base_uri => "http://github.com/api/v2/json",
|
20
|
+
:login => "jbw",
|
21
|
+
:token => "d6c339d410e3e35917f3c40caba8f241" )
|
22
|
+
|
23
|
+
foo.add(:get, "/user/search/jbw", "search")
|
24
|
+
foo.add_get("/user/search/jbw", "search")
|
25
|
+
|
26
|
+
foo.add_get("/user/show/jbw", "show_unauthenticated")
|
27
|
+
foo.add_get("/user/show/jbw", "show_authenticated", true)
|
28
|
+
foo.add_get("/user/show/jbw/followers", "followers")
|
29
|
+
|
30
|
+
foo.add(:post, "/user/follow/jbw", "follow", true)
|
31
|
+
foo.add_post("/user/follow/jbw", "follow", true)
|
32
|
+
|
33
|
+
foo.make_fixtures!
|
31
34
|
|
32
35
|
Licence
|
33
36
|
-------
|
data/Rakefile
CHANGED
@@ -26,7 +26,7 @@ spec = Gem::Specification.new do |s|
|
|
26
26
|
s.homepage = "http://github.com/jbw/somefixtures/"
|
27
27
|
s.require_paths = %w[lib]
|
28
28
|
s.rubyforge_project = 'somefixtures'
|
29
|
-
s.add_dependency('
|
29
|
+
s.add_dependency('httparty', '>= 0.6.1' )
|
30
30
|
end
|
31
31
|
|
32
32
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/lib/somefixtures/fixture.rb
CHANGED
@@ -15,26 +15,41 @@ module SomeFixtures
|
|
15
15
|
@fixtures = {}
|
16
16
|
end
|
17
17
|
|
18
|
-
def add query, name, authenticate
|
18
|
+
def add option, query, name, authenticate=false
|
19
19
|
@fixtures.each_key { |key| print name == key ? "You have added \"#{key}\" for a file name already. Each filename must be unique!\n" : nil }
|
20
|
-
@fixtures[name] = { :query => query, :authenticate => authenticate }
|
20
|
+
@fixtures[name] = { :option => option, :query => query, :authenticate => authenticate }
|
21
21
|
end
|
22
|
+
|
22
23
|
|
23
24
|
def make_fixtures!
|
24
|
-
save (
|
25
|
+
save (query)
|
25
26
|
end
|
26
|
-
|
27
|
+
|
28
|
+
def add_post(*args); add(:post, *args) end
|
29
|
+
def add_get(*args); add(:get, *args) end
|
30
|
+
|
27
31
|
private
|
28
|
-
|
32
|
+
|
33
|
+
def query
|
29
34
|
responses = []
|
30
|
-
|
31
35
|
@fixtures.each_key do |name|
|
32
|
-
|
36
|
+
if @fixtures[name][:option] == :post
|
37
|
+
responses << (post name)
|
38
|
+
else
|
39
|
+
responses << (get name)
|
40
|
+
end
|
33
41
|
end
|
34
|
-
|
35
42
|
responses
|
36
43
|
end
|
37
|
-
|
44
|
+
|
45
|
+
def get name
|
46
|
+
self.class.get( @base_uri + @fixtures[name][:query], :query => (authenticated? name) )
|
47
|
+
end
|
48
|
+
|
49
|
+
def post name
|
50
|
+
self.class.post( @base_uri + @fixtures[name][:query], :query => (authenticated? name) )
|
51
|
+
end
|
52
|
+
|
38
53
|
def authenticated? name
|
39
54
|
@authenticate = @fixtures[name][:authenticate];
|
40
55
|
auth_params
|
data/somefixtures.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: somefixtures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason Watson
|