Permalink
Browse files

Make specs green

  • Loading branch information...
1 parent bbf02f9 commit d8ba2d16820f7182b9a1b22f649559164cdb90f0 @alloy alloy committed Aug 6, 2010
Showing with 42 additions and 11 deletions.
  1. +13 −0 Rakefile
  2. +4 −4 lib/mollie/sms.rb
  3. +7 −2 lib/mollie/sms/test_helper.rb
  4. +3 −3 spec/sms_spec.rb
  5. +15 −2 spec/test_helper_spec.rb
View
@@ -5,9 +5,22 @@ task :spec do
sh "ruby ./spec/functional_sms_deliver_spec.rb"
end
+desc "Run the specs with Kicker"
+task :kick do
+ sh "kicker -c -e rake"
+end
+
task :default => :spec
begin
+ require 'yard/rake/yardoc_task'
+ YARD::Rake::YardocTask.new do |t|
+ t.options = %w{ --no-private }
+ end
+rescue LoadError
+end
+
+begin
require 'rubygems'
require 'jeweler'
Jeweler::Tasks.new do |s|
View
@@ -257,7 +257,7 @@ def deliver
# instance and the {Response} object.
def deliver!
response = deliver
- raise DeliveryFailure.new(self, response) unless response.success?
+ raise Exceptions::DeliveryFailure.new(self, response) unless response.success?
response
end
@@ -271,16 +271,16 @@ def deliver!
# @return [nil]
def validate_params!
params.slice(*REQUIRED_PARAMS).each do |key, value|
- raise ValidationError, "The required parameter `#{key}' is missing." if value.blank?
+ raise Exceptions::ValidationError, "The required parameter `#{key}' is missing." if value.blank?
end
originator = params['originator']
if originator =~ /^\d+$/
if originator.size > 14
- raise ValidationError, "Originator may have a maximimun of 14 numerical characters."
+ raise Exceptions::ValidationError, "Originator may have a maximimun of 14 numerical characters."
end
elsif originator.size > 11
- raise ValidationError, "Originator may have a maximimun of 11 alphanumerical characters."
+ raise Exceptions::ValidationError, "Originator may have a maximimun of 11 alphanumerical characters."
end
end
@@ -85,8 +85,11 @@ def assert_no_sms_messages
module SMSExt
# @private
def self.included(klass)
- klass.undef_method :deliver
- klass.extend ClassMethods
+ klass.class_eval do
+ undef_method :deliver
+ alias_method :deliver, :test_deliver
+ extend ClassMethods
+ end
end
# Overrides the normal {Mollie::SMS#deliver deliver} method to *never*
@@ -108,6 +111,8 @@ def deliver
self.class.stubbed_response
end
+ alias_method :test_deliver, :deliver
+
module ClassMethods
# @return [Array<Mollie::SMS>] A list of sent SMS messages.
#
View
@@ -110,7 +110,7 @@
exception = nil
begin
@sms.deliver!
- rescue Mollie::SMS::DeliveryFailure => exception
+ rescue Mollie::SMS::Exceptions::DeliveryFailure => exception
end
exception.message.should == "(No username given.) #{@sms.to_s}"
@@ -210,7 +210,7 @@
@sms.params['originator'] = "000000000011112"
lambda do
@sms.deliver
- end.should.raise(Mollie::SMS::ValidationError, "Originator may have a maximimun of 14 numerical characters.")
+ end.should.raise(Mollie::SMS::Exceptions::ValidationError, "Originator may have a maximimun of 14 numerical characters.")
end
it "accepts an originator of upto 11 alphanumerical characters" do
@@ -222,6 +222,6 @@
@sms.params['originator'] = "0123456789AB"
lambda do
@sms.deliver
- end.should.raise(Mollie::SMS::ValidationError, "Originator may have a maximimun of 11 alphanumerical characters.")
+ end.should.raise(Mollie::SMS::Exceptions::ValidationError, "Originator may have a maximimun of 11 alphanumerical characters.")
end
end
View
@@ -1,4 +1,11 @@
require File.expand_path("../spec_helper", __FILE__)
+
+module Test
+ class Unit
+ class TestCase
+ end
+ end
+end
require "mollie/sms/test_helper"
describe "Mollie::SMS ext" do
@@ -44,8 +51,14 @@
end
end
-describe "Mollie::SMS::TestHelper" do
- extend Mollie::SMS::TestHelper
+describe "Mollie::SMS::TestHelper::Assertions" do
+ extend Mollie::SMS::TestHelper::Assertions
+
+ it "automatically includes the Assertions module into Test::Unit::TestCase" do
+ methods = Test::Unit::TestCase.instance_methods
+ methods.should.include "assert_sms_messages"
+ methods.should.include "assert_no_sms_messages"
+ end
before do
Mollie::SMS.reset!

0 comments on commit d8ba2d1

Please sign in to comment.