Skip to content

Commit a07bc2e

Browse files
committed
Update rspec to 3.7.0
and unlock rake version
1 parent 689c3fb commit a07bc2e

File tree

5 files changed

+43
-24
lines changed

5 files changed

+43
-24
lines changed

.rspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--color
1+
--require spec_helper

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source "http://rubygems.org"
44
gemspec
55

66
gem "ZenTest", "4.6.0"
7-
gem "rake", '~> 11.0'
7+
gem "rake"

parse-cron.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
1919
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
2020
s.require_paths = ["lib"]
2121

22-
s.add_development_dependency 'rspec', '~>2.6.0'
22+
s.add_development_dependency 'rspec', '~> 3.7.0'
2323
end

spec/cron_parser_spec.rb

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require "time"
2-
require "./spec/spec_helper"
32
require "cron_parser"
43
require "date"
54

@@ -8,7 +7,7 @@ def parse_date(str)
87
Time.local(dt.year, dt.month, dt.day, dt.hour, dt.min, 0)
98
end
109

11-
describe "CronParser#parse_element" do
10+
RSpec.describe "CronParser#parse_element" do
1211
[
1312
["*", 0..59, (0..59).to_a],
1413
["*/10", 0..59, [0, 10, 20, 30, 40, 50]],
@@ -19,12 +18,12 @@ def parse_date(str)
1918
].each do |element, range, expected|
2019
it "should return #{expected} for '#{element}' when range is #{range}" do
2120
parser = CronParser.new('* * * * *')
22-
parser.parse_element(element, range).first.to_a.sort.should == expected.sort
21+
expect(parser.parse_element(element, range).first).to match_array(expected)
2322
end
2423
end
2524
end
2625

27-
describe "CronParser#next" do
26+
RSpec.describe "CronParser#next" do
2827
[
2928
["* * * * *", "2011-08-15 12:00", "2011-08-15 12:01",1],
3029
["* * * * *", "2011-08-15 02:25", "2011-08-15 02:26",1],
@@ -83,30 +82,30 @@ def parse_date(str)
8382
parsed_now = parse_date(now)
8483
expected = parse_date(expected_next)
8584
parser = CronParser.new(line)
86-
parser.next(parsed_now).xmlschema.should == expected.xmlschema
85+
expect(parser.next(parsed_now).xmlschema).to eql(expected.xmlschema)
8786
end
8887
it "returns the expected class" do
8988
parsed_now = parse_date(now)
9089
expected = parse_date(expected_next)
9190
parser = CronParser.new(line)
9291
result = parser.next(parsed_now,num)
93-
result.class.to_s.should == (num > 1 ? 'Array' : 'Time')
92+
expect(result).to be_a(num > 1 ? Array : Time)
9493
end
9594
it "returns the expected count" do
9695
parsed_now = parse_date(now)
9796
expected = parse_date(expected_next)
9897
parser = CronParser.new(line)
9998
result = parser.next(parsed_now,num)
100-
if result.class.to_s == 'Array'
101-
result.size.should == num
99+
if result.is_a?(Array)
100+
expect(result.size).to eql(num)
102101
else
103-
result.class.to_s.should == 'Time'
102+
expect(result).to be_a(Time)
104103
end
105104
end
106105
end
107106
end
108107

109-
describe "CronParser#last" do
108+
RSpec.describe "CronParser#last" do
110109
[
111110
["* * * * *", "2011-08-15 12:00", "2011-08-15 11:59"],
112111
["* * * * *", "2011-08-15 02:25", "2011-08-15 02:24"],
@@ -164,12 +163,12 @@ def parse_date(str)
164163

165164
parser = CronParser.new(line)
166165

167-
parser.last(now).should == expected_next
166+
expect(parser.last(now)).to eql(expected_next)
168167
end
169168
end
170169
end
171170

172-
describe "CronParser#new" do
171+
RSpec.describe "CronParser#new" do
173172
it 'should not raise error when given a valid cronline' do
174173
expect { CronParser.new('30 * * * *') }.not_to raise_error
175174
end
@@ -179,10 +178,10 @@ def parse_date(str)
179178
end
180179
end
181180

182-
describe "time source" do
181+
RSpec.describe "time source" do
183182
it "should use an alternate specified time source" do
184183
ExtendedTime = Class.new(Time)
185-
ExtendedTime.should_receive(:local).once
184+
expect(ExtendedTime).to receive(:local).once
186185
CronParser.new("* * * * *",ExtendedTime).next
187186
end
188187
end

spec/spec_helper.rb

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
spec_dir = File.dirname(__FILE__)
2-
lib_dir = File.expand_path(File.join(spec_dir, '..', 'lib'))
3-
$:.unshift(lib_dir)
4-
$:.uniq!
5-
61
RSpec.configure do |config|
7-
end
2+
config.expect_with :rspec do |expectations|
3+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
4+
end
5+
6+
config.mock_with :rspec do |mocks|
7+
mocks.verify_partial_doubles = true
8+
end
9+
10+
config.shared_context_metadata_behavior = :apply_to_host_groups
11+
12+
config.filter_run_when_matching :focus
13+
14+
config.example_status_persistence_file_path = 'spec/examples.txt'
815

9-
require 'cron_parser'
16+
config.disable_monkey_patching!
17+
18+
config.warnings = true
19+
20+
if config.files_to_run.one?
21+
config.default_formatter = 'doc'
22+
end
23+
24+
config.profile_examples = 10
25+
26+
config.order = :random
27+
28+
Kernel.srand config.seed
29+
end

0 commit comments

Comments
 (0)