Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:43:56+00:00 2026-06-11T00:43:56+00:00

With the new expect syntax in rspec-2.11, how is it possible to use the

  • 0

With the new expect syntax in rspec-2.11, how is it possible to use the implicit subject? Is there a better way than explicitly referencing subject, like below?

describe User do
  it 'is valid' do
    expect(subject).to be_valid    # <<< can `subject` be implicit?
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:43:58+00:00Added an answer on June 11, 2026 at 12:43 am

    If you configure RSpec to disable the should syntax, you can still use the old one-liner syntax, since that doesn’t involve should being added to every object:

    describe User do
      it { should be_valid }
    end
    

    We briefly discussed an alternate one-liner syntax, but decided against it since it wasn’t needed and we felt like it might add confusion. You can, however, easily add this yourself if you prefer how it reads:

    RSpec.configure do |c|
      c.alias_example_to :expect_it
    end
    
    RSpec::Core::MemoizedHelpers.module_eval do
      alias to should
      alias to_not should_not
    end
    

    With this in place, you could write this as:

    describe User do
      expect_it { to be_valid }
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to do some form of expect NEW in rhino mock. Example:
I'm developing a syntax analyzer by hand in Java, and I'd like to use
I am new to using expect, and I've searched for an answer to the
I would expect a Dictionary object of the form: var dict = new Dictionary<string,string>()
interval = new Date(0); return interval.getHours(); The above returns 16. I expect it to
See this code: TicketStoreService fakeTicketStoreService = MockRepository.GenerateMock<TicketStoreService>(); fakeTicketStoreService.Expect(service => service.DoSomething(Arg.Is(new Guid())) .Return(new Guid()); fakeTicketStoreService.DoSomething(Arg.Is(new
I'm not too new to VB.Net and the syntax, but I'm not an expert.
I am struggling a bit to understand how the new AAA syntax works in
The new hash syntax in Ruby 1.9.2 means that I can do the following:
First, I am very new to lisp, so it is possible that I'm just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.