sms_beholder_spec.rb 1.4 KB
Newer Older
Joe Libipl's avatar
Joe Libipl committed
1
2
3
4
5
6
7
8
9
10
11
12
require 'spec_helper'
require 'rack/test'
require_relative '../sms_beholder.rb'

describe SMSBeholder do
  include Rack::Test::Methods

  def app
    SMSBeholder.new
  end

  it 'responds with initial state' do
13
    get '/', From: 'Dude1'
Joe Libipl's avatar
Linting    
Joe Libipl committed
14

15
    expect(last_response.body).to include('Please tell me your name.')
Joe Libipl's avatar
Joe Libipl committed
16
17
  end

18
19
20
  it 'responds with initial state for each player' do
    get '/', From: 'Dude1'
    get '/', From: 'Dude2'
Joe Libipl's avatar
Linting    
Joe Libipl committed
21

22
23
24
25
26
27
    expect(last_response.body).to include('Please tell me your name.')
  end

  it 'moves to second state' do
    get '/', From: 'Dude3'
    get '/', From: 'Dude3'
Joe Libipl's avatar
Linting    
Joe Libipl committed
28

29
    expect(last_response.body).to include('Day One.')
Joe Libipl's avatar
Joe Libipl committed
30
  end
Joe Libipl's avatar
Joe Libipl committed
31
32
33
34
35
36
37
38
39

  it 'accepts a player name' do
    get '/', From: 'Dude4'
    get '/', From: 'Dude4', Body: 'NameOfDude4'
    get '/', From: 'Dude4'
    get '/', From: 'Dude4'

    expect(last_response.body).to include("You're NameOfDude4, a student at Beholder High.")
  end
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

  it 'uses the right player name' do
    get '/', From: 'Dude5'
    get '/', From: 'Dude5', Body: 'NumberFive'
    get '/', From: 'Dude6'
    get '/', From: 'Dude6'
    get '/', From: 'Dude5'
    get '/', From: 'Dude5'

    expect(last_response.body).to include("You're NumberFive, a student at Beholder High.")
  end

  it 'lets you skip to a different state for testing' do
    get '/', From: 'Dude7', SkipToState: 'D1S107'

    expect(last_response.body).to include("Your brooding has distracted you")
  end

Joe Libipl's avatar
Joe Libipl committed
58
end