rspec должен включать попытки разбить массив - PullRequest
2 голосов
/ 18 марта 2012

Используя Rails 3.2.2, я только что установил rspec и попробовал свой первый тест:

require 'spec_helper'

describe "Mains" do
  describe "GET index" do
    it "gets the page which has the proper content" do
      get 'index.html'
      response.status.should be(200)
      response.body.should include("one")
    end
  end
end

Когда я запускаю спецификацию, я получаю

Failures:

  1) Mains GET index gets the page which has the proper content
     Failure/Error: response.body.should include("one")
     NoMethodError:
       undefined method `chomp' for ["one"]:Array

Это происходит из-за Рейскейст Райана Бейтса 257 , так что я немного растерялся

заранее спасибо,

1 Ответ

4 голосов
/ 02 апреля 2012

[РЕДАКТИРОВАТЬ] Проблема исправлена ​​ в rspec-expectations, в master ветви. Вы можете исправить это, используя это в вашем Gemfile:

gem 'rspec-rails', '~> 2.9'
gem 'rspec-expectations', :git => "https://github.com/rspec/rspec-expectations.git", :branch => 'master'

Я столкнулся с той же проблемой на Rails 3.0.12 с rspec 2.9.0. Возвращаясь к rspec 2.8.0 / rspec-rails 2.8.1 сделал свое дело.

Я поднял проблему на Github , rspec/rspec-expectations, посмотрим, действительно ли это ошибка.

Для справки, это определение шага:

Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
  current_email.default_part_body.to_s.should include(text)
end

... шаг в функции:

step %{I should see "changer de mot de passe" in the email body}

... который поднимал:

undefined method `chomp' for ["changer de mot de passe"]:Array (NoMethodError)
  ./features/step_definitions/email_steps.rb:110:in `/^(?:I|they) should see "([^"]*?)" in the email body$/'
...