Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whitespace fixes #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/wrong/adapters/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def aver(valence, explanation = nil, depth = 0)
self._assertions += 1 # increment minitest's assert count
super(valence, explanation, depth + 1) # apparently this passes along the default block
end

end
121 changes: 60 additions & 61 deletions lib/wrong/adapters/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,77 @@ module RSpec::Rails::TestUnitAssertionAdapter
end
end

# This would work if we didn't need to define failure_class
# todo: figure out how to get RSpec's config object to class_eval or whatever
# Rspec.configure do |config|
# config.include Wrong
# def failure_class
# RSpec::Expectations::ExpectationNotMetError
# end
# end
# This would work if we didn't need to define failure_class
# todo: figure out how to get RSpec's config object to class_eval or whatever
# Rspec.configure do |config|
# config.include Wrong
# def failure_class
# RSpec::Expectations::ExpectationNotMetError
# end
# end

module RSpec
module Core
class ExampleGroup
include Wrong
module RSpec
module Core
class ExampleGroup
include Wrong

def failure_class
RSpec::Expectations::ExpectationNotMetError
end
end
end
end
def failure_class
RSpec::Expectations::ExpectationNotMetError
end
end
end
end

# Disallow alias_assert :expect
module Wrong
class Config
alias :alias_assert_or_deny_original :alias_assert_or_deny
def alias_assert_or_deny(valence, extra_name, options = {})
if extra_name.to_sym == :expect
if options[:override]
RSpec::Matchers.class_eval do
remove_method(:expect)
end
else
raise ConfigError.new("RSpec already has a method named #{extra_name}. Use alias_#{valence} :#{extra_name}, :override => true if you really want to do this.")
end
end
alias_assert_or_deny_original(valence, extra_name, options)
end
end
end
# Disallow alias_assert :expect
module Wrong
class Config
alias :alias_assert_or_deny_original :alias_assert_or_deny
def alias_assert_or_deny(valence, extra_name, options = {})
if extra_name.to_sym == :expect
if options[:override]
RSpec::Matchers.class_eval do
remove_method(:expect)
end
else
raise ConfigError.new("RSpec already has a method named #{extra_name}. Use alias_#{valence} :#{extra_name}, :override => true if you really want to do this.")
end
end
alias_assert_or_deny_original(valence, extra_name, options)
end
end
end

# tweak terminal width so exceptions wrap properly inside RSpec output
Wrong::Terminal.width -= 7

elsif Object.const_defined? :Spec
# RSpec 1
Spec::Runner.configure do |config|
include Wrong
Spec::Runner.configure do |config|
include Wrong

def failure_class
Spec::Expectations::ExpectationNotMetError
end
end

# Disallow alias_assert :expect
module Wrong
class Config
alias :alias_assert_or_deny_original :alias_assert_or_deny
def alias_assert_or_deny(valence, extra_name, options = {})
if extra_name.to_sym == :expect
if options[:override]
Spec::Example::ExampleMethods.class_eval do
remove_method(:expect)
end
else
raise ConfigError.new("RSpec already has a method named #{extra_name}. Use alias_#{valence} :#{extra_name}, :override => true if you really want to do this.")
end
end
alias_assert_or_deny_original(valence, extra_name, options)
end
end
end
def failure_class
Spec::Expectations::ExpectationNotMetError
end
end

# Disallow alias_assert :expect
module Wrong
class Config
alias :alias_assert_or_deny_original :alias_assert_or_deny
def alias_assert_or_deny(valence, extra_name, options = {})
if extra_name.to_sym == :expect
if options[:override]
Spec::Example::ExampleMethods.class_eval do
remove_method(:expect)
end
else
raise ConfigError.new("RSpec already has a method named #{extra_name}. Use alias_#{valence} :#{extra_name}, :override => true if you really want to do this.")
end
end
alias_assert_or_deny_original(valence, extra_name, options)
end
end
end

else
raise "Wrong's RSpec adapter can't find RSpec. Please require 'spec' or 'rspec' before requiring 'wrong/adapters/rspec'."
Expand Down
1 change: 0 additions & 1 deletion lib/wrong/config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module Wrong

def self.load_config
Expand Down
4 changes: 2 additions & 2 deletions lib/wrong/eventually.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module Wrong
module Eventually
NO_BLOCK_PASSED = "you must pass a block to the eventually method"

def eventually options = {}, &block
raise NO_BLOCK_PASSED if block.nil?
timeout = options[:timeout] || 5
delay = options[:delay] || 0.25
last_error = nil
success = nil
begin_time = Time.now
begin_time = Time.now
while (Time.now - begin_time) < timeout
begin
aver(:assert, &block)
Expand Down
1 change: 0 additions & 1 deletion lib/wrong/message/array_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def describe
message << right_str + "\n"
message << diff_str + "\n"
message

end

def compute_and_format(left, right)
Expand Down
12 changes: 6 additions & 6 deletions lib/wrong/message/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module Assert
#
def failure_message(method_sym, block, predicate)
upper_portion = super

first_test_line = caller.find{|line|line =~ /(_test.rb|_spec.rb)/}
raise "Can't find test or spec in call chain: #{caller.join('|')}" if first_test_line.nil?
file, failure_line_number = first_test_line.split(":",2)

lines = File.readlines(file)
line_number = failure_line_number.to_i - 1
to_show = []
Expand All @@ -17,12 +17,12 @@ def failure_message(method_sym, block, predicate)
to_show.unshift(line)
line_number -= 1
end while !(line =~ /^\s+(test|it)[ ]+/ || line =~ /^\s+def test_\w+/)
to_show[to_show.length-1] = to_show[to_show.length-1].chomp +

to_show[to_show.length-1] = to_show[to_show.length-1].chomp +
" ASSERTION FAILURE #{file}:#{failure_line_number.to_i}\n"

upper_portion + "\n\n" + to_show.join
end

end
end
3 changes: 1 addition & 2 deletions test/capturing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
assert { out == "hi\n"}
assert { err == "bye\n"}
end

it "returns an empty string if nothing was emitted" do
out, err = capturing(:stdout, :stderr) do
end
Expand Down Expand Up @@ -62,5 +62,4 @@
assert { e.message =~ /^stdout was reassigned/ }
end


end
14 changes: 7 additions & 7 deletions test/message/test_context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xdescribe "showing the lines just above where the failure occurs, so you have some context" do

include Wrong::Assert

it "you can see test method all the way back to the start of the test, plus an indication of where the failure was" do
a = 1
b = 2
Expand All @@ -26,12 +26,12 @@
assert{ a == b } ASSERTION FAILURE test/include_test_context_test.rb:15}
)
end

deny {e.message.include?("works with it too")}
deny {e.message.include?("test_works_with_test_undercore")}
end
end

it "works with it too" do
begin
assert{ 1 == 2 }
Expand All @@ -43,12 +43,12 @@
assert{ 1 == 2 } ASSERTION FAILURE test/include_test_context_test.rb:36}
)
end

deny {e.message.include?("you can see test method")}
deny {e.message.include?("test_works_with_test_undercore")}
end
end

def test_works_with_test_undercore_too
begin
assert{ 1 == 2 }
Expand All @@ -60,10 +60,10 @@ def test_works_with_test_undercore_too
assert{ 1 == 2 } ASSERTION FAILURE test/include_test_context_test.rb:53}
)
end

deny {e.message.include?("you can see test method")}
deny {e.message.include?("works with it too")}
end
end

end
6 changes: 3 additions & 3 deletions test/rescuing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
require "wrong/adapters/minitest"

describe "a helper for rescuing errors" do

class RedError < StandardError; end
class BlueError < StandardError; end

it "returns the error that was raised" do
assert{ rescuing{raise RedError.new}.is_a?(RedError) }
end

it "returns nil if nothing was raised" do
assert{ rescuing{"x"}.nil? }
end

end
2 changes: 1 addition & 1 deletion test/string_comparison_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Wrong
describe StringComparison do

StringComparison = Wrong::StringComparison # so Ruby 1.9.1 can find it

before do
# crank the window and prelude down for these tests
@old_window = StringComparison.window
Expand Down
10 changes: 5 additions & 5 deletions test/verbose_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
require "wrong/rainbow"

describe "verbose assert" do

include Wrong::Helpers
include Wrong::D

before do
@m = Module.new do
extend Wrong::Assert
end
Wrong.config.verbose
@color_enabled = Sickill::Rainbow.enabled
end

after do
Wrong.config[:verbose] = nil
Wrong.config[:color] = nil
Expand All @@ -28,7 +28,7 @@
it "sets the verbose flag" do
assert Wrong.config[:verbose]
end

it "prints the contents of a successful assert" do
out = capturing {
@m.assert { 2 + 2 == 4 }
Expand All @@ -42,7 +42,7 @@
}
assert_equal "basic math: ((2 + 2) == 4)\n", out
end

it "prints in color" do
Wrong.config.color
Sickill::Rainbow.enabled = true
Expand Down
1 change: 0 additions & 1 deletion wrong.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ helper methods, like rescuing, capturing, and d.
s.add_dependency "ruby2ruby", ">= 2.0.1"
s.add_dependency "sexp_processor", ">= 4.0"
s.add_dependency "diff-lcs", "~> 1.2.0"

end