Built in matchers

Equality matchers

 expect("this string").not_to eq("a different string")

raise_error:

# expect any error
expect { ... }.to raise_error

# expect no error
expect { ... }.not_to raise_error

# expect any error with expected_message
expect { ... }.to raise_error(AnyError, /expected_message/)

Comparison matchers

expect(actual value).to be >= expection
expect(actual value).to be <= expection
expect(actual value).to be > expection
expect(actual value).to be > expection
expect(actual value).to be_between(minimum, maximum).inclusive
expect(actual value).to be_between(minimum, maximum).exclusive

Controller specs

Model specs

Request spec

context 'any context' do
  subject! { get '/path', var1: var1_value, var2: var2_value }
    it do
      expect(assigns(:any_instance_variable)).to eq('any_value')
      expect(response).to render_template('any_view_template')
    end
  end
end

View spec

Helper spec

Routing spec

Reference

results matching ""

    No results matching ""