Guest User

Untitled

a guest
Jul 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. $:.unshift(File.expand_path('../../../lib',__FILE__))
  2. require 'embedly'
  3.  
  4. Given /an embedly endpoint( [^\s]+)?( with ([^\s]+) key)?$/ do |endpoint, _, key|
  5. opts = {}
  6. opts[:endpoint] = endpoint
  7. opts[:key] = key
  8. @api = Embedly::API.new opts
  9. end
  10.  
  11. When /oembed is called with the (.*) URLs?( and ([^\s]+) flag)?$/ do |urls, _, flag|
  12. urls = urls.split(',')
  13. opts = {}
  14. if urls.size == 1
  15. opts[:url] = urls.first
  16. else
  17. opts[:urls] = urls
  18. end
  19. opts[flag.to_sym] = true if flag
  20. @result = @api.oembed opts
  21. end
  22.  
  23. Then /([^\s]+) should be ([^\s]+)/ do |key, value|
  24. if @result.is_a?Array
  25. @result.collect{|o| o.send(key).to_s}.join(',').should == value
  26. else
  27. @result.send(key).to_s.should == value
  28. end
  29. end
Add Comment
Please, Sign In to add comment