私はrailsとrspecを学んでおり、これら2つのコードの違いを理解しないでください。
私のspec/models / user_spec.rbには次のものがあります:
describe User do$
before { @user = User.new(name: "Example User", email: "user@example.com") }
subject {@user}
名前の形式を確認します。
describe "when name has wrong format" do
it "should not be valid" do
names = %w[%marcin ??? 123 ___123 ___]
names.each do |invalid_name|
@user.name = invalid_name
it{should_not be_valid}
end
end
end
@user.should_not be_valid
動作していませんが、動作する代わりに使用するとit{should_not be_valid}
、理由がわからないので 、同じ意味subject {@user}
だと思いましたit {should
@user.should