Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Mike Moore
@blowmage
You can also weigh in on how to support controller tests on blowmage/minitest-rails#194
Edgar Ortega
@EdgarOrtegaRamirez
@blowmage thanks, I used this patch and it's working right now.
Mike Simkins
@msimkins
Can you stop generating controller tests in Rails 4
Mike Moore
@blowmage
Rails doesn't have an option to do that AFAIK
Mike Simkins
@msimkins
I am trying to switch to mini from RSpec, and there you can pass an option controller_specs: false, and it does not generate them, I was hoping I missed the option in Minitest
Mike Moore
@blowmage
No, we stick to the rails defaults as much as possible.
Mike Simkins
@msimkins
Thanks @blowmage, I thought that was the case, I thought with the comments about controller tests being deprecated in Rails5, that it may have been something I could do, Ill just delete the folder, as for some strange reason I can't make the authentication work right, but it works fine as an integration test <sigh>
Mike Moore
@blowmage
ActionController::TestCase is being deprecated, but controller tests remain. they will just use ActionDispatch::IntegrationTest now
Anton Trapp
@AntonTrapp
Thanks @blowmage - just joined this room and already the first useful information in the first entry :)
Mike Moore
@blowmage
👍
Sebastián
@sebastian-palma
Hi guys, I'm having a doubt using Minitest and Rails 5, when I try to test for a 404 response and I get a 200.
The differences is when I try with get /users/z which responds with 404, but when I do it with get users_path, params: { id: 'z' } I have a 200 response.
Mike Moore
@blowmage
¯(ツ)
Chris M
@CheezItMan
Just curious is there a way for Minitest-Rails to default to spec style tests on new rails apps
Mike Moore
@blowmage
there is a bug in minitest-rails-capybara. it should generate spec style tests by default, but its flipped. you can try configuring it in application.config.yaml
config.generators do |g|
g.test_framework :minitest, spec: true
end
Mike Moore
@blowmage
pushed 3.0.1 to fix the bug
Chris M
@CheezItMan
Thanks Mike, I'm not using capybara yet, but it still seems to generate:
class PostTest < ActiveSupport::TestCase
  # test "the truth" do
  #   assert true
  # end
end
Oleksandr T.
@a-tarasyuk

Minitest::Spec has let(:test) { } - is it the same as

def test
end

in Minitest::Unit?

Mike Moore
@blowmage
yes
Oleksandr T.
@a-tarasyuk
@blowmage thanks )
Nicholas
@nicholasshirley

Hi, I'm trying to test the deletion of an image associated with a user profile with Paperclip that is liked to an S3 bucket. I don't actually want the test to hit S3 though, is there a way to do this in Minitest?

Here is a SO post with the code that I've tried http://stackoverflow.com/questions/43760246/minitest-test-for-removing-paperclip-image-linked-to-s3-without-actually-upload

Mike Moore
@blowmage
Delegate the responsibility to hit S3 to something that your app owns, and then mock the call to it. If paperclip makes that too difficult, you can mock a call inside of paperclip, or try mocking the HTTP request.
Punita Ojha
@punitaojha
This message was deleted
Tessy Joseph John
@tessie
Hi I am getting : undefined method `get' in my test controller class
can some one help me
Mike Moore
@blowmage
That usually means it isn't recognized as a controller test
Tessy Joseph John
@tessie
oh.thanks
Tessy Joseph John
@tessie
That got fixed thanks @blowmage
Pete Doherty
@ethagnawl
Hello, all. Is it possible to disable the generation of controller tests via config? (e.g. config.generators/test_framework in config/application.rb) Minitest-rails appears to ignore my controller_specs false declaration.
Mike Moore
@blowmage
It is possible, but not something implemented yet
Would you like to add that?
Pete Doherty
@ethagnawl
ah, okay.
i'd be happy to take a look at implementing it. :)
Armin
@wuarmin
Hello, I have a basic minitest question: what's the minitest way of rspec's instance_double?
I have to mock, or stub external objects, but the problem is, that interface changes in the mocked objects won't attract attention. The tests pass, but the real implementation fails.
Mike Moore
@blowmage
minitest is designed intentionally to have very rudimentary implementations of mocks and stubs. see "Classical and Mockist Testing" here:
so you aren't going to get sophisticated implementations like rspec's instance_double in vanilla minitest. but you can use other mocking libraries like Mocha or even RSpec Mocks in minitest
i am a fan of rr myself
Armin
@wuarmin
Hey, thank you for the great information. Now I'm playing with rr:
    stub.proxy(MyClass).new(campaigns_id: 1, user: user) do |obj|
      # obj.respond_to?(:call).must_equal true # I need to call respond_to?, because otherwise test would pass, even if real MyClass-instances call method was renamed, removed, ...
      stub(obj).call { i_result }
    end
Armin
@wuarmin
Is there a way to achieve my goals?
@blowmage Thank You
Mike Moore
@blowmage
If your goal is to use rspec's instance_double with minitest, then I would use rspec-mocks:
Armin
@wuarmin
thank you @blowmage , but can you tell me why people should use double's without checking if they respond like their real correspondents?
The idea of having passing tests, but failing implementations because of test-doubles appears not really calming.
Mike Moore
@blowmage
I am not a mockist, so I can't defend that approach. What you are describing is why I avoid mocks as much as possible. It is a false positive. I prefer to test my implementation as much as possible. I am more of a classicalist tester. Bottom up instead of outside in.
Armin
@wuarmin
Ok, that sounds reasonable :smile: . I am of your opinion
Martin Streicher
@martinstreicher
h