davidmann4 / botstack

rapid chatbot development with ruby on rails
127 stars 23 forks source link

rspec & bots - make bots testable #32

Open davidmann4 opened 7 years ago

davidmann4 commented 7 years ago

@pferdefleisch @ramonh
cc: @tosh

played around with rspec to make it possible to make tests.. now I wonder how we want to do this :)

https://github.com/davidmann4/botstack/blob/master/spec/bot_spec_helper.rb https://github.com/davidmann4/botstack/blob/master/spec/lib/basic_functionality_spec.rb

I guess we want to be able to test whole conversations? But on the other hand rspec maybe should just cover botstack mechanics?

really curious about your opinion...

davidmann4 commented 7 years ago

maybe something like


send_and_expect_answer "Hi bot!", "Hi Human!"
#or
send_text_expect_text "Hi bot!", "Hi Human!"
send_text_expect_image "Hi bot!", "http://host.com/img.png"
send_audio_expect_audio "http://host.com/img.mp3", "http://host.com/img.mp3"
mraaroncruz commented 7 years ago

I like that API.

There's also this for acceptance tests. It's an external server that runs your specs (written in javascript) and stands in as a fake Facebook to receive your outgoing messages. Pretty interesting route.

davidmann4 commented 7 years ago

hmm interesting - could it be auto started with bundle exec rspec ?

for now I use webmock --> https://github.com/davidmann4/botstack/commit/18ea589fe26637f79287a9c17a963f406fe1c958

mraaroncruz commented 7 years ago

You could write a wrapper or do something in the spec_helper to help it bootstrap, but that's not really the use case. The use case is that you write all your tests with that test library, in JavaScript. So it's likely not that interesting if you want to stick to Ruby (which you likely do and should).

Your solution fits more into the project. 👍