bookie_accounting 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,16 +7,16 @@ describe Bookie::Database::SystemType do
7
7
  systype = SystemType.new
8
8
  #TODO: create custom RSpec matcher for this?
9
9
  systype.memory_stat_type = :unknown
10
- systype.memory_stat_type.should eql :unknown
11
- systype.read_attribute(:memory_stat_type).should eql SystemType::MEMORY_STAT_TYPE[:unknown]
10
+ expect(systype.memory_stat_type).to eql :unknown
11
+ expect(systype.read_attribute(:memory_stat_type)).to eql SystemType::MEMORY_STAT_TYPE[:unknown]
12
12
  systype.memory_stat_type = :avg
13
- systype.memory_stat_type.should eql :avg
14
- systype.read_attribute(:memory_stat_type).should eql SystemType::MEMORY_STAT_TYPE[:avg]
13
+ expect(systype.memory_stat_type).to eql :avg
14
+ expect(systype.read_attribute(:memory_stat_type)).to eql SystemType::MEMORY_STAT_TYPE[:avg]
15
15
  systype.memory_stat_type = :max
16
- systype.memory_stat_type.should eql :max
17
- systype.read_attribute(:memory_stat_type).should eql SystemType::MEMORY_STAT_TYPE[:max]
16
+ expect(systype.memory_stat_type).to eql :max
17
+ expect(systype.read_attribute(:memory_stat_type)).to eql SystemType::MEMORY_STAT_TYPE[:max]
18
18
  end
19
-
19
+
20
20
  it "rejects unrecognized memory stat type codes" do
21
21
  systype = SystemType.new
22
22
  expect { systype.memory_stat_type = :invalid_type }.to raise_error("Unrecognized memory stat type 'invalid_type'")
@@ -24,12 +24,12 @@ describe Bookie::Database::SystemType do
24
24
  systype.send(:write_attribute, :memory_stat_type, 10000)
25
25
  expect { systype.memory_stat_type }.to raise_error("Unrecognized memory stat type code 10000")
26
26
  end
27
-
27
+
28
28
  it "creates the system type when needed" do
29
29
  SystemType.expects(:'create!')
30
30
  SystemType.find_or_create!('test', :avg)
31
31
  end
32
-
32
+
33
33
  it "raises an error if the existing type has the wrong memory stat type" do
34
34
  systype = SystemType.create!(:name => 'test', :memory_stat_type => :max)
35
35
  begin
@@ -43,7 +43,7 @@ describe Bookie::Database::SystemType do
43
43
  systype.delete
44
44
  end
45
45
  end
46
-
46
+
47
47
  it "uses the existing type" do
48
48
  systype = SystemType.create!(:name => 'test', :memory_stat_type => :avg)
49
49
  begin
@@ -53,16 +53,15 @@ describe Bookie::Database::SystemType do
53
53
  systype.delete
54
54
  end
55
55
  end
56
-
56
+
57
57
  it "validates fields" do
58
58
  systype = SystemType.new(:name => 'test')
59
59
  expect { systype.valid? }.to raise_error('Memory stat type must not be nil')
60
60
  systype.memory_stat_type = :unknown
61
- systype.valid?.should eql true
61
+ expect(systype.valid?).to eql true
62
62
  systype.name = nil
63
- systype.valid?.should eql false
63
+ expect(systype.valid?).to eql false
64
64
  systype.name = ''
65
- systype.valid?.should eql false
65
+ expect(systype.valid?).to eql false
66
66
  end
67
67
  end
68
-
@@ -3,67 +3,66 @@ require 'spec_helper'
3
3
  describe Bookie::Database::User do
4
4
  it "correctly filters by name" do
5
5
  users = Bookie::Database::User.by_name('test').to_a
6
- users.length.should eql 2
6
+ expect(users.length).to eql 2
7
7
  users.each do |user|
8
- user.name.should eql 'test'
8
+ expect(user.name).to eql 'test'
9
9
  end
10
10
  end
11
11
 
12
12
  it "correctly filters by group" do
13
- Bookie::Database::User.by_group(Bookie::Database::Group.find_by_name('admin')).count.should eql 2
14
- Bookie::Database::User.by_group(Bookie::Database::Group.find_by_name('root')).count.should eql 1
13
+ expect(Bookie::Database::User.by_group(Bookie::Database::Group.find_by(name: 'admin')).count).to eql 2
14
+ expect(Bookie::Database::User.by_group(Bookie::Database::Group.find_by(name: 'root')).count).to eql 1
15
15
  end
16
16
 
17
17
  it "correctly filters by group name" do
18
- Bookie::Database::User.by_group_name('admin').count.should eql 2
19
- Bookie::Database::User.by_group_name('fake_group').count.should eql 0
18
+ expect(Bookie::Database::User.by_group_name('admin').count).to eql 2
19
+ expect(Bookie::Database::User.by_group_name('fake_group').count).to eql 0
20
20
  end
21
-
21
+
22
22
  describe "#find_or_create" do
23
23
  before(:each) do
24
- @group = Bookie::Database::Group.find_by_name('admin')
24
+ @group = Bookie::Database::Group.find_by(name: 'admin')
25
25
  end
26
-
26
+
27
27
  it "creates the user if needed" do
28
28
  Bookie::Database::User.expects(:"create!").twice
29
29
  user = Bookie::Database::User.find_or_create!('me', @group)
30
30
  user = Bookie::Database::User.find_or_create!('me', @group, {})
31
31
  end
32
-
32
+
33
33
  it "returns the cached user if one exists" do
34
- user = Bookie::Database::User.find_by_name('root')
34
+ user = Bookie::Database::User.find_by(name: 'root')
35
35
  known_users = {['root', user.group] => user}
36
- Bookie::Database::User.find_or_create!('root', user.group, known_users).should equal user
36
+ expect(Bookie::Database::User.find_or_create!('root', user.group, known_users)).to equal user
37
37
  end
38
-
38
+
39
39
  it "queries the database when this user is not cached" do
40
- user = Bookie::Database::User.find_by_name_and_group_id('root', 1)
40
+ user = Bookie::Database::User.find_by!(name: 'root', group_id: 1)
41
41
  known_users = {}
42
- Bookie::Database::User.expects(:find_by_name_and_group_id).returns(user).twice
42
+ Bookie::Database::User.expects(:find_by).returns(user).twice
43
43
  Bookie::Database::User.expects(:"create!").never
44
- Bookie::Database::User.find_or_create!('root', user.group, known_users).should eql user
45
- Bookie::Database::User.find_or_create!('root', user.group, nil).should eql user
46
- known_users.should include ['root', user.group]
44
+ expect(Bookie::Database::User.find_or_create!('root', user.group, known_users)).to eql user
45
+ expect(Bookie::Database::User.find_or_create!('root', user.group, nil)).to eql user
46
+ expect(known_users).to include ['root', user.group]
47
47
  end
48
48
  end
49
-
49
+
50
50
  it "validates fields" do
51
51
  fields = {
52
52
  :group => Bookie::Database::Group.first,
53
53
  :name => 'test',
54
54
  }
55
-
56
- Bookie::Database::User.new(fields).valid?.should eql true
57
-
55
+
56
+ expect(Bookie::Database::User.new(fields).valid?).to eql true
57
+
58
58
  fields.each_key do |field|
59
59
  user = Bookie::Database::User.new(fields)
60
60
  user.method("#{field}=".intern).call(nil)
61
- user.valid?.should eql false
61
+ expect(user.valid?).to eql false
62
62
  end
63
-
63
+
64
64
  user = Bookie::Database::User.new(fields)
65
65
  user.name = ''
66
- user.valid?.should eql false
66
+ expect(user.valid?).to eql false
67
67
  end
68
68
  end
69
-
@@ -3,22 +3,22 @@ require 'spec_helper'
3
3
  describe Range do
4
4
  describe "#normalized" do
5
5
  it "correctly normalizes" do
6
- (1 .. 2).normalized.should eql(1 .. 2)
7
- (1 .. 1).normalized.should eql(1 .. 1)
8
- (1 ... 1).normalized.should eql(1 ... 1)
9
- (1 .. 0).normalized.should eql(1 ... 1)
10
- (1 ... 0).normalized.should eql( 1 ... 1 )
6
+ expect((1 .. 2).normalized).to eql(1 .. 2)
7
+ expect((1 .. 1).normalized).to eql(1 .. 1)
8
+ expect((1 ... 1).normalized).to eql(1 ... 1)
9
+ expect((1 .. 0).normalized).to eql(1 ... 1)
10
+ expect((1 ... 0).normalized).to eql( 1 ... 1 )
11
11
  end
12
12
  end
13
13
 
14
14
  describe "empty?" do
15
15
  it "correctly determines emptiness" do
16
- (1 .. 2).empty?.should eql false
17
- (1 .. 1).empty?.should eql false
18
- (1 ... 2).empty?.should eql false
19
- (1 ... 1).empty?.should eql true
20
- (1 .. 0).empty?.should eql true
21
- (1 ... 0).empty?.should eql true
16
+ expect((1 .. 2).empty?).to eql false
17
+ expect((1 .. 1).empty?).to eql false
18
+ expect((1 ... 2).empty?).to eql false
19
+ expect((1 ... 1).empty?).to eql true
20
+ expect((1 .. 0).empty?).to eql true
21
+ expect((1 ... 0).empty?).to eql true
22
22
  end
23
23
  end
24
24
  end
@@ -6,9 +6,9 @@ module Bookie
6
6
  attr_reader :mock_field_values
7
7
 
8
8
  def open(filename)
9
-
9
+
10
10
  end
11
-
11
+
12
12
  def do_print_summary(field_values)
13
13
  @mock_field_values = field_values
14
14
  end
@@ -22,7 +22,7 @@ describe Bookie::Formatter do
22
22
  before(:each) do
23
23
  Formatter.any_instance.stubs(:require)
24
24
  end
25
-
25
+
26
26
  let(:formatter) { Formatter.new(:mock) }
27
27
  let(:jobs) { Database::Job }
28
28
  let(:summaries) { Database::JobSummary }
@@ -31,16 +31,16 @@ describe Bookie::Formatter do
31
31
  Formatter.any_instance.expects(:require).with('bookie/formatters/mock')
32
32
  Formatter.new(:mock)
33
33
  end
34
-
34
+
35
35
  it "correctly formats durations" do
36
- Formatter.format_duration(1.seconds + 2.minutes + 3.hours + 4.days + 5.weeks).should eql '5 weeks, 4 days, 03:02:01'
37
- Formatter.format_duration(1.weeks + 1.days).should eql '1 week, 1 day, 00:00:00'
36
+ expect(Formatter.format_duration(1.seconds + 2.minutes + 3.hours + 4.days + 5.weeks)).to eql '5 weeks, 4 days, 03:02:01'
37
+ expect(Formatter.format_duration(1.weeks + 1.days)).to eql '1 week, 1 day, 00:00:00'
38
38
  end
39
-
39
+
40
40
  it "correctly calculates fields for jobs" do
41
41
  with_utc do
42
42
  formatter.fields_for_each_job(jobs.limit(1)) do |fields|
43
- fields.should eql [
43
+ expect(fields).to eql [
44
44
  'root',
45
45
  'root',
46
46
  'test1',
@@ -57,11 +57,11 @@ describe Bookie::Formatter do
57
57
  jobs = [Database::Job.first]
58
58
  jobs[0].system.system_type.memory_stat_type = :unknown
59
59
  formatter.send(:fields_for_each_job, jobs) do |fields|
60
- fields[8].should eql '200kb'
60
+ expect(fields[8]).to eql '200kb'
61
61
  end
62
62
  end
63
63
  end
64
-
64
+
65
65
  describe "#print_summary" do
66
66
  it "prints the correct summary fields" do
67
67
  with_utc do
@@ -69,12 +69,12 @@ describe Bookie::Formatter do
69
69
 
70
70
  formatter.print_summary(jobs, summaries, Database::System)
71
71
  formatter.flush
72
- formatter.mock_field_values.should eql [
72
+ expect(formatter.mock_field_values).to eql [
73
73
  40, "0 weeks, 0 days, 01:06:40", "50.0000%",
74
74
  "0 weeks, 5 days, 20:00:00", "0.7937%",
75
75
  "1750000 kb", "0.0114%"
76
76
  ]
77
-
77
+
78
78
  Database::System.expects(:summary).returns(
79
79
  :avail_cpu_time => 0,
80
80
  :avail_memory_time => 0,
@@ -82,7 +82,7 @@ describe Bookie::Formatter do
82
82
  )
83
83
  formatter.print_summary(jobs, summaries, Database::System, base_time ... base_time)
84
84
  formatter.flush
85
- formatter.mock_field_values.should eql [
85
+ expect(formatter.mock_field_values).to eql [
86
86
  0, "0 weeks, 0 days, 00:00:00", "0.0000%",
87
87
  "0 weeks, 0 days, 00:00:00", "0.0000%",
88
88
  "0 kb", "0.0000%"
@@ -90,12 +90,12 @@ describe Bookie::Formatter do
90
90
  end
91
91
  end
92
92
  end
93
-
93
+
94
94
  it "forwards print_jobs to do_print_jobs" do
95
95
  formatter.expects(:do_print_jobs).with(Job)
96
96
  formatter.print_jobs(Job)
97
97
  end
98
-
98
+
99
99
  it "forwards flush to do_flush" do
100
100
  formatter.expects(:'respond_to?').with(:do_flush).returns(false)
101
101
  formatter.expects(:do_flush).never
@@ -11,27 +11,27 @@ describe Bookie::Formatters::CommaDump do
11
11
  File.expects(:open).at_least(0).returns(io_mock)
12
12
  end
13
13
  let(:formatter) { Bookie::Formatter.new(:comma_dump, 'test.csv') }
14
-
14
+
15
15
  it "correctly opens files" do
16
16
  File.expects(:open).with('test.csv')
17
17
  Bookie::Formatter.new(:comma_dump, 'test.csv')
18
18
  end
19
-
19
+
20
20
  it "correctly formats jobs" do
21
21
  with_utc do
22
22
  formatter.print_jobs(Job.order(:start_time).limit(2))
23
- io_mock.buf.should eql <<-eos
23
+ expect(io_mock.buf).to eql <<-eos
24
24
  User, Group, System, System type, Start time, End time, Wall time, CPU time, Memory usage, Command, Exit code
25
25
  "root", "root", "test1", "Standalone", "2012-01-01 00:00:00", "2012-01-01 01:00:00", "0 weeks, 0 days, 01:00:00", "0 weeks, 0 days, 00:01:40", "200kb (avg)", "vi", "0"
26
26
  "test", "default", "test1", "Standalone", "2012-01-01 01:00:00", "2012-01-01 02:00:00", "0 weeks, 0 days, 01:00:00", "0 weeks, 0 days, 00:01:40", "200kb (avg)", "emacs", "1"
27
27
  eos
28
28
  end
29
29
  end
30
-
30
+
31
31
  it "correctly formats summaries" do
32
32
  Time.expects(:now).returns(base_time + 40.hours).at_least_once
33
33
  formatter.print_summary(Job, JobSummary, System)
34
- io_mock.buf.should eql <<-eos
34
+ expect(io_mock.buf).to eql <<-eos
35
35
  "Number of jobs", "40"
36
36
  "Total CPU time", "0 weeks, 0 days, 01:06:40"
37
37
  "Successful", "50.0000%"
@@ -44,8 +44,8 @@ eos
44
44
 
45
45
  it "correctly quotes values" do
46
46
  formatter = Formatters::CommaDump
47
- formatter.quote("test").should eql '"test"'
48
- formatter.quote('"test"').should eql '"""test"""'
49
- formatter.quote(0).should eql '"0"'
47
+ expect(formatter.quote("test")).to eql '"test"'
48
+ expect(formatter.quote('"test"')).to eql '"""test"""'
49
+ expect(formatter.quote(0)).to eql '"0"'
50
50
  end
51
51
  end
@@ -18,7 +18,7 @@ end
18
18
  class MockWorksheet
19
19
  attr_reader :mock_rows
20
20
  attr_reader :mock_columns
21
-
21
+
22
22
  def initialize
23
23
  @mock_rows = []
24
24
  @mock_columns = []
@@ -31,7 +31,7 @@ class MockWorksheet
31
31
  def column(num)
32
32
  @mock_columns[num] ||= MockColumn.new
33
33
  end
34
-
34
+
35
35
  def last_row_index
36
36
  @mock_rows.length - 1
37
37
  end
@@ -41,7 +41,7 @@ class MockColumn
41
41
  def width=(value)
42
42
  @width = value
43
43
  end
44
-
44
+
45
45
  def width
46
46
  @width
47
47
  end
@@ -53,14 +53,14 @@ describe Bookie::Formatters::Spreadsheet do
53
53
  Spreadsheet::Workbook.expects(:new).returns(mock_workbook)
54
54
  end
55
55
  let(:formatter) { Bookie::Formatter.new(:spreadsheet, 'test.xls') }
56
-
56
+
57
57
  it "correctly formats jobs" do
58
58
  with_utc do
59
59
  formatter.print_jobs(Job.limit(2))
60
60
  w = mock_workbook.worksheet('Details')
61
- w.mock_columns.length.should eql Bookie::Formatter::DETAILS_FIELD_LABELS.length
61
+ expect(w.mock_columns.length).to eql Bookie::Formatter::DETAILS_FIELD_LABELS.length
62
62
  w.mock_columns.each do |col|
63
- col.width.should_not eql nil
63
+ expect(col.width).to_not eql nil
64
64
  end
65
65
  expect(w.mock_rows).to eql([
66
66
  Bookie::Formatter::DETAILS_FIELD_LABELS,
@@ -74,12 +74,12 @@ describe Bookie::Formatters::Spreadsheet do
74
74
  ])
75
75
  end
76
76
  end
77
-
77
+
78
78
  it "correctly formats summaries" do
79
79
  Time.expects(:now).returns(base_time + 40.hours).at_least_once
80
80
  formatter.print_summary(Job, JobSummary, System)
81
81
  w = mock_workbook.worksheet('Summary')
82
- w.column(0).width.should_not eql nil
82
+ expect(w.column(0).width).to_not eql nil
83
83
  expect(w.mock_rows).to eql([
84
84
  ["Number of jobs", 40],
85
85
  ["Total CPU time", "0 weeks, 0 days, 01:06:40"],
@@ -90,7 +90,7 @@ describe Bookie::Formatters::Spreadsheet do
90
90
  ["Memory used (average)", "0.0114%"],
91
91
  ])
92
92
  end
93
-
93
+
94
94
  it "correctly flushes output" do
95
95
  mock_workbook.expects(:write).with('test.xls')
96
96
  formatter.do_flush
@@ -14,29 +14,29 @@ describe Bookie::Formatters::Stdout do
14
14
 
15
15
  it "correctly opens files" do
16
16
  f = Bookie::Formatter.new(:stdout)
17
- f.instance_variable_get(:'@io').should eql STDOUT
17
+ expect(f.instance_variable_get(:'@io')).to eql STDOUT
18
18
  File.expects(:open).with('mock.out')
19
19
  Bookie::Formatter.new(:stdout, 'mock.out')
20
20
  end
21
-
21
+
22
22
  it "correctly formats jobs" do
23
23
  with_utc do
24
24
  formatter.print_jobs(Job.order(:start_time).limit(2))
25
25
  formatter.flush
26
- io_mock.buf.should eql <<-eos
27
- User Group System System type Start time End time Wall time CPU time Memory usage Command Exit code
26
+ expect(io_mock.buf).to eql <<-eos
27
+ User Group System System type Start time End time Wall time CPU time Memory usage Command Exit code
28
28
  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
29
- root root test1 Standalone 2012-01-01 00:00:00 2012-01-01 01:00:00 0 weeks, 0 days, 01:00:00 0 weeks, 0 days, 00:01:40 200kb (avg) vi 0
30
- test default test1 Standalone 2012-01-01 01:00:00 2012-01-01 02:00:00 0 weeks, 0 days, 01:00:00 0 weeks, 0 days, 00:01:40 200kb (avg) emacs 1
29
+ root root test1 Standalone 2012-01-01 00:00:00 2012-01-01 01:00:00 0 weeks, 0 days, 01:00:00 0 weeks, 0 days, 00:01:40 200kb (avg) vi 0
30
+ test default test1 Standalone 2012-01-01 01:00:00 2012-01-01 02:00:00 0 weeks, 0 days, 01:00:00 0 weeks, 0 days, 00:01:40 200kb (avg) emacs 1
31
31
  eos
32
32
  end
33
33
  end
34
-
34
+
35
35
  it "correctly formats summaries" do
36
36
  Time.expects(:now).returns(base_time + 40.hours).at_least_once
37
37
  formatter.print_summary(Job, JobSummary, System)
38
38
  formatter.flush
39
- io_mock.buf.should eql <<-eos
39
+ expect(io_mock.buf).to eql <<-eos
40
40
  Number of jobs: 40
41
41
  Total CPU time: 0 weeks, 0 days, 01:06:40
42
42
  Successful: 50.0000%
data/spec/sender_spec.rb CHANGED
@@ -29,7 +29,7 @@ class JobStub
29
29
  attr_accessor :cpu_time
30
30
  attr_accessor :memory
31
31
  attr_accessor :exit_code
32
-
32
+
33
33
  include Bookie::ModelHelpers
34
34
 
35
35
  def self.from_job(job)
@@ -74,59 +74,59 @@ describe Bookie::Sender do
74
74
  after(:all) do
75
75
  rollback_transaction
76
76
  end
77
-
77
+
78
78
  let(:sender) { Bookie::Sender.new(test_config) }
79
79
  before(:each) do
80
80
  Bookie::Database::Job.delete_all
81
81
  end
82
-
82
+
83
83
  it "correctly filters jobs" do
84
84
  job = JobStub.new
85
85
  job.user_name = "root"
86
- sender.filtered?(job).should eql true
86
+ expect(sender.filtered?(job)).to eql true
87
87
  job.user_name = "test"
88
- sender.filtered?(job).should eql false
88
+ expect(sender.filtered?(job)).to eql false
89
89
  end
90
-
90
+
91
91
  it "correctly sends jobs" do
92
92
  config = test_config.clone
93
93
  config.excluded_users = Set.new
94
94
  sender.send_data('snapshot/torque_large')
95
95
  jobs = Job.includes(:system)
96
96
  jobs.each do |job|
97
- job.system.name.should eql config.hostname
97
+ expect(job.system.name).to eql config.hostname
98
98
  end
99
- jobs.length.should eql 100
99
+ expect(jobs.length).to eql 100
100
100
  end
101
-
101
+
102
102
  it "refuses to send jobs when jobs already have been sent from a file" do
103
103
  sender.send_data('snapshot/torque_large')
104
104
  expect {
105
105
  sender.send_data('snapshot/torque_large')
106
106
  }.to raise_error("Jobs already exist in the database for 'snapshot/torque_large'.")
107
107
  end
108
-
108
+
109
109
  it "correctly handles empty files" do
110
110
  Bookie::Database::Job.any_instance.expects(:'save!').never
111
111
  ActiveRecord::Relation.any_instance.expects(:'delete_all').never
112
112
  sender.send_data('/dev/null')
113
113
  end
114
-
114
+
115
115
  it "handles missing files" do
116
116
  expect { sender.send_data('snapshot/abc') }.to raise_error("File 'snapshot/abc' does not exist.")
117
117
  end
118
-
118
+
119
119
  it "chooses the correct systems" do
120
120
  sender = Bookie::Sender.new(test_config)
121
121
 
122
122
  redefine_each_job(sender)
123
-
123
+
124
124
  #The filename is just a dummy argument.
125
125
  sender.send_data('snapshot/pacct')
126
-
126
+
127
127
  jobs = Bookie::Database::Job.by_system_name(test_config.hostname).order(:end_time).to_a
128
- jobs[0].system.should eql @sys_1
129
- jobs[1].system.should eql @sys_2
128
+ expect(jobs[0].system).to eql @sys_1
129
+ expect(jobs[1].system).to eql @sys_2
130
130
  end
131
131
 
132
132
  it "correctly finds duplicates" do
@@ -136,9 +136,9 @@ describe Bookie::Sender do
136
136
  #The job's system should be @sys_2.
137
137
  #Just to make sure this test doesn't break later, I'll check it.
138
138
  #TODO: restore?
139
- #expect(job.system).to eql @sys_2
140
- #sender.duplicate(stub, @sys_1).should eql nil
141
- sender.duplicate(stub, job.system).should eql job
139
+ #expect(expect(job.system).to eql @sys_2
140
+ #expect(sender.duplicate(stub, @sys_1)).to eql nil
141
+ expect(sender.duplicate(stub, job.system)).to eql job
142
142
  [:user_name, :group_name, :command_name, :start_time, :wall_time, :cpu_time, :memory, :exit_code].each do |field|
143
143
  old_val = stub.send(field)
144
144
  if old_val.is_a?(String)
@@ -146,11 +146,11 @@ describe Bookie::Sender do
146
146
  else
147
147
  stub.send("#{field}=", old_val + 1)
148
148
  end
149
- sender.duplicate(stub, @sys_2).should eql nil
149
+ expect(sender.duplicate(stub, @sys_2)).to eql nil
150
150
  stub.send("#{field}=", old_val)
151
151
  end
152
152
  end
153
-
153
+
154
154
  it "deletes cached summaries that overlap the new jobs" do
155
155
  sender.send_data('snapshot/torque_large')
156
156
  time_min = Bookie::Database::Job.order(:start_time).first.start_time
@@ -159,12 +159,12 @@ describe Bookie::Sender do
159
159
  sender.expects(:clear_summaries).with(time_min.to_date, time_max.to_date)
160
160
  sender.send_data('snapshot/torque_large')
161
161
  end
162
-
162
+
163
163
  describe "#clear_summaries" do
164
164
  it "deletes cached summaries" do
165
165
  sender = Bookie::Sender.new(test_config)
166
166
  sender.send_data('snapshot/torque_large')
167
-
167
+
168
168
  user = Bookie::Database::User.first
169
169
  date_start = Date.new(2012) - 2
170
170
  date_end = date_start + 4
@@ -175,50 +175,48 @@ describe Bookie::Sender do
175
175
  :system => system,
176
176
  :user => user,
177
177
  :command_name => 'vi',
178
- :num_jobs => 1,
179
178
  :cpu_time => 1,
180
- :memory_time => 100,
181
- :successful => 1
179
+ :memory_time => 100
182
180
  )
183
181
  end
184
182
  end
185
-
183
+
186
184
  sender.send(:clear_summaries, date_start + 1, date_end - 1)
187
-
185
+
188
186
  sums = Bookie::Database::JobSummary.all.to_a
189
- sums.length.should eql 9
187
+ expect(sums.length).to eql 9
190
188
  sums.each do |sum|
191
189
  #Since there are no jobs for @sys_dummy, its summaries should be left intact.
192
190
  unless sum.system == @sys_dummy
193
- (date_start + 1 .. date_end - 1).cover?(sum.date).should eql false
191
+ expect((date_start + 1 .. date_end - 1).cover?(sum.date)).to eql false
194
192
  end
195
193
  end
196
194
  sums = Bookie::Database::JobSummary.by_date(Date.new(2012))
197
- sums.count.should eql 1
198
- sums.first.system.should eql @sys_dummy
195
+ expect(sums.count).to eql 1
196
+ expect(sums.first.system).to eql @sys_dummy
199
197
  end
200
198
  end
201
-
199
+
202
200
  describe "#undo_send" do
203
201
  it "removes the correct entries" do
204
202
  sender.send_data('snapshot/torque_large')
205
203
  sender.send_data('snapshot/torque')
206
204
  sender.undo_send('snapshot/torque_large')
207
-
208
- Bookie::Database::Job.count.should eql 1
205
+
206
+ expect(Bookie::Database::Job.count).to eql 1
209
207
  job = Bookie::Database::Job.first
210
208
  Bookie::Database::Job.delete_all
211
209
  sender.send_data('snapshot/torque')
212
210
  job2 = Bookie::Database::Job.first
213
211
  job2.id = job.id
214
- job2.should eql job
212
+ expect(job2).to eql job
215
213
  end
216
214
 
217
215
  it "switches systems if needed" do
218
216
  sender = Bookie::Sender.new(test_config)
219
217
 
220
218
  redefine_each_job(sender)
221
-
219
+
222
220
  #The filename is just a dummy argument.
223
221
  sender.send_data('snapshot/pacct')
224
222
 
@@ -254,21 +252,21 @@ describe Bookie::ModelHelpers do
254
252
  @job.cpu_time = 2
255
253
  @job.memory = 300
256
254
  end
257
-
255
+
258
256
  it "correctly converts jobs to records" do
259
257
  Bookie::Database::Job.stubs(:new).returns(JobStub.new)
260
258
  djob = @job.to_record
261
- djob.command_name.should eql @job.command_name
262
- djob.start_time.should eql @job.start_time
263
- djob.end_time.should eql @job.start_time + @job.wall_time
264
- djob.wall_time.should eql @job.wall_time
265
- djob.cpu_time.should eql @job.cpu_time
266
- djob.memory.should eql @job.memory
267
- djob.exit_code.should eql @job.exit_code
259
+ expect(djob.command_name).to eql @job.command_name
260
+ expect(djob.start_time).to eql @job.start_time
261
+ expect(djob.end_time).to eql @job.start_time + @job.wall_time
262
+ expect(djob.wall_time).to eql @job.wall_time
263
+ expect(djob.cpu_time).to eql @job.cpu_time
264
+ expect(djob.memory).to eql @job.memory
265
+ expect(djob.exit_code).to eql @job.exit_code
268
266
  end
269
267
 
270
268
  it "correctly calculates end time" do
271
- @job.end_time.should eql @job.start_time + @job.wall_time
269
+ expect(@job.end_time).to eql @job.start_time + @job.wall_time
272
270
  end
273
271
  end
274
272