Reputation: 5916
I have decided to create my first gem and now I'm trying to install RSpec.
I have added spec.add_development_dependency "rspec", "~> 2.14"
to my .gemspec file and I have created spec/spec_helper.rb as below
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default, :development)
require 'my_gem'
RSpec.configure do |config|
config.color_enabled = true
config.formatter = 'documentation'
config.order = 'random'
end
After bundle it up, I have finally added spec/foobar_spec.rb as below
require 'spec_helper'
describe 'foobar' do
expect(1).to eq(2)
end
But when I run rspec spec/foobar_spec.rb I get
undefined method `expect' for # (NoMethodError)
Am I missing something here?
Thanks
Upvotes: 0
Views: 50
Reputation: 26193
According to the Rspec docs, expectations must be defined within it
blocks:
describe 'foobar' do
it { expect(1).to eq(2) }
end
Upvotes: 1