bandsintown 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,63 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
3
  describe Bandsintown::Venue do
4
4
 
5
- describe ".initialize(name, url)" do
5
+ describe "attributes" do
6
+ before(:each) do
7
+ @venue = Bandsintown::Venue.new(123)
8
+ end
9
+ it "should have an accessor for @name" do
10
+ @venue.should respond_to(:name)
11
+ @venue.should respond_to(:name=)
12
+ end
13
+ it "should have an accessor for @bandsintown_id" do
14
+ @venue.should respond_to(:bandsintown_id)
15
+ @venue.should respond_to(:bandsintown_id=)
16
+ end
17
+ it "should have an accessor for @bandsintown_url" do
18
+ @venue.should respond_to(:bandsintown_url)
19
+ @venue.should respond_to(:bandsintown_url=)
20
+ end
21
+ it "should have an accessor for @address" do
22
+ @venue.should respond_to(:address)
23
+ @venue.should respond_to(:address=)
24
+ end
25
+ it "should have an accessor for @city" do
26
+ @venue.should respond_to(:city)
27
+ @venue.should respond_to(:city=)
28
+ end
29
+ it "should have an accessor for @region" do
30
+ @venue.should respond_to(:region)
31
+ @venue.should respond_to(:region=)
32
+ end
33
+ it "should have an accessor for @postalcode" do
34
+ @venue.should respond_to(:postalcode)
35
+ @venue.should respond_to(:postalcode=)
36
+ end
37
+ it "should have an accessor for @country" do
38
+ @venue.should respond_to(:country)
39
+ @venue.should respond_to(:country=)
40
+ end
41
+ it "should have an accessor for @latitude" do
42
+ @venue.should respond_to(:latitude)
43
+ @venue.should respond_to(:latitude=)
44
+ end
45
+ it "should have an accessor for @longitude" do
46
+ @venue.should respond_to(:longitude)
47
+ @venue.should respond_to(:longitude=)
48
+ end
49
+ it "should have an accessor for @events" do
50
+ @venue.should respond_to(:events)
51
+ @venue.should respond_to(:events=)
52
+ end
53
+ end
54
+
55
+ describe ".initialize(bandsintown_id)" do
56
+ it "should set @bandsintown_id to bandsintown_id" do
57
+ Bandsintown::Venue.new(123).bandsintown_id.should == 123
58
+ end
59
+ end
60
+
61
+ describe ".build_from_json(options = {})" do
6
62
  before(:each) do
7
63
  @name = "Paradise Rock Club"
8
64
  @url = "http://www.bandsintown.com/venue/327987"
@@ -13,7 +69,7 @@ describe Bandsintown::Venue do
13
69
  @latitude = 42.37
14
70
  @longitude = 71.03
15
71
 
16
- @venue = Bandsintown::Venue.new({
72
+ @venue = Bandsintown::Venue.build_from_json({
17
73
  "name" => @name,
18
74
  "url" => @url,
19
75
  "id" => @id,
@@ -24,6 +80,9 @@ describe Bandsintown::Venue do
24
80
  "longitude" => @longitude,
25
81
  })
26
82
  end
83
+ it "should return a Bandsintown::Venue instance" do
84
+ @venue.should be_instance_of(Bandsintown::Venue)
85
+ end
27
86
  it "should set the name" do
28
87
  @venue.name.should == @name
29
88
  end
@@ -50,4 +109,62 @@ describe Bandsintown::Venue do
50
109
  end
51
110
  end
52
111
 
112
+ describe ".resource_path" do
113
+ it "should return the path for Venue requests" do
114
+ Bandsintown::Venue.resource_path.should == "venues"
115
+ end
116
+ end
117
+
118
+ describe ".search(options={})" do
119
+ before(:each) do
120
+ @args = { :location => "Boston, MA", :query => "House of Blues" }
121
+ end
122
+ it "should request and parse a call to the BIT venues search api method" do
123
+ Bandsintown::Venue.should_receive(:request_and_parse).with(:get, "search", @args).and_return([])
124
+ Bandsintown::Venue.search(@args)
125
+ end
126
+ it "should return an Array of Bandsintown::Venue objects built from the response" do
127
+ results = [
128
+ { 'id' => '123', 'name' => "house of blues" },
129
+ { 'id' => '456', 'name' => "house of blues boston" }
130
+ ]
131
+ Bandsintown::Venue.stub!(:request_and_parse).and_return(results)
132
+ venues = Bandsintown::Venue.search(@args)
133
+ venues.should be_instance_of(Array)
134
+
135
+ venues.first.should be_instance_of(Bandsintown::Venue)
136
+ venues.first.bandsintown_id.should == '123'
137
+ venues.first.name.should == 'house of blues'
138
+
139
+ venues.last.should be_instance_of(Bandsintown::Venue)
140
+ venues.last.bandsintown_id.should == '456'
141
+ venues.last.name.should == 'house of blues boston'
142
+ end
143
+ end
144
+
145
+ describe "#events" do
146
+ before(:each) do
147
+ @bandsintown_id = 123
148
+ @venue = Bandsintown::Venue.new(@bandsintown_id)
149
+ end
150
+ it "should request and parse a call to the BIT venues - events API method with @bandsintown_id" do
151
+ Bandsintown::Venue.should_receive(:request_and_parse).with(:get, "#{@bandsintown_id}/events").and_return([])
152
+ @venue.events
153
+ end
154
+ it "should return an Array of Bandsintown::Event objects built from the response" do
155
+ event_1 = mock(Bandsintown::Event)
156
+ event_2 = mock(Bandsintown::Event)
157
+ results = [ "event 1", "event 2" ]
158
+ Bandsintown::Venue.stub!(:request_and_parse).and_return(results)
159
+ Bandsintown::Event.should_receive(:build_from_json).with("event 1").ordered.and_return(event_1)
160
+ Bandsintown::Event.should_receive(:build_from_json).with("event 2").ordered.and_return(event_2)
161
+ @venue.events.should == [event_1, event_2]
162
+ end
163
+ it "should be memoized" do
164
+ @venue.events = 'events'
165
+ Bandsintown::Venue.should_not_receive(:request_and_parse)
166
+ @venue.events.should == 'events'
167
+ end
168
+ end
169
+
53
170
  end
@@ -34,7 +34,7 @@
34
34
  <div class="sidebar">
35
35
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/bandsintown"; return false'>
36
36
  <p>Get Version</p>
37
- <a href="http://rubyforge.org/projects/bandsintown" class="numbers">0.1.4</a>
37
+ <a href="http://rubyforge.org/projects/bandsintown" class="numbers">0.2.0</a>
38
38
  </div>
39
39
  </div>
40
40
  <h2>Description</h2>
@@ -134,6 +134,48 @@
134
134
  <span class="symbol">:radius</span> <span class="punct">=&gt;</span> <span class="number">10</span>
135
135
  <span class="punct">})</span>
136
136
  </pre></p>
137
+ <h3>Find venues with name beginning with &#8220;House of Blues&#8221; near San Diego, CA</h3>
138
+ <p><pre class='syntax'>
139
+ <span class="ident">venues</span> <span class="punct">=</span> <span class="constant">Bandsintown</span><span class="punct">::</span><span class="constant">Venue</span><span class="punct">.</span><span class="ident">search</span><span class="punct">({</span>
140
+ <span class="symbol">:query</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">House of Blues</span><span class="punct">&quot;,</span>
141
+ <span class="symbol">:location</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">San Diego, CA</span><span class="punct">&quot;</span>
142
+ <span class="punct">})</span>
143
+ </pre></p>
144
+ <h3>Find all upcoming events for a given venue</h3>
145
+ <p><pre class='syntax'>
146
+ <span class="comment"># 1700 =&gt; Bandsintown venue ID for Paradise Rock Club in Boston, MA</span>
147
+ <span class="ident">venue</span> <span class="punct">=</span> <span class="constant">Bandsintown</span><span class="punct">::</span><span class="constant">Venue</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="number">1700</span><span class="punct">)</span>
148
+ <span class="ident">events</span> <span class="punct">=</span> <span class="ident">venue</span><span class="punct">.</span><span class="ident">events</span>
149
+ </pre></p>
150
+ <h3>Create an event on bandsintown.com using Bandsintown::Artist and Bandsintown::Venue objects</h3>
151
+ <p><pre class='syntax'>
152
+ <span class="comment"># 1700 =&gt; Bandsintown venue ID for Paradise Rock Club in Boston, MA</span>
153
+ <span class="constant">Bandsintown</span><span class="punct">::</span><span class="constant">Event</span><span class="punct">.</span><span class="ident">create</span><span class="punct">({</span>
154
+ <span class="symbol">:artists</span> <span class="punct">=&gt;</span> <span class="punct">[</span><span class="constant">Bandsintown</span><span class="punct">::</span><span class="constant">Artist</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">The Roots</span><span class="punct">&quot;)],</span>
155
+ <span class="symbol">:datetime</span> <span class="punct">=&gt;</span> <span class="constant">Time</span><span class="punct">.</span><span class="ident">parse</span><span class="punct">(&quot;</span><span class="string">2010-06-01 20:00</span><span class="punct">&quot;),</span>
156
+ <span class="symbol">:venue</span> <span class="punct">=&gt;</span> <span class="constant">Bandsintown</span><span class="punct">::</span><span class="constant">Venue</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="number">1700</span><span class="punct">),</span>
157
+ <span class="symbol">:ticket_url</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">http://www.example.com/tickets/123</span><span class="punct">&quot;,</span>
158
+ <span class="symbol">:ticket_price</span> <span class="punct">=&gt;</span> <span class="number">19.5</span><span class="punct">,</span>
159
+ <span class="symbol">:on_sale_datetime</span> <span class="punct">=&gt;</span> <span class="constant">Time</span><span class="punct">.</span><span class="ident">parse</span><span class="punct">(&quot;</span><span class="string">2010-05-01 12:00</span><span class="punct">&quot;)</span>
160
+ <span class="punct">})</span>
161
+ </pre></p>
162
+ <h3>Create an event on bandsintown.com using artist names and venue location hash</h3>
163
+ <p><pre class='syntax'>
164
+ <span class="comment"># 1700 =&gt; Bandsintown venue ID for Paradise Rock Club in Boston, MA</span>
165
+ <span class="constant">Bandsintown</span><span class="punct">::</span><span class="constant">Event</span><span class="punct">.</span><span class="ident">create</span><span class="punct">({</span>
166
+ <span class="symbol">:artists</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">Evidence</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">Alchemist</span><span class="punct">&quot;],</span>
167
+ <span class="symbol">:datetime</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">2010-06-01T19:30:00</span><span class="punct">&quot;,</span>
168
+ <span class="symbol">:venue</span> <span class="punct">=&gt;</span> <span class="punct">{</span>
169
+ <span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Paradise Rock Club</span><span class="punct">&quot;,</span>
170
+ <span class="symbol">:city</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Boston</span><span class="punct">&quot;,</span>
171
+ <span class="symbol">:region</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">MA</span><span class="punct">&quot;,</span>
172
+ <span class="symbol">:country</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">United States</span><span class="punct">&quot;</span>
173
+ <span class="punct">},</span>
174
+ <span class="symbol">:ticket_url</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">http://www.example.com/tickets/123</span><span class="punct">&quot;,</span>
175
+ <span class="symbol">:ticket_price</span> <span class="punct">=&gt;</span> <span class="number">15</span><span class="punct">,</span>
176
+ <span class="symbol">:on_sale_datetime</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">2010-05-01T19:30:00</span><span class="punct">&quot;</span>
177
+ <span class="punct">})</span>
178
+ </pre></p>
137
179
  <h2>Source</h2>
138
180
  <pre>git clone git://github.com/bandsintown/bandsintown.git</pre>
139
181
  <h2>Links</h2>
@@ -129,6 +129,56 @@ events = Bandsintown::Event.on_sale_soon({
129
129
  })
130
130
  </pre>
131
131
 
132
+ h3. Find venues with name beginning with "House of Blues" near San Diego, CA
133
+
134
+ <pre syntax="ruby">
135
+ venues = Bandsintown::Venue.search({
136
+ :query => "House of Blues",
137
+ :location => "San Diego, CA"
138
+ })
139
+ </pre>
140
+
141
+ h3. Find all upcoming events for a given venue
142
+
143
+ <pre syntax="ruby">
144
+ # 1700 => Bandsintown venue ID for Paradise Rock Club in Boston, MA
145
+ venue = Bandsintown::Venue.new(1700)
146
+ events = venue.events
147
+ </pre>
148
+
149
+ h3. Create an event on bandsintown.com using Bandsintown::Artist and Bandsintown::Venue objects
150
+
151
+ <pre syntax="ruby">
152
+ # 1700 => Bandsintown venue ID for Paradise Rock Club in Boston, MA
153
+ Bandsintown::Event.create({
154
+ :artists => [Bandsintown::Artist.new(:name => "The Roots")],
155
+ :datetime => Time.parse("2010-06-01 20:00"),
156
+ :venue => Bandsintown::Venue.new(1700),
157
+ :ticket_url => "http://www.example.com/tickets/123",
158
+ :ticket_price => 19.5,
159
+ :on_sale_datetime => Time.parse("2010-05-01 12:00")
160
+ })
161
+ </pre>
162
+
163
+ h3. Create an event on bandsintown.com using artist names and venue location hash
164
+
165
+ <pre syntax="ruby">
166
+ # 1700 => Bandsintown venue ID for Paradise Rock Club in Boston, MA
167
+ Bandsintown::Event.create({
168
+ :artists => ["Evidence", "Alchemist"],
169
+ :datetime => "2010-06-01T19:30:00",
170
+ :venue => {
171
+ :name => "Paradise Rock Club",
172
+ :city => "Boston",
173
+ :region => "MA",
174
+ :country => "United States"
175
+ },
176
+ :ticket_url => "http://www.example.com/tickets/123",
177
+ :ticket_price => 15,
178
+ :on_sale_datetime => "2010-05-01T19:30:00"
179
+ })
180
+ </pre>
181
+
132
182
  h2. Source
133
183
 
134
184
  <pre>git clone git://github.com/bandsintown/bandsintown.git</pre>
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 4
9
- version: 0.1.4
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mike Costanza
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-03 00:00:00 -08:00
17
+ date: 2010-06-03 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -46,9 +46,23 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: newgem
49
+ name: rest-client
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 5
58
+ - 0
59
+ version: 1.5.0
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: newgem
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - ">="
54
68
  - !ruby/object:Gem::Version
@@ -58,11 +72,11 @@ dependencies:
58
72
  - 1
59
73
  version: 1.4.1
60
74
  type: :development
61
- version_requirements: *id003
75
+ version_requirements: *id004
62
76
  - !ruby/object:Gem::Dependency
63
77
  name: hoe
64
78
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
79
+ requirement: &id005 !ruby/object:Gem::Requirement
66
80
  requirements:
67
81
  - - ">="
68
82
  - !ruby/object:Gem::Version
@@ -72,7 +86,7 @@ dependencies:
72
86
  - 0
73
87
  version: 1.8.0
74
88
  type: :development
75
- version_requirements: *id004
89
+ version_requirements: *id005
76
90
  description: |-
77
91
  Bandsintown.com API gem
78
92
 
@@ -110,6 +124,7 @@ files:
110
124
  - spec/bandsintown/artist_spec.rb
111
125
  - spec/bandsintown/base_spec.rb
112
126
  - spec/bandsintown/connection_spec.rb
127
+ - spec/bandsintown/event/creation_helpers_spec.rb
113
128
  - spec/bandsintown/event_spec.rb
114
129
  - spec/bandsintown/venue_spec.rb
115
130
  - spec/bandsintown_spec.rb