Class: ODDB::TestCoMarketingPlugin

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_plugin/comarketing.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



12
13
14
15
# File 'test/test_plugin/comarketing.rb', line 12

def setup
  @app = FlexMock.new
  @plugin = CoMarketingPlugin.new(@app)
end

- (Object) test_find



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
# File 'test/test_plugin/comarketing.rb', line 16

def test_find
  flap_flag = false
  name = "Alpina Arnica-Gel mit Spilanthes, Gel"
  expected = [
    "Alpina Arnica Gel mit Spilanthes Gel",
    "Alpina Arnica Gel mit Spilanthes",
    "Alpina Arnica Gel mit",
    "Alpina Arnica Gel",
    "Alpina",
  ]
  @app.should_receive(:registration).and_return nil
  @app.should_receive(:search_sequences, 10).and_return { |query, fuzzflag|
    assert_equal(flap_flag, fuzzflag)
    flap_flag = !flap_flag
    exp = expected.shift
    assert_equal(exp, query)
    if(flap_flag)
      expected.unshift(exp)
    end
    []
  }
  result = @plugin.find(name)
  assert_nil(result)
  @app.flexmock_verify
end

- (Object) test_find__lacteol



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'test/test_plugin/comarketing.rb', line 41

def test_find__lacteol
  flap_flag = false
  name = "Lactéol 5, capsules"
  expected = [
    "Lacteol 5 capsules",
    "Lacteol 5",
    "Lacteol",
  ]
  @app.should_receive(:registration).and_return nil
  @app.should_receive(:search_sequences, 6).and_return { |query, fuzzflag|
    assert_equal(flap_flag, fuzzflag)
    flap_flag = !flap_flag
    exp = expected.shift
    assert_equal(exp, query)
    if(flap_flag)
      expected.unshift(exp)
    end
    []
  }
  result = @plugin.find(name)
  assert_nil(result)
  @app.flexmock_verify
end

- (Object) test_find__lactoferment



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'test/test_plugin/comarketing.rb', line 64

def test_find__lactoferment
  flap_flag = false
  name = "Lactoferment 5, Kapseln"
  expected = [
    "Lactoferment 5 Kapseln",
    "Lactoferment 5",
    "Lactoferment",
  ]
  @app.should_receive(:registration).and_return nil
  @app.should_receive(:search_sequences, 6).and_return { |query, fuzzflag|
    assert_equal(flap_flag, fuzzflag)
    flap_flag = !flap_flag
    exp = expected.shift
    assert_equal(exp, query)
    if(flap_flag)
      expected.unshift(exp)
    end
    []
  }
  result = @plugin.find(name)
  assert_nil(result)
end