开发者

Rails - Getting RSpec Working

开发者 https://www.devze.com 2023-02-17 11:21 出处:网络
I\'m learning how to do integration testin on my rails app. I started with cucumber but then learned since I\'m just testing a models method that I should be using RSPEC. So now I\'m trying to get RSP

I'm learning how to do integration testin on my rails app. I started with cucumber but then learned since I'm just testing a models method that I should be using RSPEC. So now I'm trying to get RSPEC installed.

When I run autotest, it is only looking at the /features directory not the /spec directory.

Here's what I've done so far:

.autotest

require 'autotest/growl'
require 'autotest/fsevent'

Autotest.add_hook(:initialize) {|at|
  at.add_exception %r{^\.git}  # ignore Version Control System
  at.add_exception %r{^./tmp}  # ignore temp files, lest autotest will run again, and again...
  #  at.cl开发者_StackOverflowear_mappings         # take out the default (test/test*rb)
  at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
    Dir['spec/**/*.rb']
  }
  nil
}


/spec - created directory
/spec/spec_helper.rb - created
/spec/lib/mailingjob_spec.rb - created, tried to write a case that would fail as follows:

require 'spec_helper'

describe User do
  before(:each) do
    @valid_attributes = {
      :login => "akm",
      :email => "akm2000@gmail.com",
      :password => "D1ff1cultPa55w0rd",
      :password_confirmation => "D1ff1cultPa55w0rd"
    }
  end

  it "should create a new instance given valid attributes" do
    User.create!(@valid_attributesXXXX)
  end
end

But when I run autotest this rpsec is never run only the features dir with cucumber is running. Ideas? thanks


Try:

rspec --configure autotest

From the autotest README:

[RSpec] if you want to use require 'spec_helper' -> rspec --configure autotest

0

精彩评论

暂无评论...
验证码 换一张
取 消