Guest User

Untitled

a guest
May 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. def foobar(options)
  2. if !options.is_a?(Hash) || options[:pdf].nil?
  3. return "fail"
  4. else
  5. return "pass"
  6. end
  7. end
  8.  
  9. describe "testing options" do
  10. it "should fail with nil" do
  11. a = foobar(nil)
  12. a.should == "fail"
  13. end
  14.  
  15. it "should fail with hash" do
  16. a = foobar({})
  17. a.should == "fail"
  18. end
  19.  
  20. it "should fail with nil key" do
  21. a = foobar({:pdf => nil})
  22. a.should == "fail"
  23. end
  24.  
  25. it "should pass with not-nil key" do
  26. a = foobar({:pdf => "not-nil"})
  27. a.should == "pass"
  28. end
  29.  
  30. end
Add Comment
Please, Sign In to add comment