Permalink
Browse files

First stab at BDD

  • Loading branch information...
1 parent 61b3c8c commit 7ab33817ee917f614277f158984f7041cc9ec5a7 Daniel Morris committed Mar 1, 2009
Showing with 80 additions and 13 deletions.
  1. +1 −1 LICENSE
  2. +4 −0 VERSION.yml
  3. +10 −8 features/awesome_events.feature
  4. +20 −0 features/steps/awesome_events_steps.rb
  5. +0 −4 features/support/env.rb
  6. +17 −0 lib/awesome_events.rb
  7. +18 −0 lib/upcoming/group.rb
  8. +10 −0 script/console
View
@@ -1,4 +1,4 @@
-Copyright (c) 2008 Daniel Morris
+Copyright (c) 2008 Daniel Morris <daniel.john.morris@googlemail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -0,0 +1,4 @@
+---
+:major: 0
+:minor: 0
+:patch: 0
@@ -1,9 +1,11 @@
-Feature: something something
- In order to something something
- A user something something
- something something something
+Feature: List events for an Upcoming group
+ In order ingest new events
+ As an events subscriber
+ I want to list all events for a group
- Scenario: something something
- Given inspiration
- When I create a sweet new gem
- Then everyone should see how awesome I am
+ Scenario: List Upcoming events for GeekUp
+ Given I know GeekUp's upcoming id
+ And I know my Upcoming api key
+ When I create a group object
+ And I call Upcoming api: group.getEvents
+ Then I see a list of ruby xml objects
@@ -0,0 +1,20 @@
+Given /^I know GeekUp's upcoming id$/ do
+ @group_id = 1479
+end
+
+Given /^I know my Upcoming api key$/ do
+ @api_key = '1eb8461830'
+end
+
+When /^I create a group object$/ do
+ @group = Upcoming::Group.new(:api_key => @api_key, :id => @group_id)
+end
+
+When /^I call Upcoming api: group\.getEvents$/ do
+ @events = @group.fetch_events(:tense => :upcoming)
+end
+
+Then /^I see a list of ruby xml objects$/ do
+ puts @events
+ !@events.empty?
+end
View
@@ -1,13 +1,9 @@
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
require 'awesome_events'
-
require 'test/unit/assertions'
-
require 'test/unit/assertions'
World do |world|
-
world.extend(Test::Unit::Assertions)
-
world
end
View
@@ -0,0 +1,17 @@
+# dependancies
+require 'rubygems'
+require 'open-uri'
+require 'hpricot'
+
+# lib
+require 'upcoming/group'
+
+include AwesomeEvents
+
+module AwesomeEvents
+ module Util
+ def self.get(url)
+ doc = Hpricot(open(url))
+ end
+ end
+end
View
@@ -0,0 +1,18 @@
+module AwesomeEvents
+ module Upcoming
+ class Group
+
+ def initialize(options = {})
+ @id = options[:id] if options[:id]
+ @api_key = options[:api_key] if options[:api_key]
+ end
+
+ def fetch_events(options = {:tense => :upcoming})
+ url = "http://upcoming.yahooapis.com/services/rest/?api_key=#{@api_key}&method=group.getEvents&group_id=#{@id}"
+ url << "&show_past=1" if options[:tense] == :past
+
+ AwesomeEvents::Util.get(url)
+ end
+ end
+ end
+end
View
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# File: script/console
+irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
+
+libs = " -r irb/completion"
+# Perhaps use a console_lib to store any extra methods I may want available in the cosole
+# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
+libs << " -r #{File.dirname(__FILE__) + '/../lib/awesome-events.rb'}"
+puts "Loading awesome-events gem"
+exec "#{irb} #{libs} --simple-prompt"

0 comments on commit 7ab3381

Please sign in to comment.