Class: MarkdownExec::TestLinkHistory
- Defined in:
- lib/link_history.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #test_context_code_accessor ⇒ Object
- #test_context_code_append ⇒ Object
- #test_context_code_block ⇒ Object
- #test_context_code_count ⇒ Object
- #test_context_code_equality ⇒ Object
- #test_context_code_present? ⇒ Boolean
- #test_deprecated_context_code_methods ⇒ Object
- #test_peek_empty ⇒ Object
- #test_pop ⇒ Object
- #test_pop_empty ⇒ Object
- #test_push ⇒ Object
Instance Method Details
#setup ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/link_history.rb', line 142 def setup @link_history = LinkHistory.new @link_state1 = LinkState.new( block_name: 'block1', document_filename: 'document1.txt', context_code: ['code1.rb'] ) @link_state2 = LinkState.new( block_name: 'block2', document_filename: 'document2.txt', context_code: ['code2.rb'] ) end |
#test_context_code_accessor ⇒ Object
174 175 176 177 |
# File 'lib/link_history.rb', line 174 def test_context_code_accessor state = LinkState.new(context_code: %w[line1 line2]) assert_equal %w[line1 line2], state.context_code end |
#test_context_code_append ⇒ Object
184 185 186 187 188 |
# File 'lib/link_history.rb', line 184 def test_context_code_append state = LinkState.new(context_code: ['line1']) state.context_code_append(['line2']) assert_equal %w[line1 line2], state.context_code end |
#test_context_code_block ⇒ Object
179 180 181 182 |
# File 'lib/link_history.rb', line 179 def test_context_code_block state = LinkState.new(context_code: %w[line1 line2]) assert_equal "line1\nline2", state.context_code_block end |
#test_context_code_count ⇒ Object
190 191 192 193 |
# File 'lib/link_history.rb', line 190 def test_context_code_count state = LinkState.new(context_code: %w[line1 line2 line3]) assert_equal 3, state.context_code_count end |
#test_context_code_equality ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/link_history.rb', line 202 def test_context_code_equality state1 = LinkState.new(context_code: ['line1']) state2 = LinkState.new(context_code: ['line1']) state3 = LinkState.new(context_code: ['line2']) assert_equal state1, state2 refute_equal state1, state3 end |
#test_context_code_present? ⇒ Boolean
195 196 197 198 199 200 |
# File 'lib/link_history.rb', line 195 def test_context_code_present? state_with_code = LinkState.new(context_code: ['line1']) state_without_code = LinkState.new(context_code: nil) assert state_with_code.context_code_present? refute state_without_code.context_code_present? end |
#test_deprecated_context_code_methods ⇒ Object
210 211 212 213 214 215 216 217 |
# File 'lib/link_history.rb', line 210 def test_deprecated_context_code_methods state = LinkState.new(context_code: %w[line1 line2]) # Test backward compatibility assert_equal %w[line1 line2], state.context_code assert_equal "line1\nline2", state.context_code_block assert_equal 2, state.context_code_count assert state.context_code_present? end |
#test_peek_empty ⇒ Object
166 167 168 |
# File 'lib/link_history.rb', line 166 def test_peek_empty assert_equal LinkState.empty, @link_history.peek end |
#test_pop ⇒ Object
159 160 161 162 163 164 |
# File 'lib/link_history.rb', line 159 def test_pop @link_history.push(@link_state1) @link_history.push(@link_state2) assert_equal @link_state2, @link_history.pop assert_equal @link_state1, @link_history.peek end |
#test_pop_empty ⇒ Object
170 171 172 |
# File 'lib/link_history.rb', line 170 def test_pop_empty assert_equal LinkState.empty, @link_history.pop end |
#test_push ⇒ Object
154 155 156 157 |
# File 'lib/link_history.rb', line 154 def test_push @link_history.push(@link_state1) assert_equal @link_state1, @link_history.peek end |