Witam piszę testy rspec (pierwszy raz mam z tym styczność)
oto kod pliku home_controller_spec.rb
require "rails_helper"
describe HomeController do
describe "GET #index" do
it "responds successfully" do
get :index
expect(response).to be_success
it "renders index template" do
get :index
expect(response).to render_template(:index)
end
end
end
describe "GET #about" do
it "responds successfully" do
get :about
expect(response).to be_success
it "renders about template" do
get :about
expect(response).to render_template(:about)
end
end
end
describe "GET #terms" do
it "responds successfully" do
get :terms
expect(response).to be_success
it "renders terms template" do
get :terms
expect(response).to render_template(:terms)
end
end
end
end
Wywala mi taki błąd a powinno zaliczyć 6 przykładów i 0 błędów
rspec
WARN: Unresolved specs during Gem::Specification.reset:
minitest (~> 5.1)
nokogiri (>= 1.5.9, >= 1.6)
builder (~> 3.1)
rake (>= 0.8.7)
thor (< 2.0, >= 0.18.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/version.rb:4: warning: already initialized constant JSON::VERSION
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/version.rb:3: warning: previous definition of VERSION was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/version.rb:5: warning: already initialized constant JSON::VERSION_ARRAY
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/version.rb:4: warning: previous definition of VERSION_ARRAY was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/version.rb:6: warning: already initialized constant JSON::VERSION_MAJOR
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/version.rb:5: warning: previous definition of VERSION_MAJOR was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/version.rb:7: warning: already initialized constant JSON::VERSION_MINOR
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/version.rb:6: warning: previous definition of VERSION_MINOR was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/version.rb:8: warning: already initialized constant JSON::VERSION_BUILD
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/version.rb:7: warning: previous definition of VERSION_BUILD was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/common.rb:100: warning: already initialized constant JSON::NaN
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/common.rb:99: warning: previous definition of NaN was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/common.rb:102: warning: already initialized constant JSON::Infinity
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/common.rb:101: warning: previous definition of Infinity was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/common.rb:104: warning: already initialized constant JSON::MinusInfinity
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/common.rb:103: warning: previous definition of MinusInfinity was here
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/2.3.0/json/common.rb:129: warning: already initialized constant JSON::UnparserError
/home/piotr/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/lib/json/common.rb:128: warning: previous definition of UnparserError was here
FFF
Failures:
1) HomeController GET #index responds successfully
Failure/Error:
it "renders index template" do
get :index
expect(response).to render_template(:index)
end
`it` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
# ./spec/controllers/home_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
2) HomeController GET #about responds successfully
Failure/Error:
it "renders about template" do
get :about
expect(response).to render_template(:about)
end
`it` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
# ./spec/controllers/home_controller_spec.rb:17:in `block (3 levels) in <top (required)>'
3) HomeController GET #terms responds successfully
Failure/Error:
it "renders terms template" do
get :termss
expect(response).to render_template(:terms)
end
`it` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
# ./spec/controllers/home_controller_spec.rb:27:in `block (3 levels) in <top (required)>'
Finished in 0.02872 seconds (files took 2.88 seconds to load)
3 examples, 3 failures
Failed examples:
rspec ./spec/controllers/home_controller_spec.rb:4 # HomeController GET #index responds successfully
rspec ./spec/controllers/home_controller_spec.rb:14 # HomeController GET #about responds successfully
rspec ./spec/controllers/home_controller_spec.rb:24 # HomeController GET #terms responds successfully
Pipes