5f0c815256
I basically went through all specs and applied the following rules: * Use `describe` for methods and `context` for contexts. * All class methods starts with `.` and instance methods with `#`. * Removed all `it should`, because the specs _have to_. * Applied a consistant naming on all listener specs. * Make fixture usage more fail save by giving generous sleep times. * Make all behaviour description non-technical and easy to understand. The goal of this excercise was to have a documentation that is easy readable and describes the behaviour and not the implementation. Try it out by using the RSpec documentation format!
58 lines
1.5 KiB
Ruby
58 lines
1.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Guard::Notifier do
|
|
subject { Guard::Notifier }
|
|
|
|
describe ".notify" do
|
|
before(:each) { subject.turn_on }
|
|
after(:each) { subject.turn_off }
|
|
|
|
if mac?
|
|
if growl_installed?
|
|
it "uses Growl on Mac OS X" do
|
|
Growl.should_receive(:notify).with("great",
|
|
:title => "Guard",
|
|
:icon => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s,
|
|
:name => "Guard"
|
|
)
|
|
subject.notify 'great', :title => 'Guard'
|
|
end
|
|
else
|
|
it { should_not be_enabled }
|
|
end
|
|
end
|
|
|
|
if linux?
|
|
if libnotify_installed?
|
|
it "uses Libnotify on Linux" do
|
|
Libnotify.should_receive(:show).with(
|
|
:body => "great",
|
|
:summary => 'Guard',
|
|
:icon_path => Pathname.new(File.dirname(__FILE__)).join('../../images/success.png').to_s
|
|
)
|
|
subject.notify 'great', :title => 'Guard'
|
|
end
|
|
else
|
|
it { should_not be_enabled }
|
|
end
|
|
end
|
|
end
|
|
|
|
describe ".turn_off" do
|
|
if mac? && growl_installed?
|
|
it "prevents the notifications" do
|
|
Growl.should_not_receive(:notify)
|
|
subject.notify 'great', :title => 'Guard'
|
|
end
|
|
elsif linux? && libnotify_installed?
|
|
it "prevents the notifications" do
|
|
Libnotify.should_not_receive(:show)
|
|
subject.notify 'great', :title => 'Guard'
|
|
end
|
|
end
|
|
|
|
it { should_not be_enabled }
|
|
end
|
|
|
|
end
|