title: RSpec 'Expect' Syntax and Idiomatic attribute spec
body: <p>This should have an easy answer but I'm struggling to find it (have checked RSpec documentation, EverydayRails Testing with RSpec, Google results). In my model specs I like to include basic attribute specs as follows:</p>
  
  <pre><code>describe Foo do
    describe "basic attributes" do
      before { @foo = create(:foo) }
      subject { @foo }
  
      it { should be_valid }
      it { should respond_to(:color) }
      it { should respond_to(:height) }
      it { should respond_to(:some_other_attribute) }
      it { should respond_to(:you_get_the_idea) }
      ...
  </code></pre>
  
  <p>I like these specs because if there is some kind of error within my factory and/or model these specs help me pinpoint it quickly.</p>
  
  <p>I've incorporated the <code>expect</code> syntax into all other specs and I like how it reads, but how to use it here? One option might be </p>
  
  <pre><code>expect(@foo).to respond_to(:color)
  </code></pre>
  
  <p>And another might be</p>
  
  <pre><code>expect(it).to respond_to(:color)
  </code></pre>
  
  <p>The former involves duplication that is avoided with the <code>should</code> syntax, but the latter looks strange to me (which could just be me).</p>
  
  <p>I realize this question is more about style than functionality*, but we Ruby developers are conscientious about style, and I want to adhere to standard practices and have readable, idiomatic code. Any help is appreciated. Thanks.</p>
  
  <p>UPDATE:  Neither of my proposed options actually work, by the way. They both throw <code>undefined method 'expect'</code> errors. Now I'm really confused! </p>
  
  <p>Having thought about the error, I realize it's because the <code>should</code> specs above are within one-line block. The confusion, then, is how can I write a single-line block with the expect syntax? In light of this update, the question is very much about functionality and I'll be excited to hear others' thoughts.</p>
  
  <p>4/2015 UPDATE</p>
  
  <p><code>rspec &gt; 3.0</code> has added yet another way of handling these, and it sounds like <code>rspec ~&gt; 4.0</code> will do away with the <code>should</code> syntax. Per Myron Masters:</p>
  
  <blockquote>
    <p>Some users have expressed confusion about how this should relates to the expect syntax and if you can continue using it. It will continue to be available in RSpec 3 (again, regardless of your syntax configuration), but we've also added an alternate API that is a bit more consistent with the expect syntax:</p>
  </blockquote>
  
  <pre><code>describe Post do
    it { is_expected.to allow_mass_assignment_of(:title) }
  end
  </code></pre>
  
  <blockquote>
    <p>is_expected is defined very simply as expect(subject) and also supports negative expectations via is_expected.not_to matcher.
    [...]<br>
    In RSpec 3, we've kept the should syntax, and it is available by default, but you will get a deprecation warning if you use it without explicitly enabling it. This will pave the way for it being disabled by default (or potentially extracted into a seperate gem) in RSpec 4, while minimizing confusion for newcomers coming to RSpec via an old tutorial.</p>
  </blockquote>