Anyone know how to get around this? On OSX, trying to get RSpec running with Rails 3.0.7. Full details at: https://gist.github.com/1017044
it "renders buttons_widgets partial" do get :buttons_widgets response.should render_template("buttons_widgets") end → rspec tools_model_spec.rb /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/version.rb:4: warning: already initialized constant STRING /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/metadata.rb:48: warning: already initialized constant RESERVED_KEYS /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/pending.rb:6: warning: already initialized constant DEFAULT_MESSAGE /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/world.rb:6: warning: already initialized constant PROC_HEX_NUMBER /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/world.rb:7: warning: already initialized constant PROJECT_DIR /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/configuration.rb:43: warning: already initialized constant CONDITIONAL_FILTERS /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/configuration.rb:48: warning: already initialized constant DEFAULT_BACKTRACE_PATTERNS /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/runner.rb:13: warning: already initialized constant AT_EXIT_HOOK_BACKTRACE_LINE /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core.rb:35: warning: already initialized constant SharedContext Run filtered excluding {:if=>#<Proc:/Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:43>, :unless=>#<Proc:/Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:44>} F Failures: 1) ToolsController renders buttons_widgets partial Failure/Error: get :buttons_widgets NoMethodError: undefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000106db51f8> # ./tools_model_spec.rb:7:in `block (2 levels) in <top (required)>'
RSpec doesn't know that your spec is a controller spec, so your examples don't have access to a get
method.
RSpec 2.x assumes that everything in the controllers directory is a controller spec.
This was changed in RSpec 3:
File-type inference disabled by default
Previously we automatically inferred spec type from a file location, this was a surprising behaviour for new users and undesirable for some veteran users so from RSpec 3 onwards this behaviour must be explicitly opted into with:
RSpec.configure do |config| config.infer_spec_type_from_file_location! end
https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#file-type-inference-disabled
In the rspec-rails README:
Controller specs default to residing in the
spec/controllers folder
. Tagging any context with the metadata:type => :controller
treats it's examples as controller specs.
An example of setting the controller context metadata for RSpec:
describe ToolsController, :type => :controller do # ... end
If at all you are using 'spec/features', you may need to add the following to your 'spec_helper.rb'
config.include RSpec::Rails::RequestExampleGroup, type: :feature
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With