File: settings_spec.rb

package info (click to toggle)
ruby-mina 0.3.7-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 444 kB
  • sloc: ruby: 1,630; makefile: 31
file content (61 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'spec_helper'

describe 'Settings' do
  describe 'instances' do
    before :each do
      @settings = Mina::Settings.new
    end

    it 'setting/getting should work' do
      @settings.domain = '192.168.1.1'

      expect(@settings.domain).to eq('192.168.1.1')
    end

    it 'question mark should work' do
      @settings.deploy_to = '/var/www/there'

      expect(@settings.deploy_to?).to be_truthy
      expect(@settings.foobar?).to be_falsey
    end

    it 'question mark should work with nils' do
      @settings.deploy_to = nil

      expect(@settings.deploy_to?).to be_truthy
      expect(@settings.foobar?).to be_falsey
    end

    it '||= should work (1)' do
      @settings.x = 2
      @settings.x ||= 3

      expect(@settings.x).to eq(2)
    end

    it '||= should work (2)' do
      @settings.x ||= 3

      expect(@settings.x).to eq(3)
    end

    it 'lambdas should work' do
      @settings.path = lambda { "/var/www/#{@settings.version}" }
      @settings.version = '3'

      expect(@settings.path?).to be_truthy
      expect(@settings.path).to eq("/var/www/3")
    end

    it 'bangs should check for settings' do
      expect { @settings.non_existent_setting! }.to raise_error(Mina::Error, /non_existent_setting/)
    end

    it 'bangs should return settings' do
      @settings.version = 4

      expect(@settings.version!).to eq(4)
    end
  end
end