-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
I have written an events spec in my project, similar to the ones in this projects, and when I run it I get the following error
Failure/Error: Team.create!(team)
NoMethodError:
undefined method `empty?' for #<Team _id: 65847bcb7fc2383892cb5523, created_at: 2023-12-21 17:54:19.206309 UTC, updated_at: 2023-12-21 17:54:19.206309 UTC, team_id: "T0", name: "minus", domain: nil, token: "abc-0", oauth_scope: nil, oauth_version: "v1", active: true, bot_user_id: nil, activated_user_id: nil, activated_user_access_token: nil>
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/attributes/processing.rb:20:in `process_attributes'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/document.rb:233:in `block in construct_document'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/threaded/lifecycle.rb:80:in `_building'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/document.rb:228:in `construct_document'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/document.rb:104:in `initialize'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/persistable/creatable.rb:172:in `new'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/persistable/creatable.rb:172:in `block in create!'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/threaded/lifecycle.rb:142:in `_creating'
# /Users/domster83/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mongoid-8.1.4/lib/mongoid/persistable/creatable.rb:168:in `create!'
# ./spec/events/events_link_shared_spec.rb:51:in `block (4 levels) in <main>'
And my spec
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'events/link_shared' do
include Rack::Test::Methods
def app
SlackRubyBotServer::Api::Middleware.instance
end
context 'without signature checks' do
before do
allow_any_instance_of(Slack::Events::Request).to receive(:verify!)
end
let!(:team) { Fabricate(:team) }
let(:event) do
{
token: SecureRandom.hex,
team_id: 'team_id',
api_app_id: 'AAAA',
event: {
type: 'link_shared',
user: 'user_id',
channel: 'C1',
message_ts: '1547842100.001400',
links: [{
url: "https://example.com",
domain: 'example.com
}]
},
type: 'event_callback',
event_id: 'EvFGTNRKLG',
event_time: 1_547_842_101,
authed_users: ['AAAA']
}
end
let(:user) do
{ user: { name: 'Bob' } }
end
let(:channel) do
{ channel: { name: 'random' } }
end
context 'with a named event handler' do
before do
Team.create!(team)
end
it 'posts System Data blocks' do
system_blocks = get_blocks(event[:event][:links][0][:url])
# expect_any_instance_of(Slack::Web::Client).to receive(:chat_postMessage).with(
# channel: 'channel_id', text: 'Welcome Bob to random!'
# )
post '/api/slack/event', event
expect(last_response.status).to eq 201
expect(JSON.parse(last_response.body)).to eq(system_blocks.to_slack_blocks.to_json)
end
end
end
end
Any help appreciated
Metadata
Metadata
Assignees
Labels
No labels