Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing/Adding Spec #54

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-1.9.3
1.9.3-p547
45 changes: 33 additions & 12 deletions spec/lib/pushmeup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@
describe Pushmeup do
describe "APNS" do
it "should have a APNS object" do
defined?(APNS).should_not be_false
defined?(APNS).should_not be_nil
end

it "should not forget the APNS default parameters" do
APNS.host.should == "gateway.sandbox.push.apple.com"
APNS.port.should == 2195
it "should have gateway.sandbox.push.apple.com as default host" do
APNS.host.eql?("gateway.sandbox.push.apple.com").should be_truthy
end

it "should have 2195 as default port" do
APNS.port.eql?(2195).should be_truthy
end

it "should have nil pem by default" do
APNS.pem.should be_equal(nil)
APNS.pass.should be_equal(nil)
end

it "should have nil password by default" do
APNS.pass.should be_equal(nil)
end

describe "Notifications" do

describe "#==" do
Expand All @@ -31,7 +40,7 @@

describe "GCM" do
it "should have a GCM object" do
defined?(GCM).should_not be_false
defined?(GCM).should_not be_nil
end

describe "Notifications" do
Expand All @@ -40,29 +49,41 @@
@options = {:data => "dummy data"}
end

it "should have https://android.googleapis.com/gcm/send as host by default" do
GCM.host.eql?("https://android.googleapis.com/gcm/send").should be_truthy
end

it "should have json as format by default" do
GCM.format.eql?(:json).should be_truthy
end

it "should have nil key by default" do
GCM.key.should be_equal(nil)
end

it "should allow only notifications with device_tokens as array" do
n = GCM::Notification.new("id", @options)
n.device_tokens.is_a?(Array).should be_true
n.device_tokens.is_a?(Array).should be_truthy

n.device_tokens = ["a" "b", "c"]
n.device_tokens.is_a?(Array).should be_true
n.device_tokens.is_a?(Array).should be_truthy

n.device_tokens = "a"
n.device_tokens.is_a?(Array).should be_true
n.device_tokens.is_a?(Array).should be_truthy
end

it "should allow only notifications with data as hash with :data root" do
n = GCM::Notification.new("id", { :data => "data" })

n.data.is_a?(Hash).should be_true
n.data.is_a?(Hash).should be_truthy
n.data.should == {:data => "data"}

n.data = {:a => ["a", "b", "c"]}
n.data.is_a?(Hash).should be_true
n.data.is_a?(Hash).should be_truthy
n.data.should == {:a => ["a", "b", "c"]}

n.data = {:a => "a"}
n.data.is_a?(Hash).should be_true
n.data.is_a?(Hash).should be_truthy
n.data.should == {:a => "a"}
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require 'pushmeup'
require 'pushmeup'