spec/strategy_spec.rb in virility-0.1.4 vs spec/strategy_spec.rb in virility-0.2.0
- old
+ new
@@ -9,92 +9,92 @@
# Initialization
#
context "initialization" do
it "should raise an error if a URL is not set" do
- lambda {Virility::Strategy.new}.should raise_error
+ expect{Virility::Strategy.new}.to raise_error(ArgumentError, "wrong number of arguments (0 for 1)")
end
it "should set and encode the url" do
- Virility::Facebook.new(@url).url.should == "http%3A%2F%2Fcreativeallies.com"
+ expect(Virility::Facebook.new(@url).url).to eq("http%3A%2F%2Fcreativeallies.com")
end
end
#
# Interface
#
context "interface" do
it "should raise an error on poll" do
- lambda { Virility::Strategy.new(@url).poll }.should raise_error
+ expect{ Virility::Strategy.new(@url).poll }.to raise_error(RuntimeError, "Abstract Method census called on Virility::Strategy - Please define this method")
end
it "should raise an error on count" do
- lambda { Virility::Strategy.new(@url).count }.should raise_error
+ expect{ Virility::Strategy.new(@url).count }.to raise_error(RuntimeError, "Abstract Method count called on Virility::Strategy - Please define this method")
end
end
#
# Dynamic Methods
#
describe "dynamic methods" do
before(:each) do
@virility = Virility::Facebook.new(@url)
- @virility.stub(:results).and_return(Virility::FB_RESULTS)
+ allow(@virility).to receive(:results) { Virility::FB_RESULTS }
end
context "overall testing" do
Virility::FB_RESULTS.each do |key, value|
it "should return #{value} when get_result is called with #{key}" do
- @virility.send(key).should == value
+ expect(@virility.send(key)).to eq(value)
end
end
Virility::FAKE_FB_RESULTS.each do |key|
it "should_not raise an error if the result (#{key}) does not exist" do
- lambda { @virility.send(key) }.should_not raise_error
+ expect{ @virility.send(key) }.not_to raise_error
end
-
+
it "should return 0 if the result (#{key}) does not exist" do
- @virility.send(key).should == 0
+ expect(@virility.send(key)).to eq(0)
end
end
end
context "result_exists?" do
before(:each) do
@virility = Virility::Facebook.new(@url)
- @virility.stub(:results).and_return(Virility::FB_RESULTS)
+ allow(@virility).to receive(:results) { Virility::FB_RESULTS }
end
Virility::FB_RESULTS.keys.each do |result|
it "should return true for #{result}" do
- @virility.result_exists?(result).should be true
+ expect(@virility.result_exists?(result)).to eq(true)
end
end
Virility::FAKE_FB_RESULTS.each do |result|
it "should return false for #{result}" do
- @virility.result_exists?(result).should be false
+ expect(@virility.result_exists?(result)).to eq(false)
end
end
end
context "get_result" do
Virility::FB_RESULTS.each do |key, value|
it "should return #{value} when get_result is called with #{key}" do
- @virility.get_result(key).should == value
+ expect(@virility.get_result(key)).to eq(value)
end
end
Virility::FAKE_FB_RESULTS.each do |key|
it "should_not raise an error if the result (#{key}) does not exist" do
- lambda { @virility.send(key) }.should_not raise_error
+ expect{ @virility.send(key) }.not_to raise_error
end
-
+
it "should return 0 if the result (#{key}) does not exist" do
- @virility.send(key).should == 0
+ expect(@virility.send(key)).to eq(0)
end
end
end
end