title: wrong number of arguments ruby rspec
body: <p>I'm trying to write unit tests for my code using rspec.  I keep getting a "wrong number of arguments" error:</p>
  
  <pre><code>class MyClass
    attr_accessor :env, :company,:size, :role, :number_of_hosts,:visability
  
    def initialize(env, company, size, role, number_of_hosts, visability)
      @env, @company, @size, @role, @number_of_hosts, @visability =  env, company, size, role, number_of_hosts, visability
    end
  
  
  
  
  end
  </code></pre>
  
  <p>And here are my tests:</p>
  
  <pre><code>require_relative "../lib/MyClass.rb"
  
   describe MyClass do
      it "has an environment" do
          MyClass.new("environment").env.should respond_to :env
      end
  
      it "has a company" do
          MyClass.new("company").company.should respond_to :company
      end
  
  ...
  </code></pre>
  
  <p>When I run rspec I get: </p>
  
  <pre><code>1) MyClass has an environment
       Failure/Error: MyClass.new("environment").env.should respond_to :env
       ArgumentError:
         wrong number of arguments (1 for 6)
       # ./lib/MyClass.rb:4:in `initialize'
       # ./spec/MyClass_spec.rb:5:in `new'
       # ./spec/MyClass_spec.rb:5:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>...</p>
  
  <p>What am I missing?</p>
  
  <p>EDIT</p>
  
  <p>Sergio helped thanks...however</p>
  
  <p>Sergio's answer worked...although I still have a further question:</p>
  
  <p>Given the Class:</p>
  
  <pre><code>class Team
      attr_accessor :name, :players
  
      def initialize(name, players = [])
          raise Exception unless players.is_a? Array
  
          @name = name
          raise Exception if @name &amp;&amp; has_bad_name
  
          @players = players
      end
  
      def has_bad_name
          list_of_words = %w{crappy bad lousy}
          list_of_words - @name.downcase.split(" ") != list_of_words
      end
  
      def favored?
          @players.include? "George Clooney"
      end
  
  end
  </code></pre>
  
  <p>and spec...</p>
  
  <pre><code>require_relative "../lib/team.rb"
  
  describe Team do
      it "has a name" do
          Team.new("random name").should respond_to :name
      end
  
      it "has a list of players" do
          Team.new("random name").players.should be_kind_of Array
      end
  </code></pre>
  
  <p>...</p>
  
  <p>The tests pass without the same error...(This works fine: Team.new("random name"))</p>
  
  <p>Any explanation?</p>