Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

well wasn't running the tests forgot the to change the require

statements
  • Loading branch information...
commit 1b6567f9c428f8cb521898dbf9788af0488c1e74 1 parent 1bd0b88
@kyriacos authored
View
1  bin/speciny 100644 → 100755
@@ -14,6 +14,7 @@ require 'speciny'
results = {}
files.each do |file|
+ puts "\n" * 2
puts "Running: #{file}"
system("ruby -I. #{file}")
end
View
6 lib/speciny.rb
@@ -1,5 +1,7 @@
$LOAD_PATH.unshift "./lib"
+require 'speciny/reporter'
require 'speciny/extensions'
+require 'speciny/match_error'
require 'speciny/matchers'
-require 'speciny/reporter'
-require 'speciny/speciny'
+require 'speciny/matcher_group'
+require 'speciny/matcher_object'
View
11 lib/speciny/matcher_group.rb
@@ -14,12 +14,9 @@ def initialize(description, &block)
# the screen with the results.
def summary_at_exit
reporter = Speciny::Reporter.new(@description)
- at_exit {
- @tests.each do |example, result|
- reporter.print_test_result(example, result)
- end
- #reporter.print_summary
- }
+ @tests.each do |example, result|
+ reporter.print_test_result(example, result)
+ end
end
# Executes block inside the MatcherGroup
@@ -162,7 +159,7 @@ def it(description, &block)
# Just the simplest way i could do this i the time.
# Couldn't think of a better way. Please contribute if you have one.
def xit(description, &block)
- @tests[description] = :PENDING
+ @tests[description] = :pending
end
end
end
View
22 lib/speciny/matchers.rb
@@ -26,7 +26,7 @@ def expect(&block)
class Have
attr_reader :value
def initialize(value)
- self.value = value
+ @value = value
end
def items; self; end
@@ -34,11 +34,11 @@ def things; self; end
def characters; self; end
def matches?(actual)
- return actual == self.value if actual.kind_of?(Numeric)
+ return actual == value if actual.kind_of?(Numeric)
if actual.respond_to?(:length)
- actual.length == self.value
+ actual.length == value
else
- actual == self.value
+ actual == value
end
end
end
@@ -46,29 +46,29 @@ def matches?(actual)
class Equal
attr_reader :value
def initialize(value)
- self.value = value
+ @value = value
end
def matches?(actual)
- actual.equal?(self.value)
+ actual.equal?(value)
end
end
class Raise
attr_reader :value
def initialize(value=nil)
- self.value = value
+ @value = value
end
def matches?(actual)
- if self.value.kind_of?(String) && actual.respond_to?(:message)
- self.value == actual.message
- elsif actual.respond_to?(:message) && self.value.nil?
+ if value.kind_of?(String) && actual.respond_to?(:message)
+ value == actual.message
+ elsif actual.respond_to?(:message) && value.nil?
# an exception was still raised
true
else
# if they have the same exception class
- self.value == actual.class
+ value == actual.class
end
end
end
View
28 lib/speciny/reporter.rb
@@ -3,7 +3,7 @@ class Reporter
def initialize(scenario)
@scenario = scenario
- @passing, @failing, @pending = 0
+ @passing = @failing = @pending = 0
end
# stupid needs refactoring
@@ -12,34 +12,22 @@ def normalized_value?(returned)
end
def print_test_result(example, returned)
- puts "SCENARIO: #{@scenario}"
result = normalized_value?(returned)
+
+ puts "SCENARIO: #{@scenario}"
puts "\t- #{example}"
- if result == true
+
+ case result
+ when true
puts "\t\tPASSED"
@passing += 1
- elsif result == false
+ when false
puts "\t\tFAILED"
@failing += 1
- elsif result == :PENDING
+ when :pending
puts "\t\tPENDING"
@pending += 1
end
end
-
- # Print out a summary of the test results
- #def print_summary
- #puts "-------------------------------"
- #puts "DESCRIBE:\t #{@scenario}"
- #puts "PASSING:\t #{@passing}"
- #puts "FAILING:\t #{@failing}"
- #puts "PENDING:\t #{@pending}"
- #puts "-------------------------------"
- ##puts "TOTAL TESTS: #{total_tests}"
- #end
-
- #def total_tests
- #@passing + @failing + @pending
- #end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.