fleakr 0.4.3 → 0.5.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.
Files changed (33) hide show
  1. data/README.rdoc +6 -1
  2. data/Rakefile +1 -1
  3. data/lib/fleakr.rb +2 -1
  4. data/lib/fleakr/api/option.rb +6 -6
  5. data/lib/fleakr/version.rb +2 -2
  6. data/test/test_helper.rb +9 -8
  7. data/test/unit/fleakr/api/file_parameter_test.rb +8 -8
  8. data/test/unit/fleakr/api/method_request_test.rb +11 -10
  9. data/test/unit/fleakr/api/option_test.rb +29 -29
  10. data/test/unit/fleakr/api/parameter_list_test.rb +22 -22
  11. data/test/unit/fleakr/api/parameter_test.rb +5 -5
  12. data/test/unit/fleakr/api/response_test.rb +6 -6
  13. data/test/unit/fleakr/api/upload_request_test.rb +28 -24
  14. data/test/unit/fleakr/api/value_parameter_test.rb +6 -6
  15. data/test/unit/fleakr/core_ext/false_class_test.rb +2 -2
  16. data/test/unit/fleakr/core_ext/hash_test.rb +6 -6
  17. data/test/unit/fleakr/core_ext/true_class_test.rb +2 -2
  18. data/test/unit/fleakr/objects/authentication_token_test.rb +6 -6
  19. data/test/unit/fleakr/objects/comment_test.rb +8 -8
  20. data/test/unit/fleakr/objects/contact_test.rb +8 -5
  21. data/test/unit/fleakr/objects/error_test.rb +2 -2
  22. data/test/unit/fleakr/objects/group_test.rb +5 -5
  23. data/test/unit/fleakr/objects/image_test.rb +6 -6
  24. data/test/unit/fleakr/objects/photo_context_test.rb +11 -11
  25. data/test/unit/fleakr/objects/photo_test.rb +32 -29
  26. data/test/unit/fleakr/objects/search_test.rb +9 -9
  27. data/test/unit/fleakr/objects/set_test.rb +9 -9
  28. data/test/unit/fleakr/objects/tag_test.rb +12 -12
  29. data/test/unit/fleakr/objects/user_test.rb +10 -10
  30. data/test/unit/fleakr/support/attribute_test.rb +21 -21
  31. data/test/unit/fleakr/support/object_test.rb +17 -17
  32. data/test/unit/fleakr_test.rb +24 -24
  33. metadata +3 -3
@@ -148,7 +148,12 @@ All tags have values, but for tags associated with photos there is some addition
148
148
  >> tag.author
149
149
  => #<Fleakr::Objects::User:0x1a149f0 @username="the decapitator", ... >
150
150
 
151
- See Fleakr::Objects::Tag for more information.
151
+ Each tag can also have related tags:
152
+
153
+ >> user.photos.first.tags[1].related.first.related.first.to_s
154
+ => "face"
155
+
156
+ You get the idea - see Fleakr::Objects::Tag for more information.
152
157
 
153
158
  === Comments
154
159
 
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ spec = Gem::Specification.new do |s|
18
18
  s.homepage = 'http://sneaq.net'
19
19
  s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,test}/**/*")
20
20
 
21
- s.add_dependency('hpricot', '~> 0.6.0')
21
+ s.add_dependency('hpricot', '~> 0.8.1')
22
22
  s.add_dependency('activesupport', '~> 2.0')
23
23
  s.add_dependency('loggable', '~> 0.2.0')
24
24
  end
@@ -15,7 +15,8 @@ require 'active_support/core_ext/time'
15
15
  require 'active_support/inflector'
16
16
  require 'active_support/core_ext/string'
17
17
 
18
- require 'md5'
18
+ require 'digest/md5'
19
+ require 'fileutils'
19
20
  require 'loggable'
20
21
 
21
22
  require 'fleakr/api'
@@ -121,9 +121,9 @@ module Fleakr
121
121
 
122
122
  def value # :nodoc:
123
123
  case @value
124
- when :safe: 1
125
- when :moderate: 2
126
- when :restricted: 3
124
+ when :safe then 1
125
+ when :moderate then 2
126
+ when :restricted then 3
127
127
  end
128
128
  end
129
129
 
@@ -143,9 +143,9 @@ module Fleakr
143
143
 
144
144
  def value # :nodoc:
145
145
  case @value
146
- when :photo: 1
147
- when :screenshot: 2
148
- when :other: 3
146
+ when :photo then 1
147
+ when :screenshot then 2
148
+ when :other then 3
149
149
  end
150
150
  end
151
151
 
@@ -2,8 +2,8 @@ module Fleakr
2
2
  module Version # :nodoc:
3
3
 
4
4
  MAJOR = 0
5
- MINOR = 4
6
- TINY = 3
5
+ MINOR = 5
6
+ TINY = 0
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -1,8 +1,9 @@
1
1
  $:.reject! { |e| e.include? 'TextMate' }
2
2
 
3
3
  require 'rubygems'
4
+ require 'test/unit'
5
+ require 'shoulda'
4
6
  require 'matchy'
5
- require 'context'
6
7
  require 'mocha'
7
8
 
8
9
  require File.dirname(__FILE__) + '/../lib/fleakr'
@@ -12,7 +13,7 @@ class Test::Unit::TestCase
12
13
  def self.should_autoload_when_accessing(*attributes)
13
14
  options = attributes.extract_options!
14
15
  attributes.each do |accessor_name|
15
- it "should load the additional user information when accessing the :#{accessor_name} attribute" do
16
+ should "load the additional user information when accessing the :#{accessor_name} attribute" do
16
17
  klass = self.class.name.sub(/Test$/, '').constantize
17
18
 
18
19
  object = klass.new
@@ -23,13 +24,13 @@ class Test::Unit::TestCase
23
24
  end
24
25
 
25
26
  def self.should_have_a_value_for(attribute_test)
26
- it "should have a value for :#{attribute_test.keys.first}" do
27
+ should "have a value for :#{attribute_test.keys.first}" do
27
28
  @object.send(attribute_test.keys.first).should == attribute_test.values.first
28
29
  end
29
30
  end
30
31
 
31
32
  def self.should_search_by(key)
32
- it "should be able to perform a scoped search by :#{key}" do
33
+ should "be able to perform a scoped search by :#{key}" do
33
34
  photos = [stub()]
34
35
  search = stub(:results => photos)
35
36
 
@@ -53,7 +54,7 @@ class Test::Unit::TestCase
53
54
 
54
55
  attributes.each do |attribute|
55
56
  target_klass = "Fleakr::Objects::#{attribute.to_s.singularize.classify}".constantize
56
- it "should be able to retrieve the #{class_name.downcase}'s #{attribute}" do
57
+ should "be able to retrieve the #{class_name.downcase}'s #{attribute}" do
57
58
  results = [stub()]
58
59
  object = this_klass.new
59
60
  object.stubs(:id).with().returns('1')
@@ -62,7 +63,7 @@ class Test::Unit::TestCase
62
63
  object.send(attribute).should == results
63
64
  end
64
65
 
65
- it "should memoize the results for the #{class_name.downcase}'s #{attribute}" do
66
+ should "memoize the results for the #{class_name.downcase}'s #{attribute}" do
66
67
  object = this_klass.new
67
68
 
68
69
  target_klass.expects("find_all_by_#{finder_attribute}".to_sym).once.returns([])
@@ -82,7 +83,7 @@ class Test::Unit::TestCase
82
83
  options[:with] = options[:by] if options[:with].nil?
83
84
  params = {options[:with] => condition_value}
84
85
 
85
- it "should be able to find a #{thing} by #{options[:by]}" do
86
+ should "be able to find a #{thing} by #{options[:by]}" do
86
87
  stub = stub()
87
88
  response = mock_request_cycle :for => options[:call], :with => params
88
89
 
@@ -96,7 +97,7 @@ class Test::Unit::TestCase
96
97
  klass = "Fleakr::Objects::#{class_name}".constantize
97
98
  object_type = class_name.downcase
98
99
 
99
- it "should be able to find all #{thing} by #{options[:by]}" do
100
+ should "be able to find all #{thing} by #{options[:by]}" do
100
101
  condition_value = '1'
101
102
  finder_options = {(options[:using] || options[:by]) => condition_value}
102
103
 
@@ -3,44 +3,44 @@ require File.dirname(__FILE__) + '/../../../test_helper'
3
3
  module Fleakr::Api
4
4
  class FileParameterTest < Test::Unit::TestCase
5
5
 
6
- describe "An instance of the FileParameter class" do
6
+ context "An instance of the FileParameter class" do
7
7
 
8
- before do
8
+ setup do
9
9
  @temp_dir = File.expand_path(create_temp_directory)
10
10
  @filename = "#{@temp_dir}/image.jpg"
11
11
  end
12
12
 
13
- after do
13
+ teardown do
14
14
  FileUtils.rm_rf(@temp_dir)
15
15
  end
16
16
 
17
- it "should know not to include itself in the parameter signature" do
17
+ should "know not to include itself in the parameter signature" do
18
18
  parameter = FileParameter.new('photo', @filename)
19
19
  parameter.include_in_signature?.should be(false)
20
20
  end
21
21
 
22
22
  {'jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif'}.each do |ext, mime_type|
23
- it "should know the correct MIME type for an extension of #{ext}" do
23
+ should "know the correct MIME type for an extension of #{ext}" do
24
24
  parameter = FileParameter.new('photo', "#{@temp_dir}/image.#{ext}")
25
25
  parameter.mime_type.should == mime_type
26
26
  end
27
27
  end
28
28
 
29
- it "should retrieve the contents of the file when accessing the value" do
29
+ should "retrieve the contents of the file when accessing the value" do
30
30
  File.expects(:read).with(@filename).returns('bopbip')
31
31
 
32
32
  parameter = FileParameter.new('photo', @filename)
33
33
  parameter.value.should == 'bopbip'
34
34
  end
35
35
 
36
- it "should cache the file contents after retrieving them" do
36
+ should "cache the file contents after retrieving them" do
37
37
  File.expects(:read).with(@filename).once.returns('bopbip')
38
38
 
39
39
  parameter = FileParameter.new('photo', @filename)
40
40
  2.times { parameter.value }
41
41
  end
42
42
 
43
- it "should know how to generate a form representation of itself" do
43
+ should "know how to generate a form representation of itself" do
44
44
  filename = 'image.jpg'
45
45
  mime_type = 'image/jpeg'
46
46
 
@@ -3,17 +3,17 @@ require File.dirname(__FILE__) + '/../../../test_helper'
3
3
  module Fleakr::Api
4
4
  class MethodRequestTest < Test::Unit::TestCase
5
5
 
6
- describe "An instance of MethodRequest" do
6
+ context "An instance of MethodRequest" do
7
7
 
8
8
  context "with API credentials" do
9
9
 
10
- before do
10
+ setup do
11
11
  @api_key = 'f00b4r'
12
12
  Fleakr.stubs(:api_key).with().returns(@api_key)
13
13
  Fleakr.stubs(:shared_secret).with().returns('sekrit')
14
14
  end
15
15
 
16
- it "should know the full query parameters" do
16
+ should "know the full query parameters" do
17
17
  request = MethodRequest.new('flickr.people.findByUsername', :username => 'foobar')
18
18
 
19
19
  request.parameters[:api_key].value.should == @api_key
@@ -21,24 +21,25 @@ module Fleakr::Api
21
21
  request.parameters[:username].value.should == 'foobar'
22
22
  end
23
23
 
24
- it "should translate a shorthand API call" do
24
+ should "translate a shorthand API call" do
25
25
  request = MethodRequest.new('people.findByUsername')
26
26
  request.parameters[:method].value.should == 'flickr.people.findByUsername'
27
27
  end
28
28
 
29
- it "should know the endpoint with full parameters" do
29
+ should "know the endpoint with full parameters" do
30
30
  query_parameters = 'foo=bar'
31
31
 
32
32
  request = MethodRequest.new('people.getInfo')
33
33
  request.parameters.stubs(:to_query).returns(query_parameters)
34
34
 
35
- uri_mock = mock() {|m| m.expects(:query=).with(query_parameters)}
35
+ uri_mock = mock()
36
+ uri_mock.expects(:query=).with(query_parameters)
36
37
  URI.expects(:parse).with("http://api.flickr.com/services/rest/").returns(uri_mock)
37
38
 
38
39
  request.__send__(:endpoint_uri).should == uri_mock
39
40
  end
40
41
 
41
- it "should be able to make a request" do
42
+ should "be able to make a request" do
42
43
  endpoint_uri = stub()
43
44
 
44
45
  request = MethodRequest.new('people.findByUsername')
@@ -49,7 +50,7 @@ module Fleakr::Api
49
50
  request.send
50
51
  end
51
52
 
52
- it "should create a response from the request" do
53
+ should "create a response from the request" do
53
54
  response_xml = '<xml>'
54
55
  response_stub = stub()
55
56
 
@@ -62,7 +63,7 @@ module Fleakr::Api
62
63
  request.send.should == response_stub
63
64
  end
64
65
 
65
- it "should be able to make a full request and response cycle" do
66
+ should "be able to make a full request and response cycle" do
66
67
  method = 'flickr.people.findByUsername'
67
68
  params = {:username => 'foobar'}
68
69
 
@@ -73,7 +74,7 @@ module Fleakr::Api
73
74
  MethodRequest.with_response!(method, params).should == response
74
75
  end
75
76
 
76
- it "should raise an exception when the full request / response cycle has errors" do
77
+ should "raise an exception when the full request / response cycle has errors" do
77
78
  method = 'flickr.people.findByUsername'
78
79
  params = {:username => 'foobar'}
79
80
 
@@ -5,12 +5,12 @@ module Fleakr::Api
5
5
  class OptionTest < Test::Unit::TestCase
6
6
 
7
7
  def self.should_know_the_class_for(type, options)
8
- it "should know the class for the :#{type} type" do
8
+ should "know the class for the :#{type} type" do
9
9
  Option.class_for(type).should == options[:is]
10
10
  end
11
11
  end
12
12
 
13
- describe "The Option class" do
13
+ context "The Option class" do
14
14
  should_know_the_class_for :title, :is => Fleakr::Api::SimpleOption
15
15
  should_know_the_class_for :description, :is => Fleakr::Api::SimpleOption
16
16
  should_know_the_class_for :tags, :is => Fleakr::Api::TagOption
@@ -19,7 +19,7 @@ module Fleakr::Api
19
19
  should_know_the_class_for :type, :is => Fleakr::Api::TypeOption
20
20
  should_know_the_class_for :hide?, :is => Fleakr::Api::HiddenOption
21
21
 
22
- it "should be able to create an option for a type" do
22
+ should "be able to create an option for a type" do
23
23
  option = stub()
24
24
 
25
25
  Option.expects(:class_for).with(:title).returns(Fleakr::Api::SimpleOption)
@@ -33,18 +33,18 @@ module Fleakr::Api
33
33
 
34
34
  class SimpleOptionTest < Test::Unit::TestCase
35
35
 
36
- describe "An instance of the SimpleOption class" do
37
- it "should have a type" do
36
+ context "An instance of the SimpleOption class" do
37
+ should "have a type" do
38
38
  so = SimpleOption.new(:title, 'blip')
39
39
  so.type.should == :title
40
40
  end
41
41
 
42
- it "should have a value" do
42
+ should "have a value" do
43
43
  so = SimpleOption.new(:title, 'blip')
44
44
  so.value.should == 'blip'
45
45
  end
46
46
 
47
- it "should be able to generate a hash representation of itself" do
47
+ should "be able to generate a hash representation of itself" do
48
48
  so = SimpleOption.new(:title, 'blip')
49
49
  so.to_hash.should == {:title => 'blip'}
50
50
  end
@@ -54,19 +54,19 @@ module Fleakr::Api
54
54
 
55
55
  class TagOptionTest < Test::Unit::TestCase
56
56
 
57
- describe "An instance of the TagOption class" do
57
+ context "An instance of the TagOption class" do
58
58
 
59
- it "should normalize the input value to an array" do
59
+ should "normalize the input value to an array" do
60
60
  to = TagOption.new(:tags, 'blip')
61
61
  to.value.should == ['blip']
62
62
  end
63
63
 
64
- it "should be able to generate a hash representation of itself with tags joined on spaces" do
64
+ should "be able to generate a hash representation of itself with tags joined on spaces" do
65
65
  to = TagOption.new(:tags, %w(bop bip))
66
66
  to.to_hash.should == {:tags => '"bop" "bip"'}
67
67
  end
68
68
 
69
- it "should quote tag values with spaces" do
69
+ should "quote tag values with spaces" do
70
70
  to = TagOption.new(:tags, ['tag', 'one with spaces'])
71
71
  to.to_hash.should == {:tags => '"tag" "one with spaces"'}
72
72
  end
@@ -76,33 +76,33 @@ module Fleakr::Api
76
76
 
77
77
  class ViewOptionTest < Test::Unit::TestCase
78
78
 
79
- describe "An instance of the ViewOption class" do
80
- it "should be able to generate a hash representation for viewing by :everyone" do
79
+ context "An instance of the ViewOption class" do
80
+ should "be able to generate a hash representation for viewing by :everyone" do
81
81
  vo = ViewOption.new(:viewable_by, :everyone)
82
82
  vo.to_hash.should == {:is_public => 1, :is_family => 0, :is_friend => 0}
83
83
  end
84
84
 
85
- it "should be able to generate a hash representation for viewing by :family" do
85
+ should "be able to generate a hash representation for viewing by :family" do
86
86
  vo = ViewOption.new(:viewable_by, :family)
87
87
  vo.to_hash.should == {:is_public => 0, :is_family => 1, :is_friend => 0}
88
88
  end
89
89
 
90
- it "should be able to generate a hash representation for viewing by :friends" do
90
+ should "be able to generate a hash representation for viewing by :friends" do
91
91
  vo = ViewOption.new(:viewable_by, :friends)
92
92
  vo.to_hash.should == {:is_public => 0, :is_family => 0, :is_friend => 1}
93
93
  end
94
94
 
95
- it "should know the visibility is public if value is set to :everyone" do
95
+ should "know the visibility is public if value is set to :everyone" do
96
96
  vo = ViewOption.new(:viewable_by, :everyone)
97
97
  vo.public?.should be(true)
98
98
  end
99
99
 
100
- it "should know the visibility is not public if :everyone is not the only value" do
100
+ should "know the visibility is not public if :everyone is not the only value" do
101
101
  vo = ViewOption.new(:viewable_by, [:everyone, :family])
102
102
  vo.public?.should be(false)
103
103
  end
104
104
 
105
- it "should know that its visible to friends and family if specified as such" do
105
+ should "know that its visible to friends and family if specified as such" do
106
106
  vo = ViewOption.new(:viewable_by, [:friends, :family])
107
107
  vo.friends?.should be(true)
108
108
  vo.family?.should be(true)
@@ -114,19 +114,19 @@ module Fleakr::Api
114
114
 
115
115
  class LevelOptionTest < Test::Unit::TestCase
116
116
 
117
- describe "An instance of the LevelOption class" do
117
+ context "An instance of the LevelOption class" do
118
118
 
119
- it "should be able to generate a hash representation for the :safe level" do
119
+ should "be able to generate a hash representation for the :safe level" do
120
120
  lo = LevelOption.new(:level, :safe)
121
121
  lo.to_hash.should == {:safety_level => 1}
122
122
  end
123
123
 
124
- it "should be able to generate a hash representation for the :moderate level" do
124
+ should "be able to generate a hash representation for the :moderate level" do
125
125
  lo = LevelOption.new(:level, :moderate)
126
126
  lo.to_hash.should == {:safety_level => 2}
127
127
  end
128
128
 
129
- it "should be able to generate a hash representation for the :restricted level" do
129
+ should "be able to generate a hash representation for the :restricted level" do
130
130
  lo = LevelOption.new(:level, :restricted)
131
131
  lo.to_hash.should == {:safety_level => 3}
132
132
  end
@@ -137,19 +137,19 @@ module Fleakr::Api
137
137
 
138
138
  class TypeOptionTest < Test::Unit::TestCase
139
139
 
140
- describe "An instance of the TypeOption class" do
140
+ context "An instance of the TypeOption class" do
141
141
 
142
- it "should be able to generate a hash representation for the :photo type" do
142
+ should "be able to generate a hash representation for the :photo type" do
143
143
  to = TypeOption.new(:type, :photo)
144
144
  to.to_hash.should == {:content_type => 1}
145
145
  end
146
146
 
147
- it "should be able to generate a hash representation for the :screenshot type" do
147
+ should "be able to generate a hash representation for the :screenshot type" do
148
148
  to = TypeOption.new(:type, :screenshot)
149
149
  to.to_hash.should == {:content_type => 2}
150
150
  end
151
151
 
152
- it "should be able to generate a hash representation for the :other type" do
152
+ should "be able to generate a hash representation for the :other type" do
153
153
  to = TypeOption.new(:type, :other)
154
154
  to.to_hash.should == {:content_type => 3}
155
155
  end
@@ -160,14 +160,14 @@ module Fleakr::Api
160
160
 
161
161
  class HiddenOptionTest < Test::Unit::TestCase
162
162
 
163
- describe "An instance of the HiddenOption class" do
163
+ context "An instance of the HiddenOption class" do
164
164
 
165
- it "should be able to generate a hash representation when set to true" do
165
+ should "be able to generate a hash representation when set to true" do
166
166
  ho = HiddenOption.new(:hide?, true)
167
167
  ho.to_hash.should == {:hidden => 2}
168
168
  end
169
169
 
170
- it "should be able to generate a hash representation when set to false" do
170
+ should "be able to generate a hash representation when set to false" do
171
171
  ho = HiddenOption.new(:hide?, false)
172
172
  ho.to_hash.should == {:hidden => 1}
173
173
  end
@@ -3,9 +3,9 @@ require File.dirname(__FILE__) + '/../../../test_helper'
3
3
  module Fleakr::Api
4
4
  class ParameterListTest < Test::Unit::TestCase
5
5
 
6
- describe "An instance of the ParameterList class" do
6
+ context "An instance of the ParameterList class" do
7
7
 
8
- before do
8
+ setup do
9
9
  @api_key = 'key'
10
10
  @secret = 'foobar'
11
11
 
@@ -13,46 +13,46 @@ module Fleakr::Api
13
13
  @parameter_list = ParameterList.new
14
14
  end
15
15
 
16
- it "should contain the :api_key by default" do
16
+ should "contain the :api_key by default" do
17
17
  @parameter_list[:api_key].name.should == 'api_key'
18
18
  @parameter_list[:api_key].value.should == @api_key
19
19
  @parameter_list[:api_key].include_in_signature?.should be(true)
20
20
  end
21
21
 
22
- it "should be able to create an initial list of parameters" do
22
+ should "be able to create an initial list of parameters" do
23
23
  parameter_list = ParameterList.new(:one => 'two')
24
24
  parameter_list[:one].value.should == 'two'
25
25
  end
26
26
 
27
- it "should be able to add parameters to its list" do
27
+ should "be able to add parameters to its list" do
28
28
  parameter = ValueParameter.new('foo', 'bar')
29
29
 
30
30
  @parameter_list << parameter
31
31
  @parameter_list['foo'].should == parameter
32
32
  end
33
33
 
34
- it "should allow access to parameters by symbol" do
34
+ should "allow access to parameters by symbol" do
35
35
  parameter = ValueParameter.new('foo', 'bar')
36
36
  @parameter_list << parameter
37
37
 
38
38
  @parameter_list[:foo].should == parameter
39
39
  end
40
40
 
41
- it "should overwrite existing values when a duplicate is added" do
41
+ should "overwrite existing values when a duplicate is added" do
42
42
  length = @parameter_list.instance_variable_get(:@list).length
43
43
  2.times {@parameter_list << ValueParameter.new('foo', 'bar') }
44
44
 
45
45
  @parameter_list.instance_variable_get(:@list).length.should == length + 1
46
46
  end
47
47
 
48
- it "should be able to calculate the signature of the parameters" do
48
+ should "be able to calculate the signature of the parameters" do
49
49
  Fleakr.stubs(:shared_secret).with().returns(@secret)
50
50
 
51
51
  @parameter_list << ValueParameter.new('foo', 'bar')
52
52
  @parameter_list.signature.should == Digest::MD5.hexdigest("#{@secret}api_key#{@api_key}foobar")
53
53
  end
54
54
 
55
- it "should use the correct order when signing a list of multiple parameters" do
55
+ should "use the correct order when signing a list of multiple parameters" do
56
56
  Fleakr.stubs(:shared_secret).with().returns(@secret)
57
57
 
58
58
  @parameter_list << ValueParameter.new('z', 'a')
@@ -61,7 +61,7 @@ module Fleakr::Api
61
61
  @parameter_list.signature.should == Digest::MD5.hexdigest("#{@secret}azapi_key#{@api_key}za")
62
62
  end
63
63
 
64
- it "should ignore the parameters that aren't included in the signature" do
64
+ should "ignore the parameters that aren't included in the signature" do
65
65
  Fleakr.stubs(:shared_secret).with().returns(@secret)
66
66
 
67
67
  @parameter_list << ValueParameter.new('foo', 'bar')
@@ -70,34 +70,34 @@ module Fleakr::Api
70
70
  @parameter_list.signature.should == Digest::MD5.hexdigest("#{@secret}api_key#{@api_key}foobar")
71
71
  end
72
72
 
73
- it "should be able to generate a boundary for post data" do
73
+ should "be able to generate a boundary for post data" do
74
74
  rand = '0.123'
75
75
 
76
76
  @parameter_list.stubs(:rand).with().returns(stub(:to_s => rand))
77
77
  @parameter_list.boundary.should == Digest::MD5.hexdigest(rand)
78
78
  end
79
79
 
80
- it "should know that it doesn't need to sign the request by default" do
80
+ should "know that it doesn't need to sign the request by default" do
81
81
  @parameter_list.sign?.should be(false)
82
82
  end
83
83
 
84
- it "should know that it needs to sign the request when a shared secret is available" do
84
+ should "know that it needs to sign the request when a shared secret is available" do
85
85
  Fleakr.expects(:shared_secret).with().returns(@secret)
86
86
  @parameter_list.sign?.should be(true)
87
87
  end
88
88
 
89
- it "should know that it doesn't need to authenticate the request by default" do
89
+ should "know that it doesn't need to authenticate the request by default" do
90
90
  @parameter_list.authenticate?.should be(false)
91
91
  end
92
92
 
93
- it "should know to authenticate the request when a token is available" do
93
+ should "know to authenticate the request when a token is available" do
94
94
  Fleakr.stubs(:token).with().returns(stub(:value => 'toke'))
95
95
  parameter_list = ParameterList.new
96
96
 
97
97
  parameter_list.authenticate?.should be(true)
98
98
  end
99
99
 
100
- it "should not authenticate the request if it's been specifically told not to" do
100
+ should "not authenticate the request if it's been specifically told not to" do
101
101
  Fleakr.expects(:token).with().never
102
102
 
103
103
  parameter_list = ParameterList.new(:authenticate? => false)
@@ -105,14 +105,14 @@ module Fleakr::Api
105
105
  end
106
106
 
107
107
 
108
- it "should know to authenticate the request when asked" do
108
+ should "know to authenticate the request when asked" do
109
109
  Fleakr.expects(:token).with().returns(stub(:value => 'toke'))
110
110
 
111
111
  parameter_list = ParameterList.new(:authenticate? => true)
112
112
  parameter_list.authenticate?.should be(true)
113
113
  end
114
114
 
115
- it "should contain the :auth_token parameter in the list if the request is to be authenticated" do
115
+ should "contain the :auth_token parameter in the list if the request is to be authenticated" do
116
116
  Fleakr.expects(:token).with().returns(stub(:value => 'toke'))
117
117
 
118
118
  parameter_list = ParameterList.new(:authenticate? => true)
@@ -123,7 +123,7 @@ module Fleakr::Api
123
123
  auth_param.include_in_signature?.should be(true)
124
124
  end
125
125
 
126
- it "should include the signature in the list of parameters if the request is to be signed" do
126
+ should "include the signature in the list of parameters if the request is to be signed" do
127
127
  parameter_list = ParameterList.new
128
128
 
129
129
  parameter_list.stubs(:sign?).with().returns(true)
@@ -138,7 +138,7 @@ module Fleakr::Api
138
138
 
139
139
  context "with associated parameters" do
140
140
 
141
- before do
141
+ setup do
142
142
  @p1 = ValueParameter.new('a', 'b')
143
143
  @p2 = ValueParameter.new('c', 'd')
144
144
 
@@ -151,11 +151,11 @@ module Fleakr::Api
151
151
  @parameter_list.stubs(:list).with().returns('a' => @p1, 'c' => @p2)
152
152
  end
153
153
 
154
- it "should be able to generate a query representation of itself" do
154
+ should "be able to generate a query representation of itself" do
155
155
  @parameter_list.to_query.should == 'q1&q2'
156
156
  end
157
157
 
158
- it "should be able to represent a form representation of itself" do
158
+ should "be able to represent a form representation of itself" do
159
159
  @parameter_list.stubs(:boundary).returns('bound')
160
160
 
161
161
  expected =