Skip to content

Commit

Permalink
spec for time_travel_to exception handling
Browse files Browse the repository at this point in the history
simple spec to make sure an exception is caught when a non Date object
is passed to time_travel_to
  • Loading branch information
ferndopolis authored and michaelkirk committed Feb 26, 2014
1 parent ec0177e commit 5b31afe
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions spec/helpers/main_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

describe TimecopConsole::MainHelper do
describe "#time_travel_to" do
let(:date) { Date.parse('Dec 12, 1950') }
context "when a Date object is passed" do
let(:date) { Date.parse('Dec 12, 1950') }

it 'should return a link with timecop console route' do
helper.time_travel_to(date).should == "<a data-method=\"post\" href=\"/timecop_console/update?timecop%5Bcurrent_time%281i%29%5D=1950&amp;timecop%5Bcurrent_time%282i%29%5D=12&amp;timecop%5Bcurrent_time%283i%29%5D=12&amp;timecop%5Bcurrent_time%284i%29%5D=12&amp;timecop%5Bcurrent_time%285i%29%5D=0\" rel=\"nofollow\">December 12, 1950</a>"
it 'should return a link with timecop console route' do
helper.time_travel_to(date).should == "<a data-method=\"post\" href=\"/timecop_console/update?timecop%5Bcurrent_time%281i%29%5D=1950&amp;timecop%5Bcurrent_time%282i%29%5D=12&amp;timecop%5Bcurrent_time%283i%29%5D=12&amp;timecop%5Bcurrent_time%284i%29%5D=12&amp;timecop%5Bcurrent_time%285i%29%5D=0\" rel=\"nofollow\">December 12, 1950</a>"
end
end
context "when a string is passed" do
let(:date) { "12-12-1950" }
it "should raise an ArgumentError" do
expect { helper.time_travel_to(date) }.to raise_error(ArgumentError, "Argument must be a Date object")
end
end
end
end

0 comments on commit 5b31afe

Please sign in to comment.