Module: Rails::AddOns::Shoulda::Matchers
- Defined in:
- lib/rails/add_ons/shoulda/matchers.rb,
lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb,
lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb,
lib/rails/add_ons/shoulda/matchers/implement_create_action_matcher.rb,
lib/rails/add_ons/shoulda/matchers/implement_delete_action_matcher.rb,
lib/rails/add_ons/shoulda/matchers/implement_update_action_matcher.rb
Overview
Defined Under Namespace
Classes: ImplementCreateActionMatcher, ImplementDeleteActionMatcher, ImplementIndexActionMatcher, ImplementShowActionMatcher, ImplementUpdateActionMatcher
Instance Method Summary collapse
-
#implement_create_action(spec) ⇒ Object
Example:.
-
#implement_delete_action(spec) ⇒ Object
Example:.
-
#implement_index_action(spec) ⇒ Object
Example:.
-
#implement_show_action(spec) ⇒ Object
Example:.
-
#implement_update_action(spec) ⇒ Object
Example:.
Instance Method Details
#implement_create_action(spec) ⇒ Object
Example:
RSpec.describe '/posts', type: :feature do
it {
expect(subject).to implement_create_action(self)
.for(Post)
.within_form('#new_post') {
fill_in 'post[title]', with: 'My first post'
}
.increasing{ |resource_class| resource_class.count }.by(1)
}
end
18 19 20 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_create_action_matcher.rb', line 18 def implement_create_action(spec) ImplementCreateActionMatcher.new(spec) end |
#implement_delete_action(spec) ⇒ Object
Example:
RSpec.describe '/posts', type: :feature do
let(:resource_class) { Post }
let(:resource) { create(:post) }
it {
expect(subject).to implement_delete_action(self)
.for(resource)
.reducing{ resource_class.count }.by(1)
}
end
18 19 20 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_delete_action_matcher.rb', line 18 def implement_delete_action(spec) ImplementDeleteActionMatcher.new(spec) end |
#implement_index_action(spec) ⇒ Object
Example:
RSpec.describe '/posts', type: :feature do
before(:each) { create_list(:post, 3) }
it { expect(subject).to implement_index_action(self) }
end
13 14 15 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 13 def implement_index_action(spec) ImplementIndexActionMatcher.new(spec) end |
#implement_show_action(spec) ⇒ Object
Example:
RSpec.describe '/posts', type: :feature do
let(:resource) { create(:post) }
it { expect(subject).to implement_show_action(self).for(resource) }
end
13 14 15 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 13 def implement_show_action(spec) ImplementShowActionMatcher.new(spec) end |
#implement_update_action(spec) ⇒ Object
Example:
RSpec.describe '/posts', type: :feature do
let(:post) { create(:post) }
it {
expect(subject).to implement_update_action(self)
.for(post)
.within_form('.edit_post') {
fill_in 'post[title]', with: 'New title'
fill_in 'post[body]', with: 'New body'
}
.updating{ |resource| resource.attributes }
.from(post.attributes)
.to({ 'title' => 'New title', 'body' => 'New body' })
}
end
22 23 24 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_update_action_matcher.rb', line 22 def implement_update_action(spec) ImplementUpdateActionMatcher.new(spec) end |