itunes_store_transporter 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,20 +7,36 @@ describe ITunes::Store::Transporter::OutputParser do
7
7
  context "without an error code" do
8
8
  before(:all) { @parser = described_class.new(fixture("errors_and_warnings.no_error_number")) }
9
9
 
10
- subject { @parser }
11
- its(:warnings) { should be_empty }
12
- its(:errors) { should have(2).items }
10
+ it "has no warnings" do
11
+ expect(@parser.warnings).to be_empty
12
+ end
13
+
14
+ it "has two errors" do
15
+ expect(@parser.errors.size).to eq 2
16
+ end
13
17
 
14
18
  describe "the first error" do
15
- subject { @parser.errors.first }
16
- its(:code) { should be_nil }
17
- its(:message) { should == "An error occurred while doing fun stuff" }
19
+ before { @error = @parser.errors[0] }
20
+
21
+ it "has a nil code" do
22
+ expect(@error.code).to be_nil
23
+ end
24
+
25
+ it "has the right error message" do
26
+ expect(@error.message).to eq "An error occurred while doing fun stuff"
27
+ end
18
28
  end
19
29
 
20
30
  describe "the second error" do
21
- subject { @parser.errors.last }
22
- its(:code) { should be_nil }
23
- its(:message) { should == "An exception has occurred: network timeout" }
31
+ before { @error = @parser.errors[1] }
32
+
33
+ it "has a nil code" do
34
+ expect(@error.code).to be_nil
35
+ end
36
+
37
+ it "has the right error message" do
38
+ expect(@error.message).to eq "An exception has occurred: network timeout"
39
+ end
24
40
  end
25
41
  end
26
42
 
@@ -32,12 +32,12 @@ describe ITunes::Store::Transporter::Shell do
32
32
  output << [ stream, line.chomp! ]
33
33
  end
34
34
 
35
- output.should == expect
35
+ expect(output).to eq expect
36
36
  end
37
37
 
38
38
  describe "#exec" do
39
39
  it "requires a block" do
40
- lambda { described_class.new.exec([]) }.should raise_exception(ArgumentError, "block required")
40
+ expect { described_class.new.exec([]) }.to raise_exception(ArgumentError, "block required")
41
41
  end
42
42
  end
43
43
 
@@ -45,32 +45,37 @@ describe ITunes::Store::Transporter::Shell do
45
45
  before(:all) { ENV["PROGRAMFILES"] = "C:\\" }
46
46
 
47
47
  it "selects the Windows executable" do
48
- described_class.stub(:windows? => true, :osx? => false)
49
- described_class.new.path.should match /#{described_class::WINDOWS_EXE}\Z/
48
+ allow(described_class).to receive(:windows?).and_return(true)
49
+ allow(described_class).to receive(:osx?).and_return(false)
50
+ expect(described_class.new.path).to match /#{described_class::WINDOWS_EXE}\z/
50
51
  end
51
52
  end
52
53
 
53
54
  context "when on OS X" do
54
- before { described_class.stub(:windows? => false, :osx? => true) }
55
+ before do
56
+ allow(described_class).to receive(:windows?).and_return(false)
57
+ allow(described_class).to receive(:osx?).and_return(true)
58
+ end
55
59
 
56
60
  it "selects the right executable" do
57
- exe = described_class::DEFAULT_OSX_PATHS.first
58
- File.stub(:exist? => true)
59
- described_class.new.path.should == exe
61
+ exe = described_class::OSX_APPLICATION_LOADER_PATHS.first
62
+ allow(File).to receive(:exist?).and_return(true)
63
+ expect(described_class.new.path).to eq exe
60
64
  end
61
65
 
62
66
  context "and no OS X specific executable is found" do
63
67
  it "defaults to the *nix executable" do
64
- File.stub(:exist? => false)
65
- described_class.new.path.should match /#{described_class::DEFAULT_UNIX_PATH}\Z/
68
+ allow(File).to receive(:exist?).and_return(false)
69
+ expect(described_class.new.path).to eq described_class::DEFAULT_UNIX_PATH
66
70
  end
67
71
  end
68
72
  end
69
73
 
70
74
  context "when not on Windows or OS X" do
71
75
  it "selects the right executable" do
72
- described_class.stub(:windows? => false, :osx? => false)
73
- described_class.new.path.should match /#{described_class::EXE_NAME}\Z/
76
+ allow(described_class).to receive(:windows?).and_return(false)
77
+ allow(described_class).to receive(:osx?).and_return(false)
78
+ expect(described_class.new.path).to match /#{described_class::EXE_NAME}\z/
74
79
  end
75
80
  end
76
81
  end
@@ -16,7 +16,17 @@ module SpecHelper
16
16
  end
17
17
 
18
18
  def expect_shell_args(*expected)
19
- ITunes::Store::Transporter::Shell.any_instance.should_receive(:exec) { |*arg| arg.first.should include(*expected); 0 }
19
+ output = expected.last.is_a?(Hash) ? expected.pop : {}
20
+ ITunes::Store::Transporter::Shell.any_instance.should_receive(:exec) do |*args, &block|
21
+ expect(args.first).to include(*expected)
22
+
23
+ [:stdout, :stderr].each do |fd|
24
+ next unless output[fd]
25
+ output[fd].each { |line| block.call(line, fd) }
26
+ end
27
+
28
+ 0
29
+ end
20
30
  end
21
31
 
22
32
  def fixture(path)
@@ -32,6 +42,7 @@ module SpecHelper
32
42
  [:stderr, :stdout].each do |fd|
33
43
  fixture = options[fd]
34
44
  next unless fixture
45
+
35
46
  lines = Array === fixture ? fixture : Fixture.for(fixture)
36
47
  outputs << [ lines, fd ]
37
48
  end
@@ -79,8 +79,27 @@ describe ITunes::Store::Transporter::ITMSTransporter do
79
79
  describe "#status" do
80
80
  let(:method) { :status }
81
81
  let(:command) { "Status" }
82
+ let(:status) { double("status command") }
82
83
 
83
84
  it_behaves_like "a transporter method without a package argument"
85
+
86
+ context "when given :all => true" do
87
+ it "runs the status all command" do
88
+ expect(ITunes::Store::Transporter::Command::StatusAll).to receive(:new).and_return(status)
89
+ expect(status).to receive(:run)
90
+
91
+ subject.status(:all => true)
92
+ end
93
+ end
94
+
95
+ context "when given :all => false" do
96
+ it "runs the status command" do
97
+ expect(ITunes::Store::Transporter::Command::Status).to receive(:new).and_return(status)
98
+ expect(status).to receive(:run)
99
+
100
+ subject.status(:all => false)
101
+ end
102
+ end
84
103
  end
85
104
 
86
105
  describe "#upload" do
@@ -0,0 +1,60 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ITunes::Store::Transporter::XML::Status do
4
+ context "given a valid XML doc with a single status" do
5
+ it "returns a Hash with a single status" do
6
+ status = described_class.new.parse(fixture("status.vendor_id_123123").join(""))
7
+ expect(status).to eq [{:apple_id=>"X9123X",
8
+ :vendor_id=>"123123",
9
+ :content_status=>
10
+ {:status=>"Unpolished",
11
+ :review_status=>"Ready-NotReviewed",
12
+ :itunes_connect_status=>"Other",
13
+ :store_status=>
14
+ {:not_on_store=>[], :on_store=>[], :ready_for_store=>["US"]},
15
+ :video_components=>
16
+ [{:name=>"Video",
17
+ :locale=>nil,
18
+ :status=>"In Review",
19
+ :delivered=>"2011-11-30 01:41:10"},
20
+ {:name=>"Audio",
21
+ :locale=>"en-US",
22
+ :status=>"In Review",
23
+ :delivered=>"2011-11-30 01:41:10"}]},
24
+ :info=>[{:created=>"2016-11-25 10:38:09", :status=>"Imported"}]}]
25
+
26
+ end
27
+ end
28
+
29
+ context "given an invalid XML doc" do
30
+ it "raises a ParseError" do
31
+ expect {
32
+ described_class.new.parse("<>")
33
+ # Comment out to satisfy 1.9.3, it results in an "not well-formed" error
34
+ #}.to raise_error( ITunes::Store::Transporter::ParseError, /invalid xml/i)
35
+ }.to raise_error(ITunes::Store::Transporter::ParseError)
36
+ end
37
+ end
38
+
39
+ context "given an XML doc that's not well-formed" do
40
+ it "raises a ParseError" do
41
+ expect {
42
+ described_class.new.parse("<a><b></a>")
43
+ }.to raise_error(ITunes::Store::Transporter::ParseError, /not well-formed/i)
44
+ end
45
+ end
46
+
47
+ context "given an XML doc that contains an error message" do
48
+ it "raises a ExecutionError containing the message and its code" do
49
+ expect {
50
+ described_class.new.parse(fixture("status.error_message").join("\n"))
51
+ }.to raise_error(ITunes::Store::Transporter::ExecutionError) { |e|
52
+ expect(e.errors.size).to eq 2
53
+ expect(e.errors[0].message).to eq "Error message one."
54
+ expect(e.errors[0].code).to eq -1234
55
+ expect(e.errors[1].message).to eq "Error message two."
56
+ expect(e.errors[1].code).to eq 9999
57
+ }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe ITunes::Store::Transporter::XML::Status do
4
+ context "given a valid XML doc with a single status" do
5
+ it "returns a Hash with a single status" do
6
+
7
+ end
8
+
9
+ end
10
+
11
+ context "given a valid XML doc with multiple statuses" do
12
+ it "returns a Hash with multiple statuses" do
13
+
14
+ end
15
+ end
16
+
17
+ context "given an XML invalid XML doc" do
18
+ it "raises a ParseError" do
19
+
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itunes_store_transporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: childprocess
@@ -93,6 +93,7 @@ files:
93
93
  - lib/itunes/store/transporter/command/providers.rb
94
94
  - lib/itunes/store/transporter/command/schema.rb
95
95
  - lib/itunes/store/transporter/command/status.rb
96
+ - lib/itunes/store/transporter/command/status_all.rb
96
97
  - lib/itunes/store/transporter/command/upload.rb
97
98
  - lib/itunes/store/transporter/command/verify.rb
98
99
  - lib/itunes/store/transporter/command/version.rb
@@ -101,6 +102,7 @@ files:
101
102
  - lib/itunes/store/transporter/output_parser.rb
102
103
  - lib/itunes/store/transporter/shell.rb
103
104
  - lib/itunes/store/transporter/version.rb
105
+ - lib/itunes/store/transporter/xml/status.rb
104
106
  - spec/command_spec.rb
105
107
  - spec/errors_spec.rb
106
108
  - spec/fixtures/errors_and_warnings.yml
@@ -112,6 +114,8 @@ files:
112
114
  - spec/shell_spec.rb
113
115
  - spec/spec_helper.rb
114
116
  - spec/transporter_spec.rb
117
+ - spec/xml_status_spec.rb
118
+ - spec/xml_status_spec.rb~
115
119
  homepage: http://github.com/sshaw/itunes_store_transporter
116
120
  licenses:
117
121
  - MIT
@@ -136,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
140
  version: '0'
137
141
  requirements: []
138
142
  rubyforge_project:
139
- rubygems_version: 2.4.3
143
+ rubygems_version: 2.4.8
140
144
  signing_key:
141
145
  specification_version: 4
142
146
  summary: Upload and manage your assets in the iTunes Store using the iTunes Store's
@@ -153,3 +157,5 @@ test_files:
153
157
  - spec/shell_spec.rb
154
158
  - spec/spec_helper.rb
155
159
  - spec/transporter_spec.rb
160
+ - spec/xml_status_spec.rb
161
+ - spec/xml_status_spec.rb~