GithubHelp home page GithubHelp logo

flexmock's People

Contributors

doudou avatar elben avatar esumerfd avatar graaff avatar hmdne avatar jimweirich avatar julik avatar junaruga avatar mparramon-kantox avatar olleolleolle avatar othatbrian avatar repeatedly avatar thegillis avatar twp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flexmock's Issues

and_iterates/and_yields should handle enumerator chains

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.

FlexMock::Undefined when attempting to use minitest-hooks or share flexmock instances between test cases

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:

  • Is it possible to do "stub out A with this mock object for all test cases in this file" using flexmock? What would you recommend?
  • Are flexmock instances intended never to be shared between test cases by design?

NoMethodError: undefined method `match?' for #<String...>

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'

License file?

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.