У меня есть некоторые тесты RSpec, где я переменные Выполняется инициализация let
:Rspec: пусть не работает
describe 'methods' do
let(:order) { Order.new }
let(:event_1) { FactoryGirl.create(:event) }
let(:event_2) { FactoryGirl.create(:event) }
context 'should checks if any event is paid' do
order.events << event_1
order.events << event_2
order.events_paid?.should == true
end
context 'should write aasm state' do
order.aasm_write_state('new')
order.state.CanonicalName.should == 'new'
end
end
Но я получаю сообщение об ошибке 'method_missing': 'order' is not available on an example group (e.g. a 'describe' or 'context' block). It is only available from within individual examples (e.g. 'it' blocks) or from constructs that run in the scope of an example (e.g. 'before', 'le', etc). (RSpec::Core::ExampleGroup::WrongScopeError)
Почему let
инициализация не работает?
Спасибо за совет, я изменил имя переменной 'order', но я все равно получаю ту же ошибку –
ах, только что понял, в чем проблема ... проверить отредактированный ответ – apneadiving
это квинтэссенсивный ответ stackoverflow .." несколько вопросов не соответствуют вашему вопросу, и о, как изменил api, так что обновите свой код « – austinheiman