spec/trackoid_spec.rb in trackoid-0.3.7 vs spec/trackoid_spec.rb in trackoid-0.3.8

- old
+ new

@@ -34,10 +34,24 @@ track :something end }.should_not raise_error end + it "should not raise errors when using to/as_json" do + mock = Test.new(:name => "Trackoid") + json_as = {} + json_to = "" + + lambda { + json_as = mock.as_json(:except => :_id) + json_to = mock.to_json(:except => :_id) + }.should_not raise_error + + json_as.should == { "name" => "Trackoid" } + json_to.should == "{\"name\":\"Trackoid\"}" + end + describe "when creating a new field with stats" do before(:all) do @mock = Test.new end @@ -54,11 +68,11 @@ @mock.class.index_options.should_not include(:visits_data) end it "should respond 'false' to field_changed? method" do # Ok, this test is not very relevant since it will return false even - # if Trackid does not override it. + # if Trackoid does not override it. @mock.visits_changed?.should be_false end it "should create a method for accesing the stats of the proper class" do @mock.visits.class.should == Mongoid::Tracking::Tracker @@ -77,10 +91,10 @@ it "should not update stats when new record" do lambda { @mock.visits.inc }.should raise_error Mongoid::Errors::ModelNotSaved end - it "shold create an empty hash as the internal representation" do + it "should create an empty hash as the internal representation" do @mock.visits.send(:_original_hash).should == {} end it "should give 0 for today stats" do @mock.visits.today.should == 0