spec/pickle/path_spec.rb in pickle-0.4.11 vs spec/pickle/path_spec.rb in pickle-0.5.0
- old
+ new
@@ -5,96 +5,96 @@
describe Pickle::Path do
include Pickle::Path
describe "#path_to_pickle, when the model doesn't exist" do
before do
- stub!(:model).and_return(nil)
+ allow(self).to receive(:model).and_return(nil)
end
it "('that user', :extra => 'new comment') should raise the error raised by model!" do
- lambda { path_to_pickle "that user", "new comment" }.should raise_error(RuntimeError, 'Could not figure out a path for ["that user", "new comment"] {}')
+ expect { path_to_pickle "that user", "new comment" }.to raise_error(RuntimeError, 'Could not figure out a path for ["that user", "new comment"] {}')
end
end
describe "#path_to_pickle" do
describe "when model returns a user" do
let :user_class do
- mock 'User', :name => 'User'
+ double 'User', :name => 'User'
end
let :user do
- mock 'user', :class => user_class
+ double 'user', :class => user_class
end
before do
- stub!(:model).and_return(user)
+ allow(self).to receive(:model).and_return(user)
end
it "('a user', 'the user: \"fred\"') should retrieve 'a user', and 'the user: \"fred\"' models" do
- should_receive(:model).with('a user')
- should_receive(:model).with('the user: "fred"')
- stub!(:user_user_path).and_return('the path')
- path_to_pickle('a user', 'the user: "fred"').should == 'the path'
+ expect(self).to receive(:model).with('a user')
+ expect(self).to receive(:model).with('the user: "fred"')
+ allow(self).to receive(:user_user_path).and_return('the path')
+ expect(path_to_pickle('a user', 'the user: "fred"')).to eq('the path')
end
it "('a user', :action => 'foo') should return foo_user_path(<user>)" do
- should_receive(:foo_user_path).with(user).and_return('the path')
- path_to_pickle('a user', :action => 'foo').should == 'the path'
+ expect(self).to receive(:foo_user_path).with(user).and_return('the path')
+ expect(path_to_pickle('a user', :action => 'foo')).to eq('the path')
end
it "('a user', :action => 'foo') should raise informative error if foo_user_path not defined" do
- should_receive(:foo_user_path).with(user).and_raise(NoMethodError)
- lambda { path_to_pickle('a user', :action => 'foo') }.should raise_error(Exception, /Could not figure out a path for/)
+ expect(self).to receive(:foo_user_path).with(user).and_raise(NoMethodError)
+ expect { path_to_pickle('a user', :action => 'foo') }.to raise_error(Exception, /Could not figure out a path for/)
end
it "('a user', :segment => 'foo') should return user_foo_path(<user>)" do
- should_receive(:user_foo_path).with(user).and_return('the path')
- path_to_pickle('a user', :segment => 'foo').should == 'the path'
+ expect(self).to receive(:user_foo_path).with(user).and_return('the path')
+ expect(path_to_pickle('a user', :segment => 'foo')).to eq('the path')
end
it "('a user', :segment => 'foo') should raise informative error if foo_user_path not defined" do
- should_receive(:user_foo_path).with(user).and_raise(NoMethodError)
- lambda { path_to_pickle('a user', :segment => 'foo') }.should raise_error(Exception, /Could not figure out a path for/)
+ expect(self).to receive(:user_foo_path).with(user).and_raise(NoMethodError)
+ expect { path_to_pickle('a user', :segment => 'foo') }.to raise_error(Exception, /Could not figure out a path for/)
end
it "('a user', :action => 'new', :segment => 'comment') should return new_user_comment_path(<user>)" do
- should_receive(:new_user_comment_path).with(user).and_return('the path')
- path_to_pickle('a user', :segment => 'comment', :action => 'new').should == 'the path'
+ expect(self).to receive(:new_user_comment_path).with(user).and_return('the path')
+ expect(path_to_pickle('a user', :segment => 'comment', :action => 'new')).to eq('the path')
end
it "('a user', :action => 'new', :segment => 'comment') should raise informative error if new_user_comment_path not defined" do
- should_receive(:new_user_comment_path).with(user).and_raise(NoMethodError)
- lambda { path_to_pickle('a user', :action => 'new', :segment => 'comment') }.should raise_error(Exception, /Could not figure out a path for/)
+ expect(self).to receive(:new_user_comment_path).with(user).and_raise(NoMethodError)
+ expect { path_to_pickle('a user', :action => 'new', :segment => 'comment') }.to raise_error(Exception, /Could not figure out a path for/)
end
it "('a user', :extra => 'new comment') should return new_user_comment_path(<user>)" do
- should_receive(:new_user_comment_path).with(user).and_return('the path')
- path_to_pickle('a user', :extra => 'new comment').should == 'the path'
+ expect(self).to receive(:new_user_comment_path).with(user).and_return('the path')
+ expect(path_to_pickle('a user', :extra => 'new comment')).to eq('the path')
end
it "('a user', :extra => 'new comment') should raise informative error if new_user_comment_path not defined" do
- should_receive(:new_user_comment_path).with(user).and_raise(NoMethodError)
- lambda { path_to_pickle('a user', :extra => 'new comment') }.should raise_error(Exception, /Could not figure out a path for/)
+ expect(self).to receive(:new_user_comment_path).with(user).and_raise(NoMethodError)
+ expect { path_to_pickle('a user', :extra => 'new comment') }.to raise_error(Exception, /Could not figure out a path for/)
end
describe "when args is a list of pickle and non pickle models" do
before do
- stub!(:model).with("account").and_return(nil)
+ allow(self).to receive(:model).with("account").and_return(nil)
end
it "('account', 'the user') should return account_user_path(<user>)" do
- should_receive(:account_user_path).with(user).and_return("the path")
- path_to_pickle('account', 'the user').should == 'the path'
+ expect(self).to receive(:account_user_path).with(user).and_return("the path")
+ expect(path_to_pickle('account', 'the user')).to eq('the path')
end
end
describe "(private API)" do
it "('a user', :extra => 'new ish comment') should try combinations of 'new', 'ish', 'comment'" do
- should_receive(:pickle_path_for_resources_action_segment).with([user], '', 'new_ish_comment').once
- should_receive(:pickle_path_for_resources_action_segment).with([user], 'new', 'ish_comment').once
- should_receive(:pickle_path_for_resources_action_segment).with([user], 'new_ish', 'comment').once
- should_receive(:pickle_path_for_resources_action_segment).with([user], 'new_ish_comment', '').once
- lambda { path_to_pickle('a user', :extra => 'new ish comment') }.should raise_error(Exception, /Could not figure out a path for/)
+ expect(self).to receive(:pickle_path_for_resources_action_segment).with([user], '', 'new_ish_comment').once
+ expect(self).to receive(:pickle_path_for_resources_action_segment).with([user], 'new', 'ish_comment').once
+ expect(self).to receive(:pickle_path_for_resources_action_segment).with([user], 'new_ish', 'comment').once
+ expect(self).to receive(:pickle_path_for_resources_action_segment).with([user], 'new_ish_comment', '').once
+ expect { path_to_pickle('a user', :extra => 'new ish comment') }.to raise_error(Exception, /Could not figure out a path for/)
end
end
end
end
end
\ No newline at end of file