cardiac 0.2.0.pre6 → 0.2.0.pre7

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,15 +8,15 @@ describe Cardiac::Model::Base do
8
8
  Class.new(Cardiac::Model::Base).class_eval do
9
9
  self.base_resource = 'http://localhost/dummy'
10
10
 
11
- attribute :id, type: Integer
12
- attribute :name, type: String
11
+ attribute :id, type: Integer
12
+ attribute :name, type: String
13
13
 
14
14
  def self.name; 'Dummy' end
15
15
 
16
16
  self
17
17
  end
18
18
  end
19
-
19
+
20
20
  subject { klass }
21
21
 
22
22
  describe '#base_resource' do
@@ -442,5 +442,6 @@ describe Cardiac::Model::Base do
442
442
  end
443
443
 
444
444
  it_behaves_like 'read-only models prohibit modification'
445
- end
445
+ end
446
+
446
447
  end
@@ -3,11 +3,13 @@ require 'spec_helper'
3
3
  describe Cardiac::OperationHandler do
4
4
 
5
5
  let(:resource) { Cardiac::Resource.new('http://google.com') }
6
- let(:client_options) { resource.send(:build_client_options) }
6
+ let(:payload) { }
7
7
  let(:client_handler) { }
8
8
 
9
9
  subject do
10
- described_class.new(client_options, nil, &client_handler)
10
+ handler = described_class.new(resource.send(:build_client_options), payload, &client_handler)
11
+ handler.config.update(resource.send(:build_config))
12
+ handler
11
13
  end
12
14
 
13
15
  include_context 'Client responses'
@@ -42,12 +44,28 @@ describe Cardiac::OperationHandler do
42
44
  before :example do
43
45
  allow_any_instance_of(Cardiac::OperationHandler).to receive(:perform_request){|_| raise Errno::ECONNREFUSED }
44
46
  resource.http_method(verb)
45
- expect{ subject.transmit! }.to raise_error
46
47
  end
47
48
 
48
- it { is_expected.not_to be_completed }
49
- it { is_expected.not_to be_transmitted }
50
- it { is_expected.to be_aborted }
49
+ describe 'that mock a response on connection errors' do
50
+ before :example do
51
+ resource.mock_response_on_connection_error = true
52
+ expect{ subject.transmit! }.not_to raise_error
53
+ end
54
+
55
+ it { is_expected.not_to be_transmitted }
56
+ it { is_expected.to be_completed }
57
+ it { is_expected.not_to be_aborted }
58
+ end
59
+
60
+ describe 'that raise connection errors' do
61
+ before :example do
62
+ resource.mock_response_on_connection_error = false
63
+ expect{ subject.transmit! }.to raise_error(Errno::ECONNREFUSED)
64
+ end
65
+ it { is_expected.not_to be_transmitted }
66
+ it { is_expected.not_to be_completed }
67
+ it { is_expected.to be_aborted }
68
+ end
51
69
  end
52
70
 
53
71
  describe 'GET' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cardiac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre6
4
+ version: 0.2.0.pre7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Khoobyar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake