From a40a01921f06ec22a65fef019d145a59f8fbb833 Mon Sep 17 00:00:00 2001 From: EdwinRozario Date: Wed, 7 Jan 2015 10:20:17 +1300 Subject: [PATCH 1/4] Fixing/Adding specs --- .ruby-version | 2 +- spec/lib/pushmeup_spec.rb | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.ruby-version b/.ruby-version index 67b8bc0..7ec1d6d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-1.9.3 +2.1.0 diff --git a/spec/lib/pushmeup_spec.rb b/spec/lib/pushmeup_spec.rb index 80264af..bc29c59 100644 --- a/spec/lib/pushmeup_spec.rb +++ b/spec/lib/pushmeup_spec.rb @@ -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 @@ -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 @@ -42,27 +51,27 @@ 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 From e1533ed67c09198e6f782644044e707e2a07ae04 Mon Sep 17 00:00:00 2001 From: EdwinRozario Date: Wed, 7 Jan 2015 10:27:50 +1300 Subject: [PATCH 2/4] More specs for GCM --- Gemfile | 1 + spec/lib/pushmeup_spec.rb | 12 ++++++++++++ spec/spec_helper.rb | 1 + 3 files changed, 14 insertions(+) diff --git a/Gemfile b/Gemfile index 080e0be..2cf81f6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ source 'https://rubygems.org' +gem 'pry' # Specify your gem's dependencies in pushmeup.gemspec gemspec diff --git a/spec/lib/pushmeup_spec.rb b/spec/lib/pushmeup_spec.rb index bc29c59..5ee51bf 100644 --- a/spec/lib/pushmeup_spec.rb +++ b/spec/lib/pushmeup_spec.rb @@ -49,6 +49,18 @@ @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_truthy diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c78a9ab..ba0e379 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1 +1,2 @@ require 'pushmeup' +require 'pry' \ No newline at end of file From a780298c62ce5957da88d91467a0cc60c08355dd Mon Sep 17 00:00:00 2001 From: EdwinRozario Date: Wed, 7 Jan 2015 10:32:00 +1300 Subject: [PATCH 3/4] Changing ruby version from 2.1.0 to 1.9.3-p547. Specs succeeded in both versions. Removing pry from Gemfile --- .ruby-version | 2 +- Gemfile | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.ruby-version b/.ruby-version index 7ec1d6d..75bfecd 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.1.0 +1.9.3-p547 diff --git a/Gemfile b/Gemfile index 2cf81f6..080e0be 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,4 @@ source 'https://rubygems.org' -gem 'pry' # Specify your gem's dependencies in pushmeup.gemspec gemspec From 64ddbe77764a85a772127024c42a6a7a5c9c0c27 Mon Sep 17 00:00:00 2001 From: EdwinRozario Date: Wed, 7 Jan 2015 10:34:05 +1300 Subject: [PATCH 4/4] removing pry from spec_helper --- spec/spec_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ba0e379..4966df8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,2 +1 @@ -require 'pushmeup' -require 'pry' \ No newline at end of file +require 'pushmeup' \ No newline at end of file