Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ported to Rspec v1 to Rspec v2

  • Loading branch information...
commit 4825ea5973084ae843e8047fc3ce3299bc8a6f93 1 parent f708728
@alan alan authored
View
2  Gemfile
@@ -1,5 +1,5 @@
source :gemcutter
-gem 'rspec'
+gem 'rspec', '>= 2.0.0.beta.15'
gem "rack"
gem "sinatra"
View
38 Rakefile
@@ -1,31 +1,25 @@
require "rubygems"
-begin
- require "spec/rake/spectask"
-rescue LoadError
- desc "Run specs"
- task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
-else
- Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
- t.libs << 'lib'
- t.libs << 'spec'
- t.warning = true
- end
- task :default => :spec
+require 'rspec/core'
+require "rspec/core/rake_task"
- desc "Run all specs in spec directory with RCov"
- Spec::Rake::SpecTask.new(:rcov) do |t|
- t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
- t.libs << 'lib'
- t.libs << 'spec'
- t.warning = true
- t.rcov = true
- t.rcov_opts = ['-x spec']
- end
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = "./**/*_spec.rb"
+ t.warning = false
end
+task :default => :spec
+
+# desc "Run all specs in spec directory with RCov"
+# RSpec::Core::RakeTask.new(:rcov) do |t|
+# t.libs << 'lib'
+# t.libs << 'spec'
+# t.warning = true
+# t.rcov = true
+# t.rcov_opts = ['-x spec']
+# end
+
desc "Generate RDoc"
task :docs do
FileUtils.rm_rf("doc")
View
1  spec/fixtures/fake_app.rb
@@ -1,3 +1,4 @@
+require "rubygems"
require "sinatra/base"
module Rack
View
5 spec/rack/test/cookie_spec.rb
@@ -1,11 +1,6 @@
require "spec_helper"
describe Rack::Test::Session do
- def have_body(string)
- simple_matcher "have body #{string.inspect}" do |response|
- response.body.should == string
- end
- end
context "cookies" do
it "keeps a cookie jar" do
View
8 spec/rack/test/digest_auth_spec.rb
@@ -12,14 +12,6 @@ def app
app
end
- def be_challenge
- simple_matcher "a HTTP Digest challenge response" do |response|
- response.status == 401 &&
- response['WWW-Authenticate'] =~ /^Digest / &&
- response.body.empty?
- end
- end
-
it 'incorrectly authenticates GETs' do
digest_authorize 'foo', 'bar'
get '/'
View
2  spec/spec.opts
@@ -1,2 +0,0 @@
---color
--fs
View
8 spec/spec_helper.rb
@@ -2,13 +2,15 @@
require "bundler/setup"
require "rack"
-require "spec"
+require "rspec"
+Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
require "rack/test"
require File.dirname(__FILE__) + "/fixtures/fake_app"
-Spec::Runner.configure do |config|
+Rspec.configure do |config|
+ config.mock_with :rspec
config.include Rack::Test::Methods
def app
@@ -20,7 +22,7 @@ def check(*args)
end
-describe "any #verb methods", :shared => true do
+shared_examples_for "any #verb methods" do
it "requests the URL using VERB" do
send(verb, "/")
View
12 spec/support/core_ext/string.rb
@@ -0,0 +1,12 @@
+# Taken from ActiveSuport v3
+class String
+ if defined?(Encoding) && "".respond_to?(:encode)
+ def encoding_aware?
+ true
+ end
+ else
+ def encoding_aware?
+ false
+ end
+ end
+end
View
9 spec/support/matchers/body.rb
@@ -0,0 +1,9 @@
+RSpec::Matchers.define :have_body do |expected|
+ match do |response|
+ response.body.should == expected
+ end
+
+ description do
+ "have body #{expected.inspect}"
+ end
+end
View
11 spec/support/matchers/challenge.rb
@@ -0,0 +1,11 @@
+RSpec::Matchers.define :be_challenge do
+ match do |actual_response|
+ actual_response.status == 401 &&
+ actual_response['WWW-Authenticate'] =~ /^Digest / &&
+ actual_response.body.empty?
+ end
+
+ description do
+ "a HTTP Digest challenge response"
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.