Skip to content

Commit

Permalink
Merge 83a117d into 6945a0b
Browse files Browse the repository at this point in the history
  • Loading branch information
chastell committed May 18, 2013
2 parents 6945a0b + 83a117d commit 27416af
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/bogus.rb
Expand Up @@ -8,9 +8,11 @@
require_relative 'bogus/rspec_extensions'
require_relative 'bogus/rspec_adapter'

all_files = Dir[File.expand_path('../bogus/**/*.rb', __FILE__)]
all_files = all_files.reject { |f| f.include?('bogus/rspec') }
all_files.sort.each { |f| require f }
Dir[File.expand_path('../bogus/**/*.rb', __FILE__)].sort.each do |path|
next if path.include? 'bogus/minitest'
next if path.include? 'bogus/rspec'
require path
end

module Bogus
extend PublicMethods
Expand Down
48 changes: 48 additions & 0 deletions lib/bogus/minitest.rb
@@ -0,0 +1,48 @@
require 'minitest/spec'
require 'bogus'

module MiniTest::Assertions
def assert_received(subject, method, args, message = nil)
with_bogus_matcher_for(subject, method, args) do |matcher, result|
assert(result, message || matcher.failure_message_for_should)
end
end

def refute_received(subject, method, args, message = nil)
with_bogus_matcher(subject, method, args) do |matcher, result|
refute(result, message || matcher.failure_message_for_should_not)
end
end

private

def with_bogus_matcher_for(subject, method, args)
matcher = Bogus.have_received.__send__(method, *args)
result = matcher.matches?(subject)
yield matcher, result
end
end

module MiniTest::Expectations
infect_an_assertion :assert_received, :must_have_received, true
infect_an_assertion :refute_received, :wont_have_received, true
end

class MiniTest::Spec
include Bogus::MockingDSL

module DSL
def fake(name, opts = {}, &block)
let(name) { fake(name, opts, &block) }
end

def fake_class(name, opts = {})
before do
fake_class(name, opts)
end
end
end

before { Bogus.clear }
after { Bogus.ensure_all_expectations_satisfied! }
end

0 comments on commit 27416af

Please sign in to comment.