Permalink
Browse files

events can now be searched. tests passing

  • Loading branch information...
jwoertink committed Nov 17, 2012
1 parent add135a commit 6beaf7c85f6bd23e6acafa84cc55fed7f6407614
View
@@ -16,3 +16,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
+spec/config.yml
View
@@ -12,4 +12,5 @@ class << self
require 'eventful/request'
require 'eventful/response'
+require 'eventful/client'
require 'eventful/event'
View
@@ -0,0 +1,8 @@
+module Eventful
+
+ class Client
+ include Request
+ extend Request
+ end
+
+end
View
@@ -1,18 +1,34 @@
module Eventful
- class Event
+ class Event < Client
class << self
def search(options = {})
- [].tap do |c|
- c.extend Response
- c << new
+ response = get('events/search', options)
+ events = []
+ response.body['search']['events']['event'].each do |event_data|
+ events << new(event_data)
end
+ respond_with events, response, success: true
end
end
+ attr_accessor :attributes
+
+ def initialize(attributes = {})
+ @attributes = attributes
+ end
+
+ def method_missing(meth_name, *attrs, &block)
+ if @attributes.has_key?(meth_name.to_s)
+ @attributes[meth_name.to_s]
+ else
+ super
+ end
+ end
+
end
end
View
@@ -24,6 +24,7 @@ module Request
# @param [Hash] options
# @return [Faraday::Response]
def get(path = nil, options = {})
+ options[:app_key] ||= Eventful.api_key
connection.get(path, options)
end
@@ -4,13 +4,22 @@
describe '.search' do
context 'when coordinates are provided' do
- subject { Eventful::Event.search(latitude: '123', longitude: '-123') }
+ use_vcr_cassette 'events/search/with_coordinates'
+
+ subject { Eventful::Event.search(location: '32.746682,-117.162741', within: 25) }
it 'returns an array of events' do
subject.first.should be_kind_of(Eventful::Event)
end
- # its(:response) { should be_success }
+ it 'should be a success' do
+ subject.success? == true
+ end
+
+ it 'should respond to title' do
+ subject.first.title should_not be_nil
+ end
+
end
end

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -15,6 +15,8 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'eventful-ruby'
+Eventful.api_key = YAML.load_file(File.join(File.dirname(__FILE__), 'config.yml'))['api_key']
+
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
View
@@ -0,0 +1,19 @@
+require 'vcr'
+require 'cgi'
+
+VCR.configure do |config|
+ config.cassette_library_dir = File.expand_path('../../fixtures/vcr_cassettes', __FILE__)
+ config.hook_into :webmock
+ config.default_cassette_options = { :record => :new_episodes }
+ config.filter_sensitive_data('<API_KEY>') { Eventful.api_key }
+ config.filter_sensitive_data('<USER_AGENT>') do |interaction|
+ interaction.request.headers['User-Agent'].first
+ end
+ config.default_cassette_options = {
+ :serialize_with => :syck
+ }
+end
+
+RSpec.configure do |config|
+ config.extend VCR::RSpec::Macros
+end

0 comments on commit 6beaf7c

Please sign in to comment.