spec/fspath/mac_spec.rb in fspath-mac-1.0.0 vs spec/fspath/mac_spec.rb in fspath-mac-2.0.0
- old
+ new
@@ -15,87 +15,81 @@
end
end
describe "finder labels" do
describe "getting" do
- it "should call label_index.get on mac_finder_alias" do
+ it "should call finder_label_number" do
@path = FSPath('to_label')
- @finder_alias = mock(:finder_alias)
- @label_index = mock(:label_index)
- @path.should_receive(:mac_finder_alias).and_return(@finder_alias)
- @finder_alias.should_receive(:label_index).and_return(@label_index)
- @label_index.should_receive(:get).and_return(0)
+ @path.should_receive(:finder_label_number).and_return(0)
@path.finder_label
end
it "should return apporitate label" do
@path = FSPath('to_label')
- @finder_alias = mock(:finder_alias)
- @label_index = mock(:label_index)
- @path.stub!(:mac_finder_alias).and_return(@finder_alias)
- @finder_alias.stub!(:label_index).and_return(@label_index)
-
FSPath::FINDER_LABEL_COLORS.each_with_index do |label, index|
- @label_index.stub!(:get).and_return(index)
+ @path.stub!(:finder_label_number).and_return(index)
@path.finder_label.should == label
end
end
end
describe "setting" do
- it "should call label_index.set on mac_finder_alias" do
+ it "should call finder_label_number=" do
@path = FSPath('to_label')
- @finder_alias = mock(:finder_alias)
- @label_index = mock(:label_index)
- @path.should_receive(:mac_finder_alias).and_return(@finder_alias)
- @finder_alias.should_receive(:label_index).and_return(@label_index)
- @label_index.should_receive(:set)
+ @path.should_receive(:finder_label_number=)
@path.finder_label = nil
end
describe "index" do
before do
@path = FSPath('to_label')
- @finder_alias = mock(:finder_alias)
- @label_index = mock(:label_index)
-
- @path.stub!(:mac_finder_alias).and_return(@finder_alias)
- @finder_alias.stub!(:label_index).and_return(@label_index)
end
it "should call label_index.set with apporitate index" do
FSPath::FINDER_LABEL_COLORS.each_with_index do |label, index|
- @label_index.should_receive(:set).with(index).ordered
+ @path.should_receive(:finder_label_number=).with(index).ordered
@path.finder_label = label
end
end
it "should accept aliases" do
FSPath::FINDER_LABEL_COLOR_ALIASES.each do |label_alias, label|
index = FSPath::FINDER_LABEL_COLORS.index(label)
- @label_index.should_receive(:set).with(index).ordered
+ @path.should_receive(:finder_label_number=).with(index).ordered
@path.finder_label = label_alias
end
end
it "should set to none when called with nil or false" do
- [nil, false].each do |label|
- @label_index.should_receive(:set).with(0).ordered
- @path.finder_label = label
- end
+ @path.should_receive(:finder_label_number=).with(0).ordered
+ @path.finder_label = nil
end
it "should raise when called with something else" do
[true, :shitty, 'hello'].each do |label|
proc do
@path.finder_label = label
end.should raise_error("Unknown label #{label.inspect}")
end
+ end
+ end
+ end
+
+ describe "number" do
+ it "should set label" do
+ @path = FSPath.temp_file_path
+
+ mac_finder_alias_colors = [nil, :orange, :red, :yellow, :blue, :purple, :green, :grey]
+ 8.times do |label_number|
+ @path.send(:finder_label_number=, label_number)
+ @path.send(:finder_label_number).should == label_number
+ color = mac_finder_alias_colors[@path.mac_finder_alias.label_index.get]
+ FSPath::Mac::FINDER_LABEL_COLORS.index(color).should == label_number
end
end
end
end