Search code examples
ruby-on-railsrubyrspecrubymine

using the --format documentation option with Rspec and Rake


I am in the process of learning Ruby and I recently set up a small project in which i am writing an API.

currently i have 2 classes, one called API which inherits from Grape

class API < Grape::API

(first quick question, within this class can i have normal methods, like def say_hello ? or is it just web methods?)

and one which i have called APIHelpers

i have set up 2 x spec files

api_spec.rb APIHelpers_spec.rb

this is the contents of my Rakefile:

require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new do |t|
  t.rspec_opts = '--format documentation'
  t.pattern = ['spec/libs/*.rb']
end

task :default => :spec

When i run the rake (i am using Rubymine 6.0 as my IDE) i am not getting any output from the Rspec except that the 2 tests i have added have passed.

2 examples, 0 failures, 2 passed Finished in 0.05642 seconds

using the --format documentation i would have expected to see the whole structure from the describe and it statements.

Does anyone have any idea on how i can go about making these tests show correctly using RubyMine?

thanks


Solution

  • in case anyone else comes across this question, here is what i did to get around this issue,

    instead of using Rake to run my tests i just used a Rspec configuration, added in an spec_helper and added in this bit of code

    RSpec.configure do |config|
      config.color_enabled = true
      config.tty = true
      config.formatter = :documentation
    
      config.expect_with :rspec do |c|
        c.syntax = :expect
      end
    end
    

    this fixed my issues