spec/unit/pr/active_form_spec.rb in pr-0.0.6 vs spec/unit/pr/active_form_spec.rb in pr-0.0.7
- old
+ new
@@ -13,15 +13,15 @@
before do
stub_const 'PR::DefineAndRegister', double
end
it 'sets up field to define fields' do
- PR::DefineAndRegister.should_receive(:[]).with form_klass, name, type, {}
+ expect(PR::DefineAndRegister).to receive(:[]).with form_klass, name, type, {}
form_klass.field name, type
end
it 'sets up field to define fields and passes in options' do
- PR::DefineAndRegister.should_receive(:[]).with form_klass, name, type, my: :option
+ expect(PR::DefineAndRegister).to receive(:[]).with form_klass, name, type, my: :option
form_klass.field name, type, my: :option
end
it 'sets up an id' do
form = form_klass.new
@@ -31,48 +31,48 @@
describe 'and makes the form ActiveModel compliant' do
let(:form) { form_klass.new }
subject { form }
- it { should respond_to :id }
- it { should respond_to :valid? }
- it { should respond_to :errors }
+ it { is_expected.to respond_to :id }
+ it { is_expected.to respond_to :valid? }
+ it { is_expected.to respond_to :errors }
it 'has a model name' do
expect(form_klass.model_name).to eq "TestForm"
expect(form_klass.model_name).to be_a ActiveModel::Name
end
- its(:to_model) { should eq form }
- its(:to_partial_path) { should eq 'testforms/testform' }
+ specify { expect(subject.to_model).to eq form }
+ specify { expect(subject.to_partial_path).to eq 'testforms/testform' }
describe 'when not persisted' do
- its(:persisted?) { should be_false }
- its(:to_key) { should be_nil }
- its(:to_param) { should be_nil }
+ specify { expect(subject.persisted?).to be false }
+ specify { expect(subject.to_key).to be nil }
+ specify { expect(subject.to_param).to be nil }
end
describe 'when persisted' do
before do
form.id = 100
end
- its(:persisted?) { should be_true }
- its(:to_key) { should eq [:id] }
- its(:to_param) { should == "100" }
+ specify { expect(subject.persisted?).to be true }
+ specify { expect(subject.to_key).to eq [:id] }
+ specify { expect(subject.to_param).to eq "100" }
end
end
describe 'and responds to ActiveModel errors' do
let(:errors) { double }
let(:form) { form_klass.new }
- before { ActiveModel::Errors.stub(:new).and_return(errors) }
+ before { allow(ActiveModel::Errors).to receive(:new).and_return(errors) }
subject { form.errors }
it 'creates active model errors with itself' do
- ActiveModel::Errors.should_receive(:new).with form
+ expect(ActiveModel::Errors).to receive(:new).with form
form.errors
end
it 'returns the errors object' do
expect(form.errors).to eq errors
end