ruby on rails - RubyMine can't find RSpec specs -
i starting project in rubymine , having trouble configuring rspec. problem not seem 'seeing' tests, 0 files loaded.
. expecting test fail, unsure why not running in first place. relevant gems have been installed , bundled correctly far can tell , included in development section of gemfile
.
the output running rspec, followed files:
/users/richardcurteis/.rvm/rubies/ruby-2.0.0-p643/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=argv.shift) /applications/rubymine.app/contents/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb testing started @ 19:26 ... work directory: /users/richardcurteis/development/rubymineprojects/revenanttech/spec loading files.... ========================================= 0 files loaded. ========================================= running tests... process finished exit code 0
spec/controllers/welcome_controller_spec.rb
require 'spec_helper' describe welcomecontroller describe context 'user browses home page' 'displays welcome message' visit '/welcome' expect(page).should have_content('coming soon...') end end end end
spec/spec_helper.rb
# file copied spec/ when run 'rails generate rspec:install' env['rails_env'] ||= 'test' require file.expand_path('../../config/environment', __file__) require 'rspec/rails' require 'rspec/autorun' require 'capybara/rails' # prevent database truncation if environment production abort("the rails environment running in production mode!") if rails.env.production? # add additional requires below line. rails not loaded until point! # requires supporting ruby files custom matchers , macros, etc, in # spec/support/ , subdirectories. files matching `spec/**/*_spec.rb` # run spec files default. means files in spec/support end # in _spec.rb both required , run specs, causing specs # run twice. recommended not name files matching glob # end _spec.rb. can configure pattern --pattern # option on command line or in ~/.rspec, .rspec or `.rspec-local`. # # following line provided convenience purposes. has downside # of increasing boot-up time auto-requiring files in support # directory. alternatively, in individual `*_spec.rb` files, manually # require support files necessary. # # dir[rails.root.join('spec/support/**/*.rb')].each { |f| require f } # checks pending migration , applies them before tests run. # if not using activerecord, can remove line. activerecord::migration.maintain_test_schema! rspec.configure |config| # remove line if you're not using activerecord or activerecord fixtures config.fixture_path = "#{::rails.root}/spec/fixtures" # if you're not using activerecord, or you'd prefer not run each of # examples within transaction, remove following line or assign false # instead of true. config.use_transactional_fixtures = true # rspec rails can automatically mix in different behaviours tests # based on file location, example enabling call `get` , # `post` in specs under `spec/controllers`. # # can disable behaviour removing line below, , instead # explicitly tag specs type, e.g.: # # rspec.describe userscontroller, :type => :controller # # ... # end # # different available types documented in features, such in # https://relishapp.com/rspec/rspec-rails/docs config.infer_spec_type_from_file_location! # filter lines rails gems in backtraces. config.filter_rails_from_backtrace! # arbitrary gems may filtered via: # config.filter_gems_from_backtrace("gem name") end
spec/spec_helper.rb
require 'rails/helper' # file generated `rails generate rspec:install` command. conventionally, # specs live under `spec` directory, rspec adds `$load_path`. # generated `.rspec` file contains `--require spec_helper` cause # file loaded, without need explicitly require in # files. # # given loaded, encouraged keep file # light-weight possible. requiring heavyweight dependencies file # add boot time of test suite on every test run, # individual file may not need of loaded. instead, consider making # separate helper file requires additional dependencies , performs # additional setup, , require spec files need # it. # # `.rspec` file contains few flags not defaults # users commonly want. # # see http://rubydoc.info/gems/rspec-core/rspec/core/configuration rspec.configure |config| # rspec-expectations config goes here. can use alternate # assertion/expectation library such wrong or stdlib/minitest # assertions if prefer. config.expect_with :rspec |expectations| # option default `true` in rspec 4. makes `description` # , `failure_message` of custom matchers include text helper methods # defined using `chain`, e.g.: # be_bigger_than(2).and_smaller_than(4).description # # => "be bigger 2 , smaller 4" # ...rather than: # # => "be bigger 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end # rspec-mocks config goes here. can use alternate test double # library (such bogus or mocha) changing `mock_with` option here. config.mock_with :rspec |mocks| # prevents mocking or stubbing method not exist on # real object. recommended, , default # `true` in rspec 4. mocks.verify_partial_doubles = true end # settings below suggested provide initial experience # rspec, feel free customize heart's content. =begin # these 2 settings work allow limit spec run # individual examples or groups care tagging them # `:focus` metadata. when nothing tagged `:focus`, examples # run. config.filter_run :focus config.run_all_when_everything_filtered = true # allows rspec persist state between runs in order support # `--only-failures` , `--next-failure` cli options. recommend # configure source control system ignore file. config.example_status_persistence_file_path = "spec/examples.txt" # limits available syntax non-monkey patched syntax # recommended. more details, see: # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode config.disable_monkey_patching! # many rspec users commonly either run entire suite or individual # file, , it's useful allow more verbose output when running # individual spec file. if config.files_to_run.one? # use documentation formatter detailed output, # unless formatter has been configured # (e.g. via command-line flag). config.default_formatter = 'doc' end # print 10 slowest examples , example groups @ # end of spec run, surface specs running # particularly slow. config.profile_examples = 10 # run specs in random order surface order dependencies. if find # order dependency , want debug it, can fix order providing # seed, printed after each run. # --seed 1234 config.order = :random # seed global randomization in process using `--seed` cli option. # setting allows use `--seed` deterministically reproduce # test failures related randomization passing same `--seed` value # 1 triggered failure. kernel.srand config.seed =end end
spec/helpers/welcome_spec_helper.rb
#require 'rails_helper' require 'spec_helper' # specs in file have access helper object includes # welcomehelper. example: # # describe welcomehelper # describe "string concat" # "concats 2 strings spaces" # expect(helper.concat_strings("this","that")).to eq("this that") # end # end # end #rspec.describe welcomehelper, type: :helper # pending "add examples (or delete) #{__file__}" #end
looks rubymine running rspec in spec directory. default, rspec looks in subdirectory, named spec, of directory it's run in. rubymine seems misconfigured. either wrong particular run/debug configuration or rubymine project thinks spec directory (rather directory above it) project root.
you can confirm rspec ok on command line cd
ing root of project , running bin/rspec
.
Comments
Post a Comment