spec/lib/trackerific/event_spec.rb in trackerific-0.6.2 vs spec/lib/trackerific/event_spec.rb in trackerific-0.7.0
- old
+ new
@@ -1,48 +1,19 @@
require 'spec_helper'
describe Trackerific::Event do
-
- before do
- @date = Time.now
- @description = 'description'
- @location = 'location'
- @required_parameters = {
- :date => @date,
- :description => @description,
- :location => @location
- }
+ let(:date) { Time.now }
+ let(:description) { "DESCRIPTION" }
+ let(:location) { "LOCATION" }
+
+ subject { described_class.new(date, description, location) }
+
+ its(:date) { should eq date }
+ its(:description) { should eq description }
+ its(:location) { should eq location }
+
+
+ let(:to_s_regex) do
+ /(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (0[1-9]|[1-2][0-9]|3[01]) \d{2}:\d{2} (am|pm).*/
end
-
- context "with all required options" do
- before { @event = Trackerific::Event.new(@required_parameters) }
-
- describe :date do
- subject { @event.date }
- it { should be @date }
- end
-
- describe :description do
- subject { @event.description }
- it { should be @description }
- end
-
- describe :location do
- subject { @event.location }
- it { should be @location }
- end
-
- describe :to_s do
- before { @regex = /(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (0[1-9]|[1-2][0-9]|3[01]) \d{2}:\d{2} (am|pm).*/ }
- subject { @event.to_s }
- it("should be in format mmm dd hh:mm am/pm.*") { should =~ @regex }
- end
- end
-
- context "missing some options" do
- specify { lambda { Trackerific::Event.new(:date => Time.now, :description => '') }.should raise_error(ArgumentError) }
- end
-
- context "with invalid options" do
- specify { lambda { Trackerific::Event.new(:hello => "world") }.should raise_error(ArgumentError) }
- end
+ its(:to_s) { should =~ to_s_regex }
end