interfax 0.2.1 → 1.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +0,0 @@
1
- module IncomingHelper
2
-
3
- INTERFAX_RESPONSE = {:messageID => '2011',
4
- :phoneNumber => '6145551212',
5
- :remoteCSID => '923459129349',
6
- :messageStatus => "0",
7
- :pages => '1',
8
- :messageSize => '58800',
9
- :messageType => "1",
10
- :receiveTime => "2011-01-01T09:08:11",
11
- :callerID => '8005556666',
12
- :messageRecordingDuration => "60"}
13
-
14
-
15
-
16
- class MockInterfaxResponse < Struct.new(:objMessageItem); end
17
- class ObjMessageItem < Struct.new(:messageItem); end
18
- class MessageItem < Struct.new(*INTERFAX_RESPONSE.keys); end
19
-
20
- def mock_getlist_response(count = 1)
21
- MockInterfaxResponse.new(ObjMessageItem.new([MessageItem.new(*INTERFAX_RESPONSE.values)]* count))
22
- end
23
- end
@@ -1,108 +0,0 @@
1
- require 'spec_helper'
2
- include IncomingHelper
3
-
4
- describe Interfax::Incoming do
5
-
6
- before(:each) do
7
- @client_mock = mock("SoapClient",
8
- :GetList => true,
9
- :GetImageChunk => true)
10
-
11
- Interfax::Incoming.stub!(:soap_client).and_return(@client_mock)
12
- end
13
-
14
- context "querying for incoming faxes" do
15
-
16
- it "should query for all messages" do
17
- Interfax::Incoming.should_receive(:query).with('AllMessages', anything())
18
- Interfax::Incoming.all
19
- end
20
-
21
- it "should query for unread messages" do
22
- Interfax::Incoming.should_receive(:query).with('NewMessages', anything())
23
- Interfax::Incoming.unread
24
- end
25
-
26
- it "should query for all users' unread messages" do
27
- Interfax::Incoming.should_receive(:query).with('AccountNewMessages', anything())
28
- Interfax::Incoming.account_unread
29
- end
30
-
31
- it "should query for all users' messages" do
32
- Interfax::Incoming.should_receive(:query).with('AccountAllMessages', anything())
33
- Interfax::Incoming.account_all
34
- end
35
-
36
- it "should respect the :limit argument over a class-defined limit" do
37
- @client_mock.should_receive(:GetList).with(hash_including(:MaxItems => 24))
38
- Interfax::Incoming.limit = 50
39
- Interfax::Incoming.all(:limit => 24)
40
- end
41
-
42
- it "should use the class-specified limit over the default" do
43
- @client_mock.should_receive(:GetList).with(hash_including(:MaxItems => 50))
44
- Interfax::Incoming.limit = 50
45
- Interfax::Incoming.all
46
- end
47
-
48
- it "should respect the :mark_as_read argument over the class-defined value" do
49
- @client_mock.should_receive(:GetList).with(hash_including(:MarkAsRead => true))
50
- Interfax::Incoming.mark_as_read = false
51
- Interfax::Incoming.all(:mark_as_read => true)
52
- end
53
-
54
- it "should use the class-specified mark_as_read over the default" do
55
- @client_mock.should_receive(:GetList).with(hash_including(:MarkAsRead => true))
56
- Interfax::Incoming.mark_as_read = true
57
- Interfax::Incoming.all
58
- end
59
-
60
-
61
- it "should return instances of the base class when called on the base class" do
62
- @client_mock.stub!(:GetList).and_return(mock_getlist_response)
63
- Interfax::Incoming.all[0].class.should == Interfax::Incoming
64
- end
65
-
66
- it "should return instances of the subclass when called on a subclass" do
67
- class TestFax < Interfax::Incoming; end
68
-
69
- @client_mock.
70
- stub!(:GetList).
71
- and_return(mock_getlist_response)
72
- TestFax.stub!(:soap_client).and_return(@client_mock)
73
-
74
- TestFax.all[0].class.should == TestFax
75
- end
76
-
77
- end
78
-
79
- context "fetching images" do
80
-
81
- before(:each) do
82
- details = mock_getlist_response.objMessageItem.messageItem[0]
83
- @fax = Interfax::Incoming.new(details)
84
- end
85
-
86
- it "should fetch the image when asked" do
87
- @client_mock.should_receive(:GetImageChunk).at_least(:once)
88
- @fax.image
89
- end
90
-
91
- it "should cache the image once received" do
92
- @client_mock.should_receive(:GetImageChunk).at_least(:once)
93
- @fax.image
94
- @client_mock.should_not_receive(:GetImageChunk)
95
- @fax.image
96
- end
97
-
98
- it "should respect the class-defined mark_as_read option" do
99
- Interfax::Incoming.mark_as_read = true
100
- @client_mock.should_receive(:GetImageChunk).with(hash_including(:MarkAsRead => true))
101
- @fax.image
102
- end
103
-
104
-
105
- end
106
-
107
- end
108
-
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Interfax" do
4
- it "fails" do
5
- pending "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color
data/spec/spec_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'interfax'
4
- require 'spec'
5
- require 'spec/autorun'
6
- require 'incoming_helper'
7
-
8
- Spec::Runner.configure do |config|
9
-
10
- end