made Key#scope return Scope object instead of Scope#to_s

This commit is contained in:
2011-03-13 20:23:23 +00:00
parent ea820d44f4
commit e4aaedfe58
3 changed files with 9 additions and 8 deletions

View File

@@ -30,13 +30,14 @@ module Redistat
options[:depth]
end
def scope
@scope.to_s
end
# def scope
# @scope.to_s
# end
def scope=(input)
@scope = (input.instance_of?(Redistat::Scope)) ? input : Scope.new(input)
end
attr_reader :scope
def label=(input)
@label = (input.instance_of?(Redistat::Label)) ? input : Label.create(input, @options)

View File

@@ -17,7 +17,7 @@ describe Redistat::Event do
it "should initialize properly" do
@event.id.should be_nil
@event.scope.should == @scope
@event.scope.to_s.should == @scope
@event.label.to_s.should == @label
@event.label_hash.should == @label_hash
@event.date.to_time.to_s.should == @date.to_s
@@ -63,7 +63,7 @@ describe Redistat::Event do
it "should find event by id" do
@event = Redistat::Event.new(@scope, @label, @date, @stats, @options.merge({:store_event => true}), @meta).save
fetched = Redistat::Event.find(@scope, @event.id)
@event.scope.should == fetched.scope
@event.scope.to_s.should == fetched.scope.to_s
@event.label.to_s.should == fetched.label.to_s
@event.date.to_s.should == fetched.date.to_s
end

View File

@@ -13,7 +13,7 @@ describe Redistat::Key do
end
it "should initialize properly" do
@key.scope.should == @scope
@key.scope.to_s.should == @scope
@key.label.to_s.should == @label
@key.label_hash.should == @label_hash
@key.groups.map { |k| k.instance_variable_get("@label") }.should == @key.instance_variable_get("@label").groups
@@ -44,10 +44,10 @@ describe Redistat::Key do
it "should allow changing attributes" do
# scope
@key.scope.should == @scope
@key.scope.to_s.should == @scope
@scope = "VisitorCount"
@key.scope = @scope
@key.scope.should == @scope
@key.scope.to_s.should == @scope
# date
@key.date.to_time.to_s.should == @date.to_s
@date = Time.now