stockboy 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/stockboy/providers/soap.rb +2 -0
  4. data/lib/stockboy/version.rb +1 -1
  5. data/spec/stockboy/attribute_map_spec.rb +10 -10
  6. data/spec/stockboy/attribute_spec.rb +7 -7
  7. data/spec/stockboy/candidate_record_spec.rb +18 -18
  8. data/spec/stockboy/configuration_spec.rb +4 -4
  9. data/spec/stockboy/configurator_spec.rb +24 -24
  10. data/spec/stockboy/filter_chain_spec.rb +4 -4
  11. data/spec/stockboy/filter_spec.rb +4 -4
  12. data/spec/stockboy/filters/missing_email_spec.rb +4 -4
  13. data/spec/stockboy/filters_spec.rb +4 -4
  14. data/spec/stockboy/job_spec.rb +24 -24
  15. data/spec/stockboy/mapped_record_spec.rb +5 -4
  16. data/spec/stockboy/provider_repeater_spec.rb +2 -2
  17. data/spec/stockboy/provider_spec.rb +3 -3
  18. data/spec/stockboy/providers/file_spec.rb +20 -20
  19. data/spec/stockboy/providers/ftp_spec.rb +20 -20
  20. data/spec/stockboy/providers/http_spec.rb +28 -28
  21. data/spec/stockboy/providers/imap/search_options_spec.rb +11 -11
  22. data/spec/stockboy/providers/imap_spec.rb +23 -23
  23. data/spec/stockboy/providers/soap_spec.rb +17 -17
  24. data/spec/stockboy/providers_spec.rb +4 -4
  25. data/spec/stockboy/readers/csv_spec.rb +13 -9
  26. data/spec/stockboy/readers/fixed_width_spec.rb +6 -6
  27. data/spec/stockboy/readers/json_spec.rb +1 -1
  28. data/spec/stockboy/readers/spreadsheet_spec.rb +15 -15
  29. data/spec/stockboy/readers/xml_spec.rb +12 -12
  30. data/spec/stockboy/readers_spec.rb +3 -3
  31. data/spec/stockboy/source_record_spec.rb +2 -2
  32. data/spec/stockboy/template_file_spec.rb +3 -3
  33. data/spec/stockboy/translations/boolean_spec.rb +1 -1
  34. data/spec/stockboy/translations/date_spec.rb +5 -5
  35. data/spec/stockboy/translations/decimal_spec.rb +3 -3
  36. data/spec/stockboy/translations/default_empty_string_spec.rb +4 -4
  37. data/spec/stockboy/translations/default_false_spec.rb +1 -1
  38. data/spec/stockboy/translations/default_nil_spec.rb +4 -4
  39. data/spec/stockboy/translations/default_true_spec.rb +1 -1
  40. data/spec/stockboy/translations/default_zero_spec.rb +4 -4
  41. data/spec/stockboy/translations/integer_spec.rb +2 -2
  42. data/spec/stockboy/translations/string_spec.rb +2 -2
  43. data/spec/stockboy/translations/time_spec.rb +3 -3
  44. data/spec/stockboy/translations/uk_date_spec.rb +5 -5
  45. data/spec/stockboy/translations/us_date_spec.rb +5 -5
  46. data/spec/stockboy/translations_spec.rb +9 -9
  47. data/spec/stockboy/translator_spec.rb +2 -2
  48. data/stockboy.gemspec +1 -1
  49. metadata +4 -4
@@ -8,21 +8,21 @@ module Stockboy
8
8
 
9
9
  describe ".register" do
10
10
  it "registers a key and class" do
11
- Providers.register(:snailmail, provider).should be provider
11
+ expect(Providers.register(:snailmail, provider)).to be provider
12
12
  end
13
13
  end
14
14
 
15
15
  describe ".find" do
16
16
  it "returns a provider class" do
17
17
  Providers.register(:snailmail, provider)
18
- Providers.find(:snailmail).should be provider
18
+ expect(Providers.find(:snailmail)).to be provider
19
19
  end
20
20
  end
21
21
 
22
22
  describe ".[]" do
23
23
  it "returns a provider class" do
24
24
  Providers.register(:snailmail, provider)
25
- Providers[:snailmail].should be provider
25
+ expect(Providers[:snailmail]).to be provider
26
26
  end
27
27
  end
28
28
 
@@ -30,7 +30,7 @@ module Stockboy
30
30
  it "returns all registered providers" do
31
31
  Providers.register(:snailmail, provider)
32
32
  Providers.register(:slugmail, provider)
33
- Providers.all.should include(snailmail: provider, slugmail: provider)
33
+ expect(Providers.all).to include(snailmail: provider, slugmail: provider)
34
34
  end
35
35
  end
36
36
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'stockboy/readers/csv'
3
5
 
@@ -18,7 +20,7 @@ module Stockboy
18
20
  describe "initialize" do
19
21
  it "configures options with argument hash" do
20
22
  reader = Readers::CSV.new(col_sep: '|')
21
- reader.col_sep.should == '|'
23
+ expect(reader.col_sep).to eq '|'
22
24
  end
23
25
 
24
26
  it "configures options with a block" do
@@ -29,9 +31,9 @@ module Stockboy
29
31
  skip_footer_rows 1
30
32
  end
31
33
 
32
- reader.col_sep.should == '|'
33
- reader.skip_header_rows.should == 2
34
- reader.skip_footer_rows.should == 1
34
+ expect(reader.col_sep).to eq '|'
35
+ expect(reader.skip_header_rows).to eq 2
36
+ expect(reader.skip_footer_rows).to eq 1
35
37
  end
36
38
  end
37
39
 
@@ -39,7 +41,7 @@ module Stockboy
39
41
  it "returns an array of records" do
40
42
  records = reader.parse "id,name\n42,Arthur Dent"
41
43
 
42
- records[0].should == {"id" => "42", "name" => "Arthur Dent"}
44
+ expect(records[0]).to eq({"id" => "42", "name" => "Arthur Dent"})
43
45
  end
44
46
 
45
47
  it "strips null bytes from empty fields (MSSQL BCP exports)" do
@@ -47,8 +49,9 @@ module Stockboy
47
49
  reader.headers = %w[city state country]
48
50
  records = reader.parse "Vancouver|\x00|Canada"
49
51
 
50
- records.should ==
52
+ expect(records).to eq(
51
53
  [{"city" => "Vancouver", "state" => nil, "country" => "Canada"}]
54
+ )
52
55
  end
53
56
 
54
57
  it "scrubs invalid encoding characters in Unicode" do
@@ -56,8 +59,9 @@ module Stockboy
56
59
  reader.encoding = 'UTF-8'
57
60
  garbage = 191.chr.force_encoding('UTF-8')
58
61
  data = "Z#{garbage}rich,Genève"
59
- reader.parse(data).should ==
62
+ expect(reader.parse(data)).to eq(
60
63
  [{"depart" => "Z\u{FFFD}rich", "arrive" => "Genève"}]
64
+ )
61
65
  end
62
66
 
63
67
  it "strips preamble header rows" do
@@ -65,12 +69,12 @@ module Stockboy
65
69
  data = "IGNORE\r\nCOMMENTS\r\nid,name\r\n42,Arthur Dent"
66
70
  records = reader.parse data
67
71
 
68
- records[0].should == {"id" => "42", "name" => "Arthur Dent"}
72
+ expect(records[0]).to eq({"id" => "42", "name" => "Arthur Dent"})
69
73
  end
70
74
 
71
75
  it "shares hash key instances between records" do
72
76
  records = reader.parse "id,name\n42,Arthur Dent\n999,Zaphod"
73
- records[0].keys[0].should be records[1].keys[0]
77
+ expect(records[0].keys[0]).to be records[1].keys[0]
74
78
  end
75
79
  end
76
80
  end
@@ -13,7 +13,7 @@ module Stockboy
13
13
 
14
14
  it "parses based on column widths" do
15
15
  reader = described_class.new(headers: [10, 10, 4, 2, 10])
16
- reader.parse(data).should == [
16
+ expect(reader.parse(data)).to eq [
17
17
  {0 => "Arthur", 1 => "Dent", 2 => "42", 3 => "M", 4 => "Human"},
18
18
  {0 => "Ford", 1 => "Prefect", 2 => "44", 3 => "M", 4 => "Betelgeuse"}
19
19
  ]
@@ -21,7 +21,7 @@ module Stockboy
21
21
 
22
22
  it "parses based on a hash" do
23
23
  reader = described_class.new(headers: headers_hash)
24
- reader.parse(data).should == [
24
+ expect(reader.parse(data)).to eq [
25
25
  {first: "Arthur", last: "Dent", age: "42", sex: "M", planet: "Human"},
26
26
  {first: "Ford", last: "Prefect", age: "44", sex: "M", planet: "Betelgeuse"}
27
27
  ]
@@ -30,22 +30,22 @@ module Stockboy
30
30
  it "skips blank rows" do
31
31
  reader = described_class.new(headers: headers_hash)
32
32
  records = reader.parse(blank_row + data + blank_row)
33
- records.first[:age].should == '42'
34
- records.last[:age].should == '44'
33
+ expect(records.first[:age]).to eq '42'
34
+ expect(records.last[:age]).to eq '44'
35
35
  end
36
36
 
37
37
  it "skips number of specified header rows" do
38
38
  reader = described_class.new(headers: headers_hash)
39
39
  reader.skip_header_rows = 1
40
40
  records = reader.parse("REPORT\r\n" + data)
41
- records.first[:age].should == '42'
41
+ expect(records.first[:age]).to eq '42'
42
42
  end
43
43
 
44
44
  it "skips number of specified footer rows" do
45
45
  reader = described_class.new(headers: headers_hash)
46
46
  reader.skip_footer_rows = 2
47
47
  records = reader.parse(data + "SUBTOTAL\r\nTOTAL\r\n")
48
- records.last[:age].should == '44'
48
+ expect(records.last[:age]).to eq '44'
49
49
  end
50
50
 
51
51
  end
@@ -10,7 +10,7 @@ module Stockboy
10
10
  it "returns an array of records" do
11
11
  records = reader.parse '{"id": "42", "name": "Arthur Dent"}'
12
12
 
13
- records.should == {"id" => "42", "name" => "Arthur Dent"}
13
+ expect(records).to eq({"id" => "42", "name" => "Arthur Dent"})
14
14
  end
15
15
 
16
16
  end
@@ -21,10 +21,10 @@ module Stockboy
21
21
  headers: %w(X Y Z)
22
22
  )
23
23
 
24
- reader.format.should == :xlsx
25
- reader.sheet.should == 'Sheet 42'
26
- reader.header_row.should == 5
27
- reader.headers.should == %w(X Y Z)
24
+ expect(reader.format).to eq :xlsx
25
+ expect(reader.sheet).to eq 'Sheet 42'
26
+ expect(reader.header_row).to eq 5
27
+ expect(reader.headers).to eq %w(X Y Z)
28
28
  end
29
29
 
30
30
  it "configures with a block" do
@@ -35,10 +35,10 @@ module Stockboy
35
35
  headers %w(X Y Z)
36
36
  end
37
37
 
38
- reader.format.should == :xlsx
39
- reader.sheet.should == 'Sheet 42'
40
- reader.header_row.should == 5
41
- reader.headers.should == %w(X Y Z)
38
+ expect(reader.format).to eq :xlsx
39
+ expect(reader.sheet).to eq 'Sheet 42'
40
+ expect(reader.header_row).to eq 5
41
+ expect(reader.headers).to eq %w(X Y Z)
42
42
  end
43
43
  end
44
44
 
@@ -52,8 +52,8 @@ module Stockboy
52
52
  reader = described_class.new(format: :xls)
53
53
  data = reader.parse(content)
54
54
 
55
- data.should_not be_empty
56
- data.each { |i| i.should be_a Hash }
55
+ expect(data).not_to be_empty
56
+ data.each { |i| expect(i).to be_a Hash }
57
57
  end
58
58
  end
59
59
 
@@ -64,30 +64,30 @@ module Stockboy
64
64
  reader = described_class.new(format: :xls, first_row: 6)
65
65
  data = reader.parse(content)
66
66
 
67
- data.first.values.should == ["Arthur Dent", 42]
67
+ expect(data.first.values).to eq ["Arthur Dent", 42]
68
68
  end
69
69
 
70
70
  it "ends on the given last row counting backwards" do
71
71
  reader = described_class.new(format: :xls, last_row: -3)
72
72
  data = reader.parse(content)
73
73
 
74
- data.last.values.should == ["Marvin", 9999999]
74
+ expect(data.last.values).to eq ["Marvin", 9999999]
75
75
  end
76
76
 
77
77
  it "ends on the given last row counting upwards" do
78
78
  reader = described_class.new(format: :xls, last_row: 9)
79
79
  data = reader.parse(content)
80
80
 
81
- data.last.values.should == ["Ford", 40]
81
+ expect(data.last.values).to eq ["Ford", 40]
82
82
  end
83
83
  end
84
84
  end
85
85
 
86
- describe "#sheet", pending: "Hard to test this due to roo. Needs a test case with fixtures" do
86
+ describe "#sheet", skip: "Hard to test this due to roo. Needs a test case with fixtures" do
87
87
  let(:sheets) { ['Towels', 'Lemons'] }
88
88
  let(:be_selected) { receive(:default_sheet=) }
89
89
  let(:spreadsheet) { double(:spreadsheet, sheets: sheets) }
90
- before { subject.stub!(:with_spreadsheet).and_yield(spreadsheet) }
90
+ before { allow(subject).to receive(:with_spreadsheet).and_yield(spreadsheet) }
91
91
 
92
92
  context "with :first" do
93
93
  before { expect(spreadsheet).to be_selected.with('Towels') }
@@ -15,11 +15,11 @@ module Stockboy
15
15
  elements: ['SomeNested', 'Record']
16
16
  )
17
17
 
18
- reader.options[:strip_namespaces].should be true
19
- reader.options[:advanced_typecasting].should be true
20
- reader.options[:convert_tags_to].should be_a Proc
21
- reader.options[:parser].should == :nokogiri
22
- reader.elements.should == ['some_nested', 'record']
18
+ expect(reader.options[:strip_namespaces]).to be true
19
+ expect(reader.options[:advanced_typecasting]).to be true
20
+ expect(reader.options[:convert_tags_to]).to be_a Proc
21
+ expect(reader.options[:parser]).to eq :nokogiri
22
+ expect(reader.elements).to eq ['some_nested', 'record']
23
23
  end
24
24
 
25
25
  it "configures with a block" do
@@ -32,11 +32,11 @@ module Stockboy
32
32
  elements ['SomeNested', 'Record']
33
33
  end
34
34
 
35
- reader.options[:strip_namespaces].should be true
36
- reader.options[:advanced_typecasting].should be true
37
- reader.options[:convert_tags_to].should be_a Proc
38
- reader.options[:parser].should == :nokogiri
39
- reader.elements.should == ['some_nested', 'record']
35
+ expect(reader.options[:strip_namespaces]).to be true
36
+ expect(reader.options[:advanced_typecasting]).to be true
37
+ expect(reader.options[:convert_tags_to]).to be_a Proc
38
+ expect(reader.options[:parser]).to eq :nokogiri
39
+ expect(reader.elements).to eq ['some_nested', 'record']
40
40
  end
41
41
  end
42
42
 
@@ -52,7 +52,7 @@ module Stockboy
52
52
  it "returns element hashes" do
53
53
  items = reader.parse data
54
54
  output_keys.each do |k|
55
- items[0].keys.should include k
55
+ expect(items[0].keys).to include k
56
56
  end
57
57
  end
58
58
 
@@ -60,7 +60,7 @@ module Stockboy
60
60
  items = reader.parse data
61
61
  output_keys.each do |key|
62
62
  i = items[0].keys.index(key)
63
- items[0].keys[i].should be items[1].keys[i]
63
+ expect(items[0].keys[i]).to be items[1].keys[i]
64
64
  end
65
65
  end
66
66
  end
@@ -8,21 +8,21 @@ module Stockboy
8
8
 
9
9
  describe ".register" do
10
10
  it "registers a key for a reader class" do
11
- Readers.register(:markup, reader_class).should be reader_class
11
+ expect(Readers.register(:markup, reader_class)).to be reader_class
12
12
  end
13
13
  end
14
14
 
15
15
  describe ".find" do
16
16
  it "returns a reader class" do
17
17
  Readers.register(:markup, reader_class)
18
- Readers.find(:markup).should be reader_class
18
+ expect(Readers.find(:markup)).to be reader_class
19
19
  end
20
20
  end
21
21
 
22
22
  describe ".[]" do
23
23
  it "returns a reader class" do
24
24
  Readers.register(:markup, reader_class)
25
- Readers[:markup].should be reader_class
25
+ expect(Readers[:markup]).to be reader_class
26
26
  end
27
27
  end
28
28
 
@@ -9,11 +9,11 @@ module Stockboy
9
9
  end
10
10
 
11
11
  it "accesses initialized fields from hash" do
12
- record.full_name.should == 'Arthur Dent'
12
+ expect(record.full_name).to eq 'Arthur Dent'
13
13
  end
14
14
 
15
15
  it "accesses source field names" do
16
- record[3].should == 'Arthur Dent'
16
+ expect(record[3]).to eq 'Arthur Dent'
17
17
  end
18
18
  end
19
19
  end
@@ -12,17 +12,17 @@ module Stockboy
12
12
 
13
13
  describe ".read" do
14
14
  it "returns the template string" do
15
- TemplateFile.read("test_job").should match "# file exists!"
15
+ expect(TemplateFile.read("test_job")).to match "# file exists!"
16
16
  end
17
17
  end
18
18
 
19
19
  describe ".template_path" do
20
20
  it "returns nil when missing" do
21
- TemplateFile.find("not_here").should be nil
21
+ expect(TemplateFile.find("not_here")).to be nil
22
22
  end
23
23
 
24
24
  it "returns a file path when found" do
25
- TemplateFile.find("test_job").should == "#{template_path}/test_job.rb"
25
+ expect(TemplateFile.find("test_job")).to eq "#{template_path}/test_job.rb"
26
26
  end
27
27
  end
28
28
 
@@ -8,7 +8,7 @@ module Stockboy
8
8
  def self.it_should_be(actual, arg)
9
9
  it "returns #{actual.inspect} for #{arg[:for].inspect}" do
10
10
  result = subject.call arg[:for]
11
- result.should eq actual
11
+ expect(result).to eq actual
12
12
  end
13
13
  end
14
14
 
@@ -10,27 +10,27 @@ module Stockboy
10
10
  describe "#call" do
11
11
  it "returns nil for an empty string" do
12
12
  result = subject.call start: ""
13
- result.should be nil
13
+ expect(result).to be nil
14
14
  end
15
15
 
16
16
  it "returns a date unmodified" do
17
17
  result = subject.call start: ::Date.new(2012,12,21)
18
- result.should == ::Date.new(2012,12,21)
18
+ expect(result).to eq ::Date.new(2012,12,21)
19
19
  end
20
20
 
21
21
  it "returns a date from a string" do
22
22
  result = subject.call start: '2013-12-11'
23
- result.should == ::Date.new(2013,12,11)
23
+ expect(result).to eq ::Date.new(2013,12,11)
24
24
  end
25
25
 
26
26
  it "returns a date from a time" do
27
27
  result = subject.call start: ::Time.new(2012,12,21,12,21,12)
28
- result.should == ::Date.new(2012,12,21)
28
+ expect(result).to eq ::Date.new(2012,12,21)
29
29
  end
30
30
 
31
31
  it "returns a date from a DateTime" do
32
32
  result = subject.call start: ::DateTime.new(2012,12,21,12,21,12)
33
- result.should == ::Date.new(2012,12,21)
33
+ expect(result).to eq ::Date.new(2012,12,21)
34
34
  end
35
35
  end
36
36
 
@@ -9,13 +9,13 @@ module Stockboy
9
9
  describe "#call" do
10
10
  it "returns nil for an empty string" do
11
11
  result = subject.call total: ""
12
- result.should be nil
12
+ expect(result).to be nil
13
13
  end
14
14
 
15
15
  it "returns a decimal" do
16
16
  result = subject.call total: "42.42"
17
- result.should == 42.42
18
- result.should be_a BigDecimal
17
+ expect(result).to eq 42.42
18
+ expect(result).to be_a BigDecimal
19
19
  end
20
20
  end
21
21
 
@@ -9,22 +9,22 @@ module Stockboy
9
9
  describe "#call" do
10
10
  it "returns empty string for nil" do
11
11
  result = subject.call comment: nil
12
- result.should == ""
12
+ expect(result).to eq ""
13
13
  end
14
14
 
15
15
  it "returns empty string for an empty string" do
16
16
  result = subject.call comment: ""
17
- result.should == ""
17
+ expect(result).to eq ""
18
18
  end
19
19
 
20
20
  it "returns original value if present" do
21
21
  result = subject.call comment: "asdf"
22
- result.should == "asdf"
22
+ expect(result).to eq "asdf"
23
23
  end
24
24
 
25
25
  it "returns original value when zero" do
26
26
  result = subject.call comment: 0
27
- result.should == 0
27
+ expect(result).to eq 0
28
28
  end
29
29
  end
30
30
 
@@ -8,7 +8,7 @@ module Stockboy
8
8
  def self.it_should_be(actual, arg)
9
9
  it "returns #{actual.inspect} for #{arg[:for].inspect}" do
10
10
  result = subject.call arg[:for]
11
- result.should eq actual
11
+ expect(result).to eq actual
12
12
  end
13
13
  end
14
14
 
@@ -9,22 +9,22 @@ module Stockboy
9
9
  describe "#call" do
10
10
  it "returns nil for empty string" do
11
11
  result = subject.call email: ""
12
- result.should == nil
12
+ expect(result).to eq nil
13
13
  end
14
14
 
15
15
  it "returns nil for nil" do
16
16
  result = subject.call email: nil
17
- result.should == nil
17
+ expect(result).to eq nil
18
18
  end
19
19
 
20
20
  it "returns original value if present" do
21
21
  result = subject.call email: "a@example.com"
22
- result.should == "a@example.com"
22
+ expect(result).to eq "a@example.com"
23
23
  end
24
24
 
25
25
  it "returns original value when zero" do
26
26
  result = subject.call email: 0
27
- result.should == 0
27
+ expect(result).to eq 0
28
28
  end
29
29
  end
30
30