doudou / flexmock Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jimweirich/flexmock
Flexible mocking for Ruby testing
License: MIT License
This project forked from jimweirich/flexmock
Flexible mocking for Ruby testing
License: MIT License
With version 2.3.5, using the following:
flexmock(collection).should_receive(:each_batch).and_iterates(%w[a b c], %[d e f])
collection.each_batch.each_with_index do |batch, index|
...
end
Produces the following exception:
FlexMock::MockError: No Block given to mock with 'and_yield' expectation
Intuitively, I would have expected the above code to simply work. I'm not entirely sure how feasible it would be, and there are work-arounds, but it would be a nice to have.
Thank you for maintaining this gem!
Now, the problem. Here is a minimal example. (using https://github.com/jeremyevans/minitest-hooks)
require 'minitest/autorun'
require 'flexmock/minitest'
require 'minitest/hooks/default'
class A
def foo
'hi'
end
end
class SimpleTest < Minitest::Test
include Minitest::Hooks
def around_all
A.stub(:new, flexmock(foo: 'bye')) do
super
end
end
def test_it_once
puts A.new.foo
end
def test_it_twice
puts A.new.foo
end
end
Running this file produces TypeError: can't convert FlexMock::Undefined to Array
.
From skimming the code, it looks like the teardown logic for test_it_once
is "closing" the flexmock instance, putting it in a state where it respondes FlexMock::Undefined
to all messages.
I also saw the same error in another case, without minitest-hooks, where a caching scheme in the tested code was causing the flexmock instance to be shared between two test cases.
Two questions:
A
with this mock object for all test cases in this file" using flexmock? What would you recommend?Is it possible to add "Source Code" link to this github URL for below rubygems page to avoid people's confusion with jimweirich/flexmock
?
https://rubygems.org/gems/flexmock
Here is a sample for "Source Code" link just in case.
https://rubygems.org/gems/builder
Thanks.
Perhaps the CI matrix is reaching too far back in time? Ruby 2.0, 2.1 have failures.
Example failure: https://travis-ci.org/github/doudou/flexmock/jobs/663129048#L416
NoMethodError: undefined method `match?' for #String:0x00000000c577b8
TestStubbing#test_partial_mocks_leaves_NoMethodError_exceptions_raised_by_the_original_method_unchanged:
NoMethodError: undefined method `match?' for #<String:0x00000000c577b8>
/home/travis/build/doudou/flexmock/test/partial_mock_test.rb:637:in `test_partial_mocks_leaves_NoMethodError_exceptions_raised_by_the_original_method_unchanged'
I saw this package was MIT license in flexmock.gemspec
file.
Is it possible to include License file to your next version gem file?
Github has good feature to support having license.
Also see: jimweirich#23 (I mistook the repo to report the issue).
It would probably help many if this was available.
flexmock calls singleton_class
which is not defined.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.