spec/lib/pushover/pushover_spec.rb in pushover-0.5.0 vs spec/lib/pushover/pushover_spec.rb in pushover-0.5.1

- old
+ new

@@ -1,5 +1,48 @@ -require 'pushover' +require 'spec_helper' describe "Pushover" do - it "can send a notification" + before :each do + App.current_app = nil + User.current_user = nil + Pushover.clear + end + + describe "#clear" do + it "will erase all the attributes in Pushover" do + Pushover.send("#{keys.first}=", "something") + Pushover.clear + parameters.each {|k,v| v.should be_nil} + end + end + + describe "#parameters?" do + it 'will return true only if every key is set to something.' do + keys.each {|k| Pushover.send("#{k}=", 'ladeda')} + parameters?.should eq true + end + it 'will return false otherwise.' do + Pushover.send("#{keys.first}=", "something") + parameters?.should eq false + end + end + + describe "#configure" do + Pushover.keys.each do |key| + it "#{key} can be configured via .configure" do + r = "acdfef" + Pushover.configure do |c| + c.instance_variable_set "@#{key}", r + end + Pushover.send(key).should eq r + end + end + end + + describe "#notification" do + it "can send a notification" do + setup_webmocks + resp = Pushover.notification message:'a message', token:'good_token', user:'good_user' + resp.code.should eq "200" + end + end end