2013-07-21 3 views
0

У меня есть простой класс ресторан, который выглядит следующим образом:Factory Girl + Rspec: ArgumentError: неверное число аргументов (0 для 2)

module Restaurant 
    class Identity 

     attr_reader :name, :location 

     def initialize (name, location) 
      @name = name 
      @location = location 
     end 

    end 
end 

Моя фабрика выглядит следующим образом:

FactoryGirl.define do 
    factory :restaurant, :class => Restaurant::Identity do |f| 
     f.name "Alfredos" 
     f.location "Andheri" 
    end 
end 

И мой тест пишется так:

describe Restaurant::Identity do 

subject { build(:restaurant) } 

its(:name) {should_not be_nil} 
its(:location) {should_not be_nil} 

end 

Но когда я запускаю это, я получаю

1) Restaurant::Identity name 
    Failure/Error: subject { build(:restaurant) } 
    ArgumentError: 
     wrong number of arguments (0 for 2) 
    # ./lib/restaurant.rb:7:in `initialize' 
    # ./spec/restaurant_spec.rb:9:in `block (2 levels) in <top (required)>' 
    # ./spec/restaurant_spec.rb:11:in `block (2 levels) in <top (required)>' 

Почему это происходит? Что я делаю не так?

ответ

Смежные вопросы