rspec-rails (3.0.0.beta2)
์์ rspec-rails (3.0.0.rc1)
ํฌ๊ธฐ
require 'spec_helper'
describe ApplicationController do
controller do
def index
render :text => 'Ok'
end
def show
raise TypeError, 'Any fake value!'
end
end
it "redirects to new_sessions_path" do
get :index
expect(response).to redirect_to(new_session_path)
end
end
์ค๋ฅ
spec/controllers/application_controller_spec.rb:5:in `block (2 levels) in <top (required)>': undefined method `controller' for #<Class:0x007fed8fe69180> (NoMethodError)
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/ankitgupta/Documents/projects/work/my-development/spec/controllers/application_controller_spec.rb:4:in `block in <top (required)>'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/dsl.rb:79:in `block (2 levels) in expose_example_group_alias_globally'
from /Users/ankitgupta/Documents/projects/work/my-development/spec/controllers/application_controller_spec.rb:3:in `<top (required)>'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `load'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `block in load_spec_files'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `each'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `load_spec_files'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:97:in `setup'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:85:in `run'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:70:in `run'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/exe/rspec:4:in `<top (required)>'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `load'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `<main>'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/ankitgupta/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
rspec-rails 2.x์๋ ํ์ผ ์์น๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ฌ์ ์ ํ์ ์ ์ถํ๋ ๋งค์ฐ ์์์ ์ธ(์ผ๋ถ๋ "๋ง๋ฒ ๊ฐ์") ๋์์ด ์์ต๋๋ค. RSpec 3(RC1๋ถํฐ ์์)์์ ์ด๊ฒ์ ์ํ ๊ฒฝ์ฐ ์ตํธ์ธํ๊ฑฐ๋ ์ฌ์ ์ ํ์ ์ง์ ์ค์ ํด์ผ ํฉ๋๋ค.
describe ApplicationController, :type => :controller do
end
# or
RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end
์์ธํ ๋ด์ฉ์ rspec/rspec-rails#970์ ์ฐธ์กฐํ์ธ์.
2.14 -> 2.99 -> 3.0 ์ ๊ทธ๋ ์ด๋ ๊ฒฝ๋ก๋ฅผ ์ํํ๋ ์ฌ๋๋ค์ ๊ฒฝ์ฐ ์ด์ ๋ํ ๋ช ํํ ์ฌ์ฉ ์ค๋จ ๊ฒฝ๊ณ ๊ฐ ์์ง๋ง ๋ถํํ๋ 3.0 beta2 -> 3.0 RC1์์๋ ํธ๋ฆฌ๊ฑฐ๋์ง ์์ต๋๋ค. ๋ฏธ์ํฉ๋๋ค!
@myronmarston ๊ฐ์ฌํฉ๋๋ค! :+1:
@myronmarston ์ ํํ ๋ฌด์์ด ์๋ชป๋์๋์ง. ๊ฐ์ฌํฉ๋๋ค!
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
rspec-rails 2.x์๋ ํ์ผ ์์น๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ฌ์ ์ ํ์ ์ ์ถํ๋ ๋งค์ฐ ์์์ ์ธ(์ผ๋ถ๋ "๋ง๋ฒ ๊ฐ์") ๋์์ด ์์ต๋๋ค. RSpec 3(RC1๋ถํฐ ์์)์์ ์ด๊ฒ์ ์ํ ๊ฒฝ์ฐ ์ตํธ์ธํ๊ฑฐ๋ ์ฌ์ ์ ํ์ ์ง์ ์ค์ ํด์ผ ํฉ๋๋ค.
์์ธํ ๋ด์ฉ์ rspec/rspec-rails#970์ ์ฐธ์กฐํ์ธ์.
2.14 -> 2.99 -> 3.0 ์ ๊ทธ๋ ์ด๋ ๊ฒฝ๋ก๋ฅผ ์ํํ๋ ์ฌ๋๋ค์ ๊ฒฝ์ฐ ์ด์ ๋ํ ๋ช ํํ ์ฌ์ฉ ์ค๋จ ๊ฒฝ๊ณ ๊ฐ ์์ง๋ง ๋ถํํ๋ 3.0 beta2 -> 3.0 RC1์์๋ ํธ๋ฆฌ๊ฑฐ๋์ง ์์ต๋๋ค. ๋ฏธ์ํฉ๋๋ค!