Code Monkey home page Code Monkey logo

Comments (8)

dblock avatar dblock commented on June 21, 2024 1

If you're still having trouble, feel free to upload the project somewhere and I can try to help.

Either way this is 100% not a problem with the bot library, I'm going to close this for housekeeping, but feel free to add more questions and I'll do my best to answer.

from slack-ruby-bot.

dblock avatar dblock commented on June 21, 2024

I think the issue is simpler here. You are calling StartIntegrationTestsWorker.perform_async, which is a class method on StartIntegrationTestsWorker, not an instance method. The above expect_any_instance_of is expecting an instance, StartIntegrationTestsWorker.new, and so doesn't work.

The expect(StartIntegrationTestsWorker).to receive(:perform_async) version should work. Are you sure it does not?

from slack-ruby-bot.

dblock avatar dblock commented on June 21, 2024

The start_typing, and respond_with_slack_message and other rspec matchers setup a message handler/hook instance that in a real app is setup listening on slack's message events, and keep track of the client instance, so you don't have to.

from slack-ruby-bot.

dblock avatar dblock commented on June 21, 2024

Minor, but I don't remember if we handle commands with spaces, run tests. If it doesn't work try without?

from slack-ruby-bot.

CeeBeeUK avatar CeeBeeUK commented on June 21, 2024

I started with expect(StartIntegrationTestsWorker).to receive(:perform_async)
and have also tried expect(StartIntegrationTestsWorker).to receive(:perform) in case ruby magic was translating it internally!
Both fail with

(StartIntegrationTestsWorker (class)).perform(*(any args))
           expected: 1 time with any arguments
           received: 0 times with any arguments

This is actually working nicely in Slack!
gif-complete
If I take out the StartIntegrationTestsWorker line the start_typing(channel: 'channel') test passes fine 🤔
Thanks for the response and clarification, knowing that it should work, I'll keep playing!

Thanks for maintaining all these repos!

from slack-ruby-bot.

CeeBeeUK avatar CeeBeeUK commented on June 21, 2024

Hmm, looking at my other tests, I am using a different format

expect { perform }.to change(MonitorTestRunWorker.jobs, :size).by(1)

In the same tests

      it 'works?' do
        expect(MonitorTestRunWorker).to receive(:perform)
        perform
      end

fails.

Can I call message_send in a block?
failing, but something like

    it 'triggers the sidekiq job' do
      expect { SlackRubyBot::Hooks::Message.new(message: user_input, channel: 'channel') }
        .to change(MonitorTestRunWorker.jobs, :size).by(1)
    end

from slack-ruby-bot.

dblock avatar dblock commented on June 21, 2024

If I take out the StartIntegrationTestsWorker line the start_typing(channel: 'channel') test passes fine 🤔

Is this code valid at all? Add a puts above to see if it's called? Then wrap it in an exception handler, maybe there's a typo? :)

command 'run tests' do |client, data, _match|
  begin
        client.typing(channel: data.channel)
        StartIntegrationTestsWorker.perform_async(data)
  rescue Exception => e
      puts e
      raise
  end
end

See anything?

from slack-ruby-bot.

dblock avatar dblock commented on June 21, 2024

Can I call message_send in a block?
failing, but something like

    it 'triggers the sidekiq job' do
      expect { SlackRubyBot::Hooks::Message.new(message: user_input, channel: 'channel') }
        .to change(MonitorTestRunWorker.jobs, :size).by(1)
    end

yes you can

from slack-ruby-bot.

Related Issues (20)

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.