Can i get RSpec to generate specs with expect syntax?
Posted
by
papirtiger
on Stack Overflow
See other posts from Stack Overflow
or by papirtiger
Published on 2013-10-26T15:05:33Z
Indexed on
2013/10/28
15:54 UTC
Read the original article
Hit count: 143
ruby-on-rails
|rspec
When generating specs with :
rails g controller Home index
A spec is generated with the older object.should syntax
require 'spec_helper'
describe HomeController do
describe "GET 'index'" do
it "returns http success" do
get 'index'
response.should be_success
end
end
end
Is it possible to configure the generator to use the expect syntax instead?
Desired output:
require 'spec_helper'
describe HomeController do
describe "GET 'index'" do
it "returns http success" do
get 'index'
expect(response).to be_success
end
end
end
in config/application.rb:
config.generators do |g|
g.test_framework :rspec, fixture: true
g.fixture_replacement :factory_girl, dir: 'spec/factories'
g.view_specs false
g.stylesheets = false
g.javascripts = false
end
© Stack Overflow or respective owner