Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated to use rspec 2.0

  • Loading branch information...
commit 6c4041433ddeb055f502e610d33425af0f4b1296 1 parent bd079b2
Philip Mcmahon authored
View
1  .rspec
@@ -0,0 +1 @@
+--color
View
21 Rakefile
@@ -1,7 +1,7 @@
-require "spec"
-require "spec/rake/spectask"
+require "rspec"
+require "rspec/core/rake_task"
require 'rake/rdoctask'
-require 'lib/feedzirra.rb'
+require File.dirname(__FILE__) + "/lib/feedzirra.rb"
# Grab recently touched specs
def recent_specs(touched_since)
@@ -24,20 +24,17 @@ desc "Run all the tests"
task :default => :spec
# Tasks
-Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*_spec.rb']
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = FileList['spec/**/*_spec.rb']
end
desc 'Run recent specs'
-Spec::Rake::SpecTask.new("spec:recent") do |t|
- t.spec_opts = ["--format","specdoc","--color"]
- t.spec_files = recent_specs(Time.now - 600) # 10 min.
+RSpec::Core::RakeTask.new("spec:recent") do |t|
+ t.pattern = recent_specs(Time.now - 600) # 10 min.
end
-Spec::Rake::SpecTask.new('spec:rcov') do |t|
- t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*_spec.rb']
+RSpec::Core::RakeTask.new('spec:rcov') do |t|
+ t.pattern = FileList['spec/**/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'spec,/usr/lib/ruby,/usr/local,/var/lib,/Library', '--text-report']
end
View
14 lib/feedzirra/feed_entry_utilities.rb
@@ -1,6 +1,6 @@
module Feedzirra
module FeedEntryUtilities
- def published
+ def published
@published || @updated
end
@@ -15,20 +15,20 @@ def parse_datetime(string)
##
# Returns the id of the entry or its url if not id is present, as some formats don't support it
- def id
+ def id
@entry_id || @url
end
-
+
##
# Writter for published. By default, we keep the "oldest" publish time found.
- def published=(val)
+ def published=(val)
parsed = parse_datetime(val)
- @published = parsed if !@published || parsed < @published
+ @published = parsed if !@published || parsed < @published
end
-
+
##
# Writter for udapted. By default, we keep the most recenet update time found.
- def updated=(val)
+ def updated=(val)
parsed = parse_datetime(val)
@updated = parsed if !@updated || parsed > @updated
end
View
8 lib/feedzirra/parser/atom_entry.rb
@@ -12,9 +12,9 @@ module Parser
# * summary
# * published
# * categories
- class AtomEntry
- include SAXMachine
- include FeedEntryUtilities
+ class AtomEntry
+ include SAXMachine
+ include FeedEntryUtilities
element :title
element :link, :as => :url, :value => :href, :with => {:type => "text/html", :rel => "alternate"}
element :name, :as => :author
@@ -28,7 +28,7 @@ class AtomEntry
element :modified, :as => :updated
elements :category, :as => :categories, :value => :term
elements :link, :as => :links, :value => :href
-
+
def url
@url || links.first
end
View
0  spec/spec.opts → spec/.rspec
File renamed without changes
View
2  spec/benchmarks/feed_benchmarks.rb
@@ -2,7 +2,7 @@
# multiple feed fetches
require 'rubygems'
require 'curb'
-require 'activesupport'
+require 'active_support'
require 'net/http'
require 'uri'
View
2  spec/feedzirra/feed_entry_utilities_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Feedzirra::FeedUtilities do
before(:each) do
View
11 spec/feedzirra/feed_utilities_spec.rb
@@ -1,4 +1,6 @@
require File.dirname(__FILE__) + '/../spec_helper'
+require 'rubygems'
+require 'active_support'
describe Feedzirra::FeedUtilities do
before(:each) do
@@ -31,8 +33,9 @@
it "should provide a last_modified accessor" do
feed = @klass.new
time = Time.now
- feed.last_modified = time
+ feed.last_modified = time
feed.last_modified.should == time
+ feed.last_modified.class.should == Time
end
it "should return new_entries? as true when entries are put into new_entries" do
@@ -121,9 +124,9 @@
@old_entry = Feedzirra::Parser::AtomEntry.new
@old_entry.url = "http://pauldix.net/old.html"
@old_entry.published = Time.now.to_s
- @new_entry = Feedzirra::Parser::AtomEntry.new
+ @new_entry = Feedzirra::Parser::AtomEntry.new
@new_entry.url = "http://pauldix.net/new.html"
- @new_entry.published = (Time.now + 10).to_s
+ @new_entry.published = (Time.now + 10).to_s
@feed.entries << @old_entry
@updated_feed.entries << @new_entry
@updated_feed.entries << @old_entry
@@ -131,7 +134,7 @@
it "should update last-modified from the latest entry date" do
@feed.update_from_feed(@updated_feed)
- @feed.last_modified.should == @new_entry.published
+ @feed.last_modified.should == @new_entry.published
end
it "should put new entries into new_entries" do
View
3  spec/feedzirra/parser/rss_entry_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
describe Feedzirra::Parser::RSSEntry do
@@ -27,7 +28,7 @@
@entry.summary.should == "Oops! When I released nokogiri version 1.0.7, I totally forgot to talk about Nokogiri::Slop() feature that was added. Why is it called \"slop\"? It lets you sloppily explore documents. Basically, it decorates your document with method_missing() that allows you to search your document via method calls.\nGiven this document:\n\ndoc = Nokogiri::Slop&#40;&#60;&#60;-eohtml&#41;\n&#60;html&#62;\n&#160; &#60;body&#62;\n&#160; [...]"
end
- it "should parse the published date" do
+ it "should parse the published date" do
@entry.published.to_s.should == "Thu Dec 04 17:17:49 UTC 2008"
end
View
12 spec/spec_helper.rb
@@ -1,5 +1,5 @@
require "rubygems"
-require "spec"
+require "rspec"
# gem install redgreen for colored test output
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
@@ -7,7 +7,7 @@
path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
-require "lib/feedzirra"
+require "feedzirra"
def load_sample(filename)
File.read("#{File.dirname(__FILE__)}/sample_feeds/#{filename}")
@@ -55,4 +55,12 @@ def sample_feedburner_atom_entry_content
def sample_wfw_feed
load_sample("PaulDixExplainsNothingWFW.xml")
+end
+
+# http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l156
+# Default Time.to_s changed in 1.9, monkeypatching it back
+class Time
+ def to_s
+ strftime("%a %b %d %H:%M:%S %Z %Y")
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.