title: mock Rails.env.development? using rspec
body: <p>I am writing a unit test using rspec.</p>
  
  <p>I would like to mock Rails.env.develepment? to return true. How could I achieve this?.</p>
  
  <p>I tried this </p>
  
  <pre><code>Rails.env.stub(:development?, nil).and_return(true)
  </code></pre>
  
  <p>it throws this error</p>
  
  <pre><code>activesupport-4.0.0/lib/active_support/string_inquirer.rb:22:in `method_missing': undefined method `any_instance' for "test":ActiveSupport::StringInquirer (NoMethodError)
  </code></pre>
  
  <p>Update
  ruby version ruby-2.0.0-p353,
  rails 4.0.0,
  rspec 2.11</p>
  
  <pre><code>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
  </code></pre>