diff --git a/spec/poros/run_strategy_spec.rb b/spec/poros/run_strategy_spec.rb new file mode 100644 index 0000000..4d29d68 --- /dev/null +++ b/spec/poros/run_strategy_spec.rb @@ -0,0 +1,15 @@ +require "spec_helper" + +describe Alloy::Poros::RunStrategy do + subject { described_class.new nil, nil } + + it { subject.should allow_public_access_for_methods :now } + + describe "#now" do + it "should invoke formed_strategy" do + subject.should_receive(:strategy_formed).once + + subject.now + end + end +end \ No newline at end of file diff --git a/spec/poros/schedule_strategy_spec.rb b/spec/poros/schedule_strategy_spec.rb new file mode 100644 index 0000000..6589f99 --- /dev/null +++ b/spec/poros/schedule_strategy_spec.rb @@ -0,0 +1,36 @@ +require "spec_helper" + +describe Alloy::Poros::ScheduleStrategy do + subject { described_class.new nil, nil } + + it { subject.should allow_public_access_for_methods :every } + + describe "#every" do + it "should return the every duration" do + subject.should_receive(:strategy_formed).once + subject.every 5 + + subject.every.should be 5 + end + + context "when a duration is specified" do + it "should set the every duration" do + subject.should_receive(:strategy_formed).once + subject.every 7 + + subject.every.should be 7 + end + it "should invoke formed_strategy" do + subject.should_receive(:strategy_formed).once + + subject.every 9 + end + + context "when duration is less than one" do + it "should raise an argument error" do + expect { subject.every 0 }.to raise_error ArgumentError, "an 'every' duration cannot be less than 1" + end + end + end + end +end \ No newline at end of file diff --git a/spec/poros/strategy_spec.rb b/spec/poros/strategy_spec.rb new file mode 100644 index 0000000..4916e43 --- /dev/null +++ b/spec/poros/strategy_spec.rb @@ -0,0 +1,38 @@ +require "spec_helper" + +describe Alloy::Poros::Strategy do + subject { described_class.new Class, nil } + + it { subject.should allow_public_access_for_methods :clazz, :in } + + describe "#clazz" do + it "should return the clazz" do + subject.clazz.should be Class + end + end + + describe "#in" do + it "should return the in duration" do + subject.in 5 + + subject.in.should be 5 + end + + context "when a duration is specified" do + it "should set the in duration" do + subject.in 7 + + subject.in.should be 7 + end + it "should return itself" do + subject.in(9).should be subject + end + + context "when duration is less than one" do + it "should raise an argument error" do + expect { subject.in 0 }.to raise_error ArgumentError, "an 'in' duration cannot be less than 1" + end + end + end + end +end \ No newline at end of file