Last active
October 10, 2019 14:24
-
-
Save tennety/ee6837794b3a14e771dd28ff5a315e04 to your computer and use it in GitHub Desktop.
A Case for View Specs in Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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