Created
August 26, 2014 01:27
-
-
Save coderdan/fe02eac374f0f3138d4e to your computer and use it in GitHub Desktop.
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An improvement would be to check the actual template output_buffer