title: Writing specs for a class that behaves differently depending upon constructor arguments
body: <p>If you have a class that responds differently depending upon constructor arguments, how do you go about writing a spec for that class?</p>
  
  <pre><code>class Route
  {
    function __construct($url, array $methods = array())
    {
      // stores methods and url in private member variables
      // creates a regex to match $url against incoming request URLs
    }
  
    public function isMatch($url)
    {
      // checks if the incoming request url matches against this url
    }
  }
  </code></pre>
  
  <p>Example use:</p>
  
  <pre><code>$a = new Route('/users/:id');
  $a-&gt;isMatch('/users/1') // returns true;
  $b = new Route('/users');
  $b-&gt;isMatch('/users') // returns true
  </code></pre>
  
  <p>If I set up my spec for this class using the let function from phpspec:</p>
  
  <pre><code>class Route extends ObjectBehaviour
  {
    function let() 
    {
      $this-&gt;beConstructedWith('/users/:id')
    }
  }
  </code></pre>
  
  <p>My spec can only check if the behaviour of this class works in one of the cases.</p>
  
  <p>I've contemplated adding setter methods to allow me to test around this, but it seems like I'd be breaking encapsulation for the purpose of testing.</p>
  
  <p>I'm struggling to find anything that touches upon this, so I'm started to think that maybe this is bad code smell situation.</p>