Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rspec syntax #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,35 @@ You can write a spec such as (RSpec was used in this example):
require 'spec_helper'

describe 'Whenever Schedule' do
before do
before(:context) do
load 'Rakefile' # Makes sure rake tasks are loaded so you can assert in rake jobs
end

it 'makes sure `runner` statements exist' do
schedule = Whenever::Test::Schedule.new(file: 'config/schedule.rb')

assert_equal 2, schedule.jobs[:runner].count
expect(schedule.jobs[:runner].count).to eq(2)

# Executes the actual ruby statement to make sure all constants and methods exist:
schedule.jobs[:runner].each { |job| instance_eval job[:task] }
schedule.jobs[:runner].each do |job|
expect { instance_eval job[:task] }.not_to raise_error
end
end

it 'makes sure `rake` statements exist' do
# config/schedule.rb file is used by default in constructor:
schedule = Whenever::Test::Schedule.new(vars: { environment: 'staging' })

# Makes sure the rake task is defined:
assert Rake::Task.task_defined?(schedule.jobs[:rake].first[:task])
expect(Rake::Task.task_defined?(job[:task])).to be(true)
end

it 'makes sure cron alive monitor is registered in minute basis' do
schedule = Whenever::Test::Schedule.new(file: fixture)

assert_equal 'http://myapp.com/cron-alive', schedule.jobs[:curl].first[:task]
assert_equal 'curl :task', schedule.jobs[:curl].first[:command]
assert_equal [:minute], schedule.jobs[:curl].first[:every]
expect(schedule.jobs[:curl].first[:task]).to eq('http://myapp.com/cron-alive')
expect(schedule.jobs[:curl].first[:command]).to eq('curl :task')
expect(schedule.jobs[:curl].first[:every]).to eq([:minute])
end
end
```
Expand Down