blob: 8075a509eb11903c27d31a5e29080c003f7b8f0f (
plain)
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
|
require 'spec_helper'
describe Chouette::Direction, :type => :model do
describe ".new" do
context "when single argument provided is a direction" do
let(:text) { "dummy"}
let(:direction){ Chouette::Direction.new( text, 1)}
it "should be equals to the provided direction" do
expect(direction).to eq(Chouette::Direction.new( direction))
end
end
end
shared_examples_for "west direction" do
it "should return true to #west? " do
expect(direction).to be_west
end
context "#to_i" do
it "should return 6" do
expect(direction.to_i).to eq(6)
end
end
end
context "when instanciating with existing text only ('west' for example)" do
let(:direction){ Chouette::Direction.new "west"}
it_should_behave_like "west direction"
end
context "when instanciating with existing numerical code only (6 for example)" do
let(:direction){ Chouette::Direction.new 6}
it_should_behave_like "west direction"
end
context "when instanciating with 'dummy' and 1 as argumrent" do
let(:text) { "dummy"}
let(:number) { 1}
let(:direction){ Chouette::Direction.new( text, number)}
it "should return true to #dummy? " do
expect(direction.send( "#{text}?".to_sym)).to be_truthy
end
it "should return false to #other-dummy? " do
expect(direction.send( "other-#{text}?".to_sym)).to be_falsey
end
context "#to_i" do
it "should return provided number" do
expect(direction.to_i).to eq(number)
end
end
context "#name" do
it "should return provided text" do
expect(direction.name).to eq(text)
end
end
end
end
|