ari_fetch 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,5 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
  gem 'rspec'
6
6
 
7
- # gem "activesupport"
7
+ gem "activesupport"
8
+ gem "activerecord"
8
9
  # gem "rails"
@@ -9,7 +9,7 @@ module AriFetch
9
9
  attr_accessor :content, :vehicles
10
10
 
11
11
  def fetch_data(ftp_instance, include_cancel)
12
- ftp_instance.gettextfile(name)
12
+ ftp_instance.get(name)
13
13
  @content = parse!(File.open(name, "r"))
14
14
  FileUtils.rm name
15
15
  filter_cancel_vehicles! unless include_cancel
@@ -1,3 +1,3 @@
1
1
  module AriFetch
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/spec/ari_spec.rb CHANGED
@@ -2,28 +2,52 @@ require 'spec_helper'
2
2
 
3
3
  describe AriFetch::Engine do
4
4
 
5
- let!(:engine) { AriFetch::Engine.new("184.168.187.1", "arixml", "ARIuser1!") }
5
+ before(:all) {
6
+ @engine = AriFetch::Engine.new("184.168.187.1", "arixml", "ARIuser1!")
7
+ }
6
8
 
7
9
  context "initialize ari fetch" do
8
- subject { engine }
10
+ subject { @engine }
11
+
12
+ context "ftp instance" do
13
+ subject { @engine.ftp_instance }
14
+ its(:class) { should == Net::FTP }
15
+ end
9
16
 
10
17
  context "fetch files from ftp" do
11
- let!(:ftp_files) { engine.ftp_files }
12
- subject { ftp_files }
13
- its(:count) { should be > 0 }
18
+ subject { @engine.ftp_files }
19
+ its(:class) { should == Array }
14
20
  end
15
21
 
16
- context "read and unread files" do
22
+ context "fetch real files from db" do
17
23
  its(:read_files){ should == [] }
18
- let!(:ftp_files) { engine.ftp_files }
19
- its(:unread_files) { should == ftp_files }
20
24
  end
21
25
 
22
- end
26
+ context "getting list of unread files" do
27
+ context "read file is empty" do
28
+ before {
29
+ @engine.stub(:read_files).and_return([])
30
+ @engine.stub(:ftp_files).and_return(["File1"])
31
+ }
32
+ its(:unread_files) { should == @engine.ftp_files }
33
+ end
34
+
35
+ context "read file and ftp files both are not empty" do
36
+ before {
37
+ @engine.stub(:read_files).and_return(["File1"])
38
+ @engine.stub(:ftp_files).and_return(["File1", "File2"])
39
+ }
40
+ its(:unread_files) { should == ["File2"] }
41
+ end
42
+
43
+ context "ftp files is empty" do
44
+ before {
45
+ @engine.stub(:read_files).and_return(["File1", "File2"])
46
+ @engine.stub(:ftp_files).and_return([])
47
+ }
48
+ its(:unread_files) { should == [] }
49
+ end
50
+ end
23
51
 
24
- context "reading files and fetching data" do
25
- subject { engine }
26
- its(:read_files_from_start) { should == "Array" }
27
52
  end
28
-
29
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ari_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri