Skip to content

Instantly share code, notes, and snippets.

@tennety
Last active October 10, 2019 14:24
Show Gist options
  • Save tennety/ee6837794b3a14e771dd28ff5a315e04 to your computer and use it in GitHub Desktop.
Save tennety/ee6837794b3a14e771dd28ff5a315e04 to your computer and use it in GitHub Desktop.
A Case for View Specs in Rails
.modal_content
- if @book.on_hold?
- # No action needed, user will be notified on availability
- else
- if @book.available_here?
- # Allow user to check it out
- else
- # Allow user to pick a different location to check out from
subject { Nokogiri::HTML(rendered) }
it 'renders a location select' do
expect(subject.css("select#location_selector")).to.not be_empty
expect(subject.at_css("#location_selector option").text).to match("Zanesville")
end
describe "reserving a book" do
let(:available_other_location_book) { create(:book, :available, location: "Zanesville") }
before do
assign(:book, available_other_location_book)
render partial: 'books/reserve_modal'
end
it 'displays other location availability message' do
expect(rendered).to match(/not available at your selected location/)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment