mock Rails.env.development? za pomocą rspec
Piszę test jednostkowy za pomocą rspec.
Chciałbym wyrecytować Rails.env.develepment? zwracać prawdę. Jak mogłem to osiągnąć ?.
Próbowałem tego
Rails.env.stub(:development?, nil).and_return(true)
to zgłasza ten błąd
activesupport-4.0.0/lib/active_support/string_inquirer.rb:22:in `method_missing': undefined method `any_instance' for "test":ActiveSupport::StringInquirer (NoMethodError)
Zaktualizuj ruby w wersji ruby-2.0.0-p353, rails 4.0.0, rspec 2.11
describe "welcome_signup" do
let(:mail) { Notifier.welcome_signup user }
describe "in dev mode" do
Rails.env.stub(:development?, nil).and_return(true)
let(:mail) { Notifier.welcome_signup user }
it "send an email to" do
expect(mail.to).to eq([GlobalConstants::DEV_EMAIL_ADDRESS])
end
end
end