Skip to content

Instantly share code, notes, and snippets.

@coderdan
Created August 26, 2014 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderdan/fe02eac374f0f3138d4e to your computer and use it in GitHub Desktop.
Save coderdan/fe02eac374f0f3138d4e to your computer and use it in GitHub Desktop.
RSpec.describe LikertInput, type: :input do
class MockTemplate
include ActionView::Helpers
attr_accessor :output_buffer
end
let(:object) { double(:object, happiness: '1') }
let(:builder) { double(:builder, object: object) }
let(:input_options) { { value: '1', class: 'input-small' } }
subject do
described_class.new(builder, :happiness, :happiness, :likert)
end
before do
allow(subject).to receive(:template).and_return(MockTemplate.new)
expect(builder).to receive(:select)
.with(:happiness, LikertOption.to_a, input_options).and_return("select tag")
expect(subject).to receive(:input_html_options).and_return({})
end
specify do
expect(subject.input).to eq('<div class="input-append likert">select tag</div>')
end
end
@coderdan
Copy link
Author

An improvement would be to check the actual template output_buffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment